Skip to content

fix: validate wrapped Zod output schemas#2106

Open
pragnyanramtha wants to merge 2 commits into
modelcontextprotocol:v1.xfrom
pragnyanramtha:pragnyan/fix-output-schema-zod-wrapper
Open

fix: validate wrapped Zod output schemas#2106
pragnyanramtha wants to merge 2 commits into
modelcontextprotocol:v1.xfrom
pragnyanramtha:pragnyan/fix-output-schema-zod-wrapper

Conversation

@pragnyanramtha
Copy link
Copy Markdown

@pragnyanramtha pragnyanramtha commented May 16, 2026

Summary

  • validate tool structuredContent against the registered output schema directly instead of first normalizing it to a plain object schema
  • add regression coverage for optional, nullable, nullish, and union Zod output schemas across the repo Zod v3/v4 test matrix
  • add a patch changeset for @modelcontextprotocol/sdk

Fixes #1308.

Related prior work: this revives the behavior covered by closed, unmerged #1931, with the current fix scoped to preserving the registered schema wrapper and with Zod v3/v4 regression coverage.

Validation

  • npx vitest run test/server/mcp.test.ts -t "wrapped and union"
  • npx vitest run test/server/mcp.test.ts
  • npm run typecheck
  • npm run lint
  • npm run build
  • npx prettier --check .changeset/validate-wrapped-output-schemas.md
  • git diff --check

Note: I also started npm test; it passed the changed server suite and several unrelated suites, then stopped producing output for more than 10 minutes in this environment, so I stopped that run and relied on the targeted/full server suite plus typecheck/lint/build.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 16, 2026

🦋 Changeset detected

Latest commit: b0e8d74

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

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
Copy link
Copy Markdown

pkg-pr-new Bot commented May 16, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@modelcontextprotocol/sdk@2106

commit: b0e8d74

@pragnyanramtha pragnyanramtha marked this pull request as ready for review May 16, 2026 07:55
@pragnyanramtha pragnyanramtha requested a review from a team as a code owner May 16, 2026 07:55
Copilot AI review requested due to automatic review settings May 16, 2026 07:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

2 participants