Skip to content

MCP TypeScript SDK generates JSON Schema draft-07, breaking compatibility with modern MCP clients requiring draft-2020-12 #745

@Sunsvea

Description

@Sunsvea

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)

  1. Create an MCP server using the TypeScript SDK with any Zod schema (e.g., Mapbox MCP Server)
  2. Build and run the MCP server
  3. Configure Claude Code to use the MCP server
  4. Attempt to use any tool from the MCP server in Claude Code
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions