Skip to content

Fix Zod 4 tool input schemas - #2647

Draft
uuzzrm wants to merge 2 commits into
modelcontextprotocol:mainfrom
uuzzrm:codex/zod4-input-schema-additional-properties
Draft

Fix Zod 4 tool input schemas#2647
uuzzrm wants to merge 2 commits into
modelcontextprotocol:mainfrom
uuzzrm:codex/zod4-input-schema-additional-properties

Conversation

@uuzzrm

@uuzzrm uuzzrm commented Aug 11, 2026

Copy link
Copy Markdown

Summary

Zod 4 does not include additionalProperties: false when the SDK converts a default z.object(...) input shape. That leaves the schema advertised by tools/list different 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/list result as well as the converter behavior.

Fixes #2636

Verification

  • ./node_modules/.bin/vitest run in packages/core-internal (1,438 passed)
  • ./node_modules/.bin/vitest run in packages/server (469 passed)
  • tsgo -p tsconfig.json --noEmit in both packages
  • ESLint passed for both changed source packages
  • git diff --check

Changeset 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.

Restore closed object schemas for MCP tool inputs without changing the generic Standard Schema conversion used by elicitation.
@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b0d6415

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/core-internal Patch

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

@pkg-pr-new

pkg-pr-new Bot commented Aug 11, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@2647

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@2647

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@2647

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@2647

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@2647

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@2647

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@2647

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@2647

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@2647

commit: b0d6415

@uuzzrm

uuzzrm commented Aug 11, 2026

Copy link
Copy Markdown
Author

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.

@uuzzrm

uuzzrm commented Aug 11, 2026

Copy link
Copy Markdown
Author

Follow-up verification on b0d6415:

  • packages/core-internal: standardSchema.test.ts — 9 passed
  • packages/server: mcp.compat.test.ts — 9 passed
  • git diff --check: passed
  • worktree: clean

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 uuzzrm does not have permission to change the draft state. Could a maintainer mark it ready and review the current head when convenient?

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 v4: "additionalProperties: false" missing

1 participant