Skip to content

Conversation

@jackkoppa
Copy link

@jackkoppa jackkoppa commented Nov 11, 2025

Note

@jackkoppa - Closing out this PR. The primarily AI-generated changes did not result in a working version of /sdk that I could use in our Zod4 codebase, and I won't have time to pursue this further for at least the next few weeks. Please feel free, obviously, to reference this in another PR attempting to add Zod4 support.


Warning

@jackkoppa - This is only a first attempt, and before this is possibly opened for review, would love to see what CI errors are raised. Heavily AI-assisted first pass (via Amp). Please don't spend any time reviewing yet! Thanks!


  • Move zod to peerDependencies supporting ^3.23.8 || ^4.0.0
  • Create zodJsonSchema wrapper with auto-detection
  • Use native z.toJSONSchema() for Zod 4
  • Fall back to zod-to-json-schema for Zod 3
  • Add ZOD_4_MIGRATION.md documentation
  • Non-breaking change, fully backward compatible

Closes #555

Motivation and Context

How Has This Been Tested?

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 11, 2025

Open in StackBlitz

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/sdk@1102

commit: 0b2ef19

- Move zod to peerDependencies supporting ^3.23.8 || ^4.0.0
- Create zodJsonSchema wrapper with auto-detection
- Use native z.toJSONSchema() for Zod 4
- Fall back to zod-to-json-schema for Zod 3
- Add ZOD_4_MIGRATION.md documentation
- Non-breaking change, fully backward compatible

Closes modelcontextprotocol#555

Amp-Thread-ID: https://ampcode.com/threads/T-6db05869-7946-4144-922f-b7adac392de5
Co-authored-by: Amp <amp@ampcode.com>
@jackkoppa jackkoppa force-pushed the feat/zod-4-support branch 2 times, most recently from 2440086 to c34efde Compare November 11, 2025 22:14
The RegisteredTool type now preserves the original ZodRawShape instead of
converting it to ZodType<object>. This allows users to access shape properties
directly, which is important for introspection and testing.

The conversion to ZodType<object> is now done only when needed:
- During JSON schema generation (for API responses)
- During validation (for parsing input/output)

This is a non-breaking fix that maintains backward compatibility.
@jackkoppa
Copy link
Author

Closing out this PR. The primarily AI-generated changes did not result in a working version of /sdk that I could use in our Zod4 codebase, and I won't have time to pursue this further for at least the next few weeks. Please feel free, obviously, to reference this in another PR attempting to add Zod4 support.

@jackkoppa jackkoppa closed this Nov 12, 2025
@ryansuhartanto ryansuhartanto mentioned this pull request Nov 14, 2025
9 tasks
@ryansuhartanto
Copy link

@jackkoppa would this PR be helpful? #1113

Zod 4 schema won't be supported still, but at least users can use the latest Zod version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zod 4 supported

2 participants