Skip to content

Zod 4 supported #555

Closed
Closed

Description

@tangye1234

Is your feature request related to a problem? Please describe.
Currently, server.tool() uses a zod3 raw shape type for its input schema. Zod 4 is now currently release, and our input schema validation is all written in zod 4.

There isn't a compatible conversion between zod 3/4 up to now, so we are stuck here.

Describe the solution you'd like
I recommend to use a custom validation schema as an overload for this method, like vercel/ai-sdk.

Describe alternatives you've considered
We would also like to see the method supports v4/v3 both if the type can be inferred.

Activity

  1. added
    enhancementRequest for a new feature that's not currently supported
    on May 27, 2025
  2. pattobrien commented on May 31, 2025

    @pattobrien

    Relevant issue: #164

  3. tangye1234 commented on Jun 17, 2025

    @tangye1234
    Author

    I use this type to adopt any json schema library:

    #164 (comment)

  4. timonbimon commented on Jun 23, 2025

    @timonbimon

    We're also blocked by this (all our schema validation is zod 4)

  5. ydennisy commented on Jul 10, 2025

    @ydennisy

    +1 here

  6. pattobrien commented on Jul 10, 2025

    @pattobrien

    FWIW, we have full Standard Schema support over at FastMCP; it's a good alternative while this issue is prioritized.

  7. acaumartin-cameleon commented on Jul 14, 2025

    @acaumartin-cameleon

    +1

  8. nicolasembleton commented on Jul 25, 2025

    @nicolasembleton

    I've upgraded the library to support Zod V4 and have been using it successfully in my CLI > MCP DXT building library library. If you need compatibility, you can install via NPM registry:

    pnpm add @alcyone-labs/modelcontextprotocol-sdk
    # or
    npm install @alcyone-labs/modelcontextprotocol-sdk

    Since it's a re-published package, you will have to import from the NPM package as follows, for example:

    import { McpServer, ResourceTemplate } from "@alcyone-labs/modelcontextprotocol-sdk/server/mcp";

    The repo is available here: https://github.com/Alcyone-Labs/mcp-typescript-sdk

    The update focuses on upgrading to V4 + getting all tests to pass. Happy to create a PR if needed, but this would potentially break anyone not using V4. I haven't tested it well with V3.

    EDIT: I published the package on NPM to make it more deterministic and allow me to keep updating the package from upstream, and have a better sense of whether anyone's using the fork or not (via weekly downloads). The repo is the same, the NPM package is available here:
    https://www.npmjs.com/package/@alcyone-labs/modelcontextprotocol-sdk

  9. wottpal commented on Jul 29, 2025

    @wottpal

    amazing! would be personally fine with a breaking v4 release/pr

  10. nicolasembleton commented on Aug 1, 2025

    @nicolasembleton

    amazing! would be personally fine with a breaking v4 release/pr

    Me too. But I think having a V4 branch for a few weeks would make sense, it's going to break many users otherwise, which is undesirable.

    Do you think I should publish the version to NPM @wottpal? Hesitant to do so, but would make the code more predictable (I want to upgrade the code from 1.16.0 to 1.17.x but that could break some users code)

    EDIT: I did, meaning the import signature will change. Will update previous message.

  11. added a commit that references this issue on Aug 20, 2025
  12. omerfe commented on Aug 24, 2025

    @omerfe

    use import { z } from "zod/v3" on your mcp routes/folders and files until they support v4 and just swap the /v3 with /v4 when they bump it

  13. kamsar commented on Aug 28, 2025

    @kamsar

    Lots of useful info here on supporting v3 and v4 at the same time: https://zod.dev/library-authors

  14. zdunecki commented on Sep 25, 2025

    @zdunecki

    What you think about gives zod optional? There's many cases where JSONSchema will bet it better.

    MCP uses that for validation but it's another abstraction layer where it depends mostly on another library. JSONSchema is more stable and being more specification.

    Another case is JSONSchema is more portable, being stuck with zod narrows portability.

  15. added
    ready for workEnough information for someone to start working on
    P0Broken core functionality, security issues, critical missing feature
    on Oct 16, 2025
  16. added this to the zod milestone on Nov 3, 2025
  17. added 2 commits that reference this issue on Nov 11, 2025
    ee91c2f
    a30ef44
  18. felixweinberger commented on Nov 21, 2025

    @felixweinberger
    Contributor

    Hi! we just shipped a beta release adding backwards compatible support for zod v4 - if you'd like to try it we're keen for feedback to make sure this works well!

  19. added
    P2Moderate issues affecting some users, edge cases, potentially valuable feature
    and removed
    P0Broken core functionality, security issues, critical missing feature
    on Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P2Moderate issues affecting some users, edge cases, potentially valuable featureenhancementRequest for a new feature that's not currently supported

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions