-
Notifications
You must be signed in to change notification settings - Fork 40
Description
When an MCP client sends a tools/call request where _meta.progressToken is a numeric value (e.g., 1 or 42), the server throws: MCP error -32000: The JSON value could not be converted to System.String. Path: $._meta.progressToken | LineNumber: 0 | BytePositionInLine: 163.
The MetaData.ProgressToken property appears to be typed as string, but the MCP specification defines progressToken as ProgressToken which is string | number
(https://spec.modelcontextprotocol.io/specification/2025-03-26/basic/utilities/progress/). Claude Code (Anthropic's CLI) sends progressToken as a numeric value, which causes
System.Text.Json to reject the deserialization.
Steps to Reproduce:
- Create an MCP server using MCPSharp v1.0.11
- Connect via a client that sends numeric progressToken values (e.g., Claude Code)
- Call any tool
Expected: Tool executes successfully, progressToken accepts both string and number values per the MCP spec.
Actual: All tool calls fail with the deserialization error above.
Suggested Fix:
Change ProgressToken in the MetaData class from string to a type that accepts both, e.g.:
// Option A: Use object
[JsonPropertyName("progressToken")]
public object? ProgressToken { get; set; }
// Option B: Use JsonElement for deferred parsing
[JsonPropertyName("progressToken")]
public JsonElement? ProgressToken { get; set; }
// Option C: Custom JsonConverter that coerces number to string
[JsonConverter(typeof(StringOrNumberConverter))]
[JsonPropertyName("progressToken")]
public string? ProgressToken { get; set; }
Environment:
- MCPSharp v1.0.11
- .NET 9.0
- Client: Claude Code (Anthropic CLI)