Skip to content

Route Streamable HTTP era from the request envelope, not only the header - #3868

Closed
andrevegas wants to merge 2 commits into
modelcontextprotocol:mainfrom
andrevegas:fix/streamable-http-body-era-routing
Closed

andrevegas wants to merge 2 commits into
modelcontextprotocol:mainfrom
andrevegas:fix/streamable-http-body-era-routing

Conversation

@andrevegas

Copy link
Copy Markdown

Fixes #3863

StreamableHTTPSessionManager chooses the protocol era from the MCP-Protocol-Version header alone. A request that carries the 2026-07-28 _meta envelope with a 2025-era or missing header is therefore served by the legacy path (HTTP 200) instead of being rejected with 400 / -32020 (HeaderMismatch), as the 2026-07-28 transport requires.

This follows the approach sketched in the issue: the manager reads the POST body (already buffered and size-limited by RequestBodyLimitMiddleware) and sends requests that carry the envelope to the modern entry, whose classifier already returns HeaderMismatch. The body is replayed unchanged. The era check moves to mcp.shared.inbound.has_modern_envelope, shared with the stdio runner.

Unparseable bodies, notifications and batches stay on the legacy path. initialize is routed like any other request, since a handshake never carries the reserved version key.

Tests cover the mismatch for tools/list, server/discover and initialize (stateless and stateful; 2025-era and missing header), plus controls for valid 2025 and 2026 requests and a plain legacy initialize. The routing description under docs/run/ is updated.

AI disclosure: written with Claude Code. I reproduced the issue and reviewed the change; the full test suite (100% coverage), pyright and ruff pass locally.

andrevegas and others added 2 commits November 17, 2026 16:49
StreamableHTTPSessionManager chose the protocol era from the
MCP-Protocol-Version header alone, so a request carrying the 2026-07-28
`_meta` envelope with a 2025-era or missing header was served by the legacy
path: tools/list answered 200 with a 2025-shaped result and modern-only
methods such as server/discover answered 200 with -32601. The 2026-07-28
transport requires 400 with HeaderMismatch (-32020) when the header does not
match the envelope.

Peek at the POST body (already buffered and size-limited by
RequestBodyLimitMiddleware) and send requests that carry the envelope to the
modern entry, whose classifier already produces HeaderMismatch. The body is
replayed untouched. Unparseable bodies, notifications, batches and
`initialize` stay on the legacy path, as in the stdio runner.

Share the era predicate as mcp.shared.inbound.has_modern_envelope so stdio and
HTTP use one definition.

Refs modelcontextprotocol#3863

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ing docs

An `initialize` carrying the reserved 2026-07-28 version key with a 2025-era
or missing header was still served by the legacy handshake, so the same body
got a successful handshake or a modern rejection depending only on the
header. A handshake never carries the reserved key, so route it like any
other enveloped request and let the modern entry answer HeaderMismatch.
Ordinary legacy `initialize` requests are unchanged and covered by tests.

Document that routing now also considers the 2026-07-28 envelope.

Refs modelcontextprotocol#3863

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md) label Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR has been closed automatically. This repo only keeps pull requests open when they come from a maintainer, or from a contributor a maintainer has assigned to the linked issue, and you aren't currently assigned to #3863.

If a maintainer assigns you to #3863, this PR reopens on its own and there's nothing more you need to do here. Assignment is a maintainer call based on capacity; comments that only ask to be assigned don't factor in. What does help is engaging on the issue itself by confirming the repro, explaining why it matters for your use case, or describing the approach you'd take.

You're welcome to keep pushing commits here (just avoid force-pushing, since GitHub can't reopen a rewritten branch), but that on its own won't get the PR reviewed or the issue assigned, and realistically most auto-closed PRs stay closed. There's no need to open a new PR either way.

CONTRIBUTING.md has the full reasoning, but in short:

  • We're a small team with very little capacity to review community PRs right now.
  • Many recent PRs are AI-generated with little human review, and reviewing one carefully still costs a maintainer as much time as it ever did. A well-described issue is usually more useful to us than the code.

Maintainers: reopen, remove missing-issue-link, or add bypass-issue-check to override.

@github-actions github-actions Bot closed this Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streamable HTTP serves a 2026-07-28 request as legacy when the MCP-Protocol-Version header is 2025-era or missing

1 participant