Can the MCP TypeScript SDK tool() accept ArkType/Valibot instead of Zod?
The modelcontextprotocol/typescript-sdk tool() helper is coupled to Zod via ZodRawShape and zod-to-json-schema. Can it be changed to accept Standard Schema so ArkType, Valibot, or other runtime type libraries work too? No specific error occurs; this is a design limitation raised in February 2025.
Originally asked on GitHub: https://github.com/modelcontextprotocol/typescript-sdk/issues/164
5 answers
The issue is marked closed/completed, but the thread itself does not describe a merged implementation or a released change; it records the design discussion and a draft PR. A maintainer said a PR would be welcome.
The plan that got the maintainer's interest was: change public signatures from T extends ZodRawShape to StandardSchemaV1, replace zod parse calls with the Standard Schema validate API, and generate JSON Schema with a runtime-type-agnostic toJSONSchema utility. A draft PR following that plan was opened, but the thread does not say it was merged.
The main blocker explained in the thread is that Standard Schema standardizes static type extraction and input validation, but not JSON Schema generation. Different model providers support different JSON Schema subsets: for example, OpenAI tool calling supports $defs, $refs, and anyOf, while disallowing some constraints and expecting additionalProperties to be disabled. A commenter concluded that users still have to decide how to generate the JSON Schema for the specific model they target. One comment noted that Valibot users can use @valibot/to-json-schema, but Standard Schema itself had no toJSONSchema method at that time.
Later discussion suggested Standard Schema could add an optional toJsonSchema method with no options that throws for schemas with transformations, and that AI providers should parse the JSON Schema and return an error for unsupported features. No final decision on that is recorded here.
Did this work for you?What a GitHub user tried on GitHub (Outcome unclear)
The issue author proposed changing tool()'s params schema type from ZodRawShape to StandardSchemaV1 and wrapping non-Zod types with an adapter similar to Hono's standard-validator, using ArkType as an example. No implementation was included.
Source: https://github.com/modelcontextprotocol/typescript-sdk/issues/164 (opens external site)
Did this work for you?What @harrysolovay tried on GitHub (Outcome unclear)
A commenter proposed changing signatures to StandardSchemaV1, replacing zod parse calls with the Standard Schema validate method, and using a runtime-type-agnostic toJSONSchema utility. They offered to submit a PR.
Did this work for you?What @harrysolovay tried on GitHub (Outcome unclear)
A draft PR was opened following the proposed plan, with the author saying there were still quirks to iron out. The thread does not record whether it was merged.
Did this work for you?What @fabian-hiller tried on GitHub (Outcome unclear)
A commenter suggested MCP should accept Standard Schema or JSON Schema directly to avoid vendor lock-in and offered to discuss adding a toJSONSchema method to the Standard Schema spec. No decision is recorded.
Did this work for you?
Related questions
- MCP TypeScript SDK StreamableHttp without sticky sessions in multi-replica deployments?
- MCP stdio server: SyntaxError Unexpected token in deserializeMessage when using console.log
- MCP typescript-sdk: tool inputSchema/outputSchema reject JSON Schema type 'array'?
- Use Zod union/intersection as MCP tool paramsSchema in typescript-sdk?
- MCP Inspector: "Invalid transport type: undefined" when connecting to an SSE server