How to use TypeBox instead of Zod for inputSchema/outputSchema in the MCP TypeScript SDK?
In the modelcontextprotocol/typescript-sdk (v1), how can I use TypeBox instead of Zod for tool inputSchema and outputSchema? The GitHub issue requesting TypeBox support (opened 2025-07-30) was closed as completed, but what is the actual workaround for v1 and what is planned for v2?
Originally asked on GitHub: https://github.com/modelcontextprotocol/typescript-sdk/issues/825
3 answers
The issue was closed as completed, but the thread describes a plan and a workaround rather than a shipped v1 fix: v2 is planned to be validator-agnostic, tracked in issue #809.
For the current v1 SDK, the contributor recommends switching from the high-level
McpServerclass to the low-levelServerclass, becauseServeraccepts a raw JSON schema. The two commenters disagree on one detail:- The contributor says you must convert your TypeBox object to JSON Schema yourself before passing it to
Server. - The TypeBox author says TypeBox objects already are JSON Schema (
Type.String()produces{ type: 'string' }), so they shouldn't require conversion and should be compatible with any SDK interface that accepts JSON Schema binding.
That author statement is an expectation, not a tested confirmation, and the thread does not report anyone actually running either approach. Verify both suggestions against your SDK version.
The TypeBox author also shared a proposal called TypeDriver (github.com/sinclairzx81/typedriver) with middleware that would let the SDK support both JSON Schema and Standard Schema (Zod 3 & 4, Valibot, ArkType). That is a proposal for discussion, not a shipped SDK feature. Follow issue #809 for the v2 validator-agnostic design.
Did this work for you?- The contributor says you must convert your TypeBox object to JSON Schema yourself before passing it to
What @KKonstantinov tried on GitHub (Outcome unclear)
A contributor suggested switching from the high-level McpServer class to the low-level Server class, which accepts a raw JSON schema, and converting the TypeBox object to JSON Schema yourself before passing it.
Did this work for you?What @sinclairzx81 tried on GitHub (Outcome unclear)
The TypeBox author replied that TypeBox objects are already JSON Schema (e.g. Type.String() is { type: 'string' }), so they shouldn't require conversion and should be compatible with SDK interfaces that accept JSON Schema; he also shared a TypeDriver middleware proposal.
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