-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
The MCP TypeScript SDK generates JSON Schema draft-07 via [email protected], causing 400 errors when MCP servers are used with modern MCP clients (e.g. Claude Code in this report), which requires strict compliance with JSON Schema draft-2020-12. This breaks compatibility between the MCP ecosystem & Claude Code.
To Reproduce (Claude Code)
- Create an MCP server using the TypeScript SDK with any Zod schema (e.g., Mapbox MCP Server)
- Build and run the MCP server
- Configure Claude Code to use the MCP server
- Attempt to use any tool from the MCP server in Claude Code
- Observe 400 error: "JSON schema is invalid. It must match JSON Schema draft 2020-12"
Expected behavior
MCP servers built with the TypeScript SDK should generate JSON Schema draft-2020-12 compatible schemas that work seamlessly with Claude Code (and other popular MCP clients) and other modern JSON Schema validators.
Logs
Error from Claude Code:
> Hi there!
⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"tools.74.custom.input_schema: JSON schema is invalid. It must
match JSON Schema draft 2020-12 (https://json-schema.org/draft/2020-12). Learn more about tool use at
https://docs.anthropic.com/en/docs/tool-use."}}
> What the!!
⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"tools.54.custom.input_schema: JSON schema is invalid. It must
match JSON Schema draft 2020-12 (https://json-schema.org/draft/2020-12). Learn more about tool use at
https://docs.anthropic.com/en/docs/tool-use."}}
Root cause in https://github.com/modelcontextprotocol/typescript-sdk/blob/main/src/server/mcp.ts:
zodToJsonSchema(tool.inputSchema, {
strictUnions: true,
})Additional context
- Root cause: SDK uses [email protected] which defaults to draft-07
- Impact: Affects all MCP servers using TypeScript SDK (Mapbox, database connectors, etc.)
- Related issues:
- [BUG] JSON schema is invalid. It must match JSON Schema draft 2020-12 anthropics/claude-code#586 - Claude Code compatibility issue
- Discussion: Schema's problem rust-sdk#182 - Similar issue in Rust SDK
- Discussion Update README.md to use correct location of InMemoryEventStore #366 - Schema draft standards discussion
- Solution: Upgrade to Zod v4's native
toJSONSchema({ target: "draft-2020-12" })or configurezod-to-json-schemafordraft-2020-12output - Environment: @modelcontextprotocol/[email protected], [email protected]
nicolasembleton and Mihailoff
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working