Fix Zod 4 tool input schemas - #2647
Conversation
Restore closed object schemas for MCP tool inputs without changing the generic Standard Schema conversion used by elicitation.
🦋 Changeset detectedLatest commit: b0d6415 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@modelcontextprotocol/core
@modelcontextprotocol/server
@modelcontextprotocol/server-legacy
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
|
The serving snapshots and guide harness expectations are now aligned with the server-side Zod 4 closure option. All required GitHub checks are green on �0d6415, and the PR is ready for review. The generic Standard Schema conversion remains unchanged; closure is opted into only for MCP tool input declarations. |
|
Follow-up verification on
The current GitHub checks are green. I tried to mark the draft ready for review, but GitHub rejected both the CLI and REST request because |
Summary
Zod 4 does not include
additionalProperties: falsewhen the SDK converts a defaultz.object(...)input shape. That leaves the schema advertised bytools/listdifferent from the closed object schema produced by the Zod 3 path.This keeps the generic Standard Schema conversion unchanged for elicitation and other callers, and opts into closed Zod object input schemas only when the server builds MCP tool declarations. The regression coverage checks the wire-level
tools/listresult as well as the converter behavior.Fixes #2636
Verification
./node_modules/.bin/vitest runinpackages/core-internal(1,438 passed)./node_modules/.bin/vitest runinpackages/server(469 passed)tsgo -p tsconfig.json --noEmitin both packagesgit diff --checkChangeset included for
@modelcontextprotocol/core-internal.AI assistance was used while preparing this patch. The implementation and regression tests were checked against the existing core and server test suites.