Support JSON schema in addition to zod #283
Copy link
Copy link
Closed
Labels
P1Significant bug affecting many users, highly requested featureSignificant bug affecting many users, highly requested featureenhancementRequest for a new feature that's not currently supportedRequest for a new feature that's not currently supportedneeds decisionIssue is actionable, needs maintainer decision on whether to implementIssue is actionable, needs maintainer decision on whether to implementv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixesIdeas, requests and plans for v2 of the SDK which will incorporate major changes and fixes
Milestone
Description
Why dont you add support for jsonschema in addition to zod. A lot of projects already have jsonshemas defined and you are converting internally from zod to jsonschema.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P1Significant bug affecting many users, highly requested featureSignificant bug affecting many users, highly requested featureenhancementRequest for a new feature that's not currently supportedRequest for a new feature that's not currently supportedneeds decisionIssue is actionable, needs maintainer decision on whether to implementIssue is actionable, needs maintainer decision on whether to implementv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixesIdeas, requests and plans for v2 of the SDK which will incorporate major changes and fixes
Activity
[-]Support JSON schema in addition to sod[/-][+]Support JSON schema in addition to zod[/+]ThomasAribart commentedon May 26, 2025
I guess this is for type-safety/devX. However there are tools for type inference like https://github.com/ThomasAribart/json-schema-to-ts.
tianlinle commentedon Jun 23, 2025
I'm also looking forward to JSON-Schema. @ThomasAribart It's not for type-safety, it's the same goal as zod. Right now I'm using ajv to validate any JSON data by JSON-Schema. Tool calling in most LLMs is using JSON-schema to describe the args of a function, so I think it's helpful if MCP also can support JSON-Schema in addition to zod.
finom commentedon Jun 28, 2025
After creating vercel-labs/mcp-handler#65 and digging thru the source codes I found this repository. I'm using
@vercel/mcp-adapterand all I have is JSON Schema. My attempts to convert it to Zod were unsuccessful.It seems like the SDK supports Zod 3 only with legacy zod-to-json-schema, even though there is a plenty of libraries, including Zod 4, Valibot and other libraries that implement Standard Schema and their own
toJSONSchemafirst-, second-, or 3rd-party implementation. IMO, such an important SDK should be JSON Schema-first, instead of one-legacy-library-first, even though Zod 3 is still maintained.Ajv has a nice TypeScript library that might be a great fit to support JSON Schemas. At this case the SDK can support basically all modern validation libraries, instead of one specific version of one specific library.
Rutledge commentedon Jun 28, 2025
+1 for JSON Schema support. I'm currently blocked by this when using Stainless-generated MCP
tools.
Stainless (and many other code generators) produce plain JSON schemas from OpenAPI specs.
When these are passed to
server.tool(), the MCP SDK tries to runzodToJsonSchema()onthem, which fails because they're already JSON schemas, not Zod schemas.
This results in:
undefinedfor all parametersannotationsinstead ofinputSchema)Supporting plain JSON schemas would enable:
Related issue in Vercel adapter: vercel-labs/mcp-handler#65
priolo commentedon Jul 27, 2025
+1 for JSON Schema support.
Transforming from JSON Schema to ZOD is not easy.
emaciel10 commentedon Aug 6, 2025
Completely agreed, going from json schema to a clean zod schema has been a pain for us so having MCPServer work with just json schema would be great!
bahatron commentedon Sep 24, 2025
We use https://github.com/sinclairzx81/typebox for types, the runtime object is a normal valid jsonschema object. Would be nice to be able to give it valid jsonschema coming from typebox
logseq-cldwalker commentedon Sep 25, 2025
We're using this library from clojurescript and already have json schemas created by https://github.com/metosin/malli. We'd love to be able to reuse these json schemas without having to maintain a separate zod version of them
dan-kwiat commentedon Oct 5, 2025
I agree it would be nice to have the option of using JSON Schema in the helpers
registerTool,registerPromptetc. and I'd be happy to implement it. But FYI you can already work with JSON Schema through the low-level server:finom commentedon Nov 14, 2025
I'm working on a project that requires supporting a lot of libraries out of the box but also convertion to JSON Schema. There is my proposal for solving this problem.
There are two key limitations in today's ecosystem:
1. Standard Schema does not provide
toJSONSchemaThis is intentional to keep package sizes small. Libraries like Valibot ship JSON Schema support as separate packages (e.g.,
@valibot/to-json-schema).2. JSON Schema validators do not understand Standard Schema
There is no JSON Schema validator that accepts Standard Schema directly.
✅ Proposed Solution
1. A new Ajv-based Standard Schema implementation
Introduce a function that implements the Standard Schema interface using Ajv internally.
2. A universal adapter
Introduce a function that wraps any Standard Schema implementation and adds JSON Schema conversion capabilities.
In the context of MCP SDK this may look like:
I could take care of implementing this if the proposal looks good to you. Let me know your thoughts.
KKonstantinov commentedon Dec 5, 2025
Adding this to #809
fix(schema): migrate to Zod v4 and SDK 1.30 to clear the remaining ar…
felixweinberger commentedon Oct 5, 2026
v2 takes tool schemas from any Standard Schema library that can produce JSON Schema, and
fromJsonSchema()wraps a plain JSON Schema you already have (#1689, released in 2.0.0). v1 stays on Zod forregisterTool(); the low-levelsetRequestHandlerroute shown above works there. Closing.