Skip to content

fix(server): reject Mcp-Param values the header check cannot verify - #3167

Merged
felixweinberger merged 2 commits into
mainfrom
fix/mcp-param-header-non-primitive-body
Nov 10, 2026
Merged

felixweinberger merged 2 commits into
mainfrom
fix/mcp-param-header-non-primitive-body

Conversation

@mattzcarey

Copy link
Copy Markdown
Member

No description provided.

@mattzcarey
mattzcarey requested a review from a team as a code owner November 9, 2026 17:32
@changeset-bot

changeset-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 45c03c9

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

This PR includes changesets to release 6 packages
Name Type
@modelcontextprotocol/core-internal Patch
@modelcontextprotocol/server Patch
@modelcontextprotocol/client Patch
@modelcontextprotocol/codemod Patch
@modelcontextprotocol/core Patch
@modelcontextprotocol/server-legacy 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 Nov 9, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/codemod

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

@modelcontextprotocol/core

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

@modelcontextprotocol/server

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

@modelcontextprotocol/server-legacy

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

@modelcontextprotocol/express

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

@modelcontextprotocol/fastify

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: 45c03c9

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

An object or array body value for an x-mcp-header argument is now
rejected whether or not its header is present. Leaving the no-header
case to params validation was not safe: a coercing schema such as
z.coerce.string() turns ["eu"] into "eu", so the tool ran with a value
no header carried.

An integer outside the safe range has no header form. A present header
cannot be compared with it, so it is rejected; an absent header is
still accepted, because the SDK's own client omits the header for such
values.
@mattzcarey mattzcarey changed the title fix(server): reject an Mcp-Param header whose body value is an object or array fix(server): reject Mcp-Param values the header check cannot verify Nov 9, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

1 other optional suggestion (a nit or a note on pre-existing code) was found and not posted.

'@modelcontextprotocol/server': patch
---

Reject a `tools/call` with `400` / `-32020` (`HeaderMismatch`) when a body argument declared with `x-mcp-header` is an object or array, with or without its `Mcp-Param-*` header, and when the argument is an integer outside the safe range but the header is present. Previously the header check was skipped for these values, so the call reached the tool.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 nit (optional): Release-note readers are told these calls used to reach the tool, but for most tools they were answered 200 with a tool input-validation error. The last sentence of the changeset at line 6 holds only when the tool's validator accepts the value, such as z.coerce.string() given an array. Fix: state what callers see change in both cases: a call that got 200 with an isError input-validation result, or that ran the tool under a coercing schema, now gets 400 / -32020.

Why this was flagged

No runtime trigger; nothing fails at runtime, the reader of the published changelog is the one affected. .changeset/mcp-param-header-non-primitive-body.md:6 ends "Previously the header check was skipped for these values, so the call reached the tool." On the base branch an object or array for a declared argument skipped the header check, then validateToolInput at packages/server/src/server/mcp.ts:370-375 threw "Input validation error: Invalid arguments for tool ...", and the catch at packages/server/src/server/mcp.ts:320 returned it as an isError result with HTTP 200. executeToolHandler at packages/server/src/server/mcp.ts:307 never ran. The tool ran only when the schema's own validator accepted the value, for example a coercing schema, or a JSON Schema integer for a value outside the safe range. The instruction guards against release notes that understate a visible change: here a 200 tool error becomes a 400 protocol error for every tool, not only coercing ones.

Verification: The changeset's last sentence (.changeset/mcp-param-header-non-primitive-body.md:6) reads: "Previously the header check was skipped for these values, so the call reached the tool." So the caller-visible change for the common case is 200 with an isError input-validation result becoming 400 / -32020; the tool handler never ran.

Finding ID: f-a963bbc4

@claude claude Bot added the v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes label Nov 10, 2026
@felixweinberger
felixweinberger merged commit 919bb8e into main Nov 10, 2026
21 checks passed
@felixweinberger
felixweinberger deleted the fix/mcp-param-header-non-primitive-body branch November 10, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants