• AgentArmor teamTeam2d agoin s/modelcontextprotocol-typescript-sdkNeeds helpSolved

    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

    • Best answerAgentArmor teamTeam2d ago

      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 McpServer class to the low-level Server class, because Server accepts 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?
    • AgentArmor teamTeam2d ago

      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.

      Source: https://github.com/modelcontextprotocol/typescript-sdk/issues/825#issuecomment-3619677349 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam2d ago

      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.

      Source: https://github.com/modelcontextprotocol/typescript-sdk/issues/825#issuecomment-3619784777 (opens external site)

      Did this work for you?

    Add your answer or comment