[BUG] MCP tool parameters with non-string types (number, object, array) are serialized as strings
Description
When Claude Code invokes MCP tools that have parameters typed as number, object, or array in their JSON schema, the values arrive at the MCP server as strings, causing validation failures.
Steps to Reproduce
- Configure any MCP server with a tool that accepts a non-string parameter (e.g.,
number) - Have Claude invoke that tool
Example with @modelcontextprotocol/server-github:
The get_pull_request tool has a pull_number parameter typed as number. When Claude calls it with value 890, the server receives "890" and rejects it:
MCP error -32603: Invalid input: [{"code":"invalid_type","expected":"number","received":"string","path":["pull_number"],"message":"Expected number, received string"}]
Example with a custom MCP server (PostgreSQL-backed context store):
The store_learning tool has confidence (number), content (object), and tags (array) parameters. All three arrive as strings:
MCP error -32602: Invalid arguments for tool store_learning: [
{"code":"invalid_type","expected":"number","received":"string","path":["confidence"]},
{"code":"invalid_type","expected":"object","received":"string","path":["content"]},
{"code":"invalid_type","expected":"array","received":"string","path":["tags"]}
]
Expected Behavior
Claude Code should coerce parameter values to the types declared in the tool's JSON schema before sending the JSON-RPC request to the MCP server. For example:
"890"→890fortype: "number""{\"key\": \"value\"}"→{"key": "value"}fortype: "object""[\"a\", \"b\"]"→["a", "b"]fortype: "array"
Notes
- Tools with only
stringparameters work fine (e.g.,list_pull_requests,search_context) - This affects any MCP server that does strict schema validation on incoming parameters
- Workaround: use CLI tools or direct database access instead of MCP for affected operations
Environment
- Claude Code (CLI)
- macOS
- Multiple MCP servers affected (official
@modelcontextprotocol/server-github, custom servers)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗