Streamable HTTP: no precedence between UnsupportedProtocolVersionError (-32022) and HeaderMismatch (-32020) when an unsupported version arrives without the modern headers

Open
#3,449 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
53/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
documentation

Research direction

Read the Streamable HTTP Protocol Version Header and Server Validation sections, then compare the compatibility matrix in the versioning docs. The issue describes the required precedence rule and says a draft diff is ready for docs/specification/draft/. Update the relevant specification text and matrix, then confirm they consistently cover unsupported versions, missing headers or _meta fields, and header/body mismatches.

Written by the indexing model from the issue text.

Description

What's broken?

The spec is ambiguous or self-contradictory

Where in the spec or docs?

https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/streamable-http#protocol-version-header
(also #server-validation on the same page, and
https://modelcontextprotocol.io/specification/2026-07-28/basic/versioning#compatibility-matrix).
The draft pages have the same text.

What should happen?

The spec should say which error a server returns when a request:

  • has an MCP-Protocol-Version header naming a version the server does not implement, and
  • also fails another Server Validation check, typically a missing Mcp-Method (or Mcp-Name) header.

A 2025-11-25 client produces this request whenever it sends the version header, because
that revision has no Mcp-Method header. It also happens with a future modern revision
whose required headers differ from 2026-07-28's.

Proposed rule: judge the version first. If the MCP-Protocol-Version header names a
version the server does not implement, respond with 400 + UnsupportedProtocolVersionError
before checking the other standard headers (Mcp-Method, Mcp-Name, Mcp-Param-*)
and the request's _meta fields, even when those checks would also fail. The single
exception is a version header that is missing, malformed, or disagrees with the body's
_meta io.modelcontextprotocol/protocolVersion: that stays HeaderMismatch (-32020),
as the existing mismatch rule says.

The _meta part is what decides the legacy-client case: a 2025-11-25 request has no
_meta at all, so a rule that ranked only the headers would still leave -32022 against
"missing _meta fields" open.

Why version-first:

  1. Which headers are required depends on the version. A server that does not
    implement a revision cannot tell whether a request conforms to that revision's
    header rules. "Mcp-Method is missing" only means something under 2026-07-28 rules.
  2. Only -32022 lets the client recover. UnsupportedProtocolVersionError carries
    data.supported, and the client "SHOULD select a mutually supported version from the
    supported list and retry" (versioning.mdx, Protocol Version Negotiation). A
    HeaderMismatch gives no version information, and "correct the request" (the Backward
    Compatibility advice) doesn't help when the real problem is the version.
  3. It matches an existing SHOULD. versioning.mdx asks a modern-only server to "name
    the protocol versions it supports in any error it returns to an initialize request",
    because legacy clients have no other diagnostic. The -32022 data.supported does
    exactly this. A -32020 does not.

The other deterministic choice is header-first (Server Validation before the version),
which is what the compatibility matrix currently implies for Legacy client → Modern
server. It also settles the question, but the client never learns the supported versions.

What actually happens?

Two MUSTs apply to the same request, and the spec doesn't rank them.

basic/transports/streamable-http.mdx (2026-07-28), Protocol Version Header, lines 263–269:

If the server does not implement the requested protocol version (whether the
version is unknown to the server, or is a known version the server has chosen
not to support), it MUST respond with 400 Bad Request and an
[UnsupportedProtocolVersionError] listing its supported versions.

Same file, Standard Request Headers, line 290 (Mcp-Method … "All requests") and line 293:

These headers are REQUIRED for compliance.

Same file, Server Validation, lines 597–599 and 623–625:

When rejecting a request due to header validation failure, servers MUST
return HTTP status 400 Bad Request and MUST include a JSON-RPC error
response using the following error code: [-32020 HeaderMismatch]

Validation failure conditions include:

  • A required standard header (MCP-Protocol-Version, Mcp-Method, Mcp-Name) is missing.

The header/body mismatch rule (lines 257–261) adds a third option, but implementations
agree on it (see below):

The header value MUST match the io.modelcontextprotocol/protocolVersion field
carried in the request body's _meta. If the values do not match, the server MUST
reject the request with 400 Bad Request and a HeaderMismatch JSON-RPC error.

basic/versioning.mdx, Compatibility Matrix, line 170 (Legacy → Modern) leans towards
header-first without saying so:

HTTP: the request is missing the required headers and is rejected per server
validation with 400 Bad Request […]

basic/index.mdx lines 133–135 define -32020 and -32022 but give no order.

Where implementations disagreed. While testing two 2026-07-28 implementations
against each other, the request

POST /mcp
MCP-Protocol-Version: 2025-11-25
Content-Type: application/json

{"jsonrpc":"2.0","id":40,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"old","version":"1"}}}

got -32020 from one (Server Validation first) while the other's test expected -32022.
Both readings are defensible from the text. Both projects have since adopted the
version-first order with the mismatch exception:

  • zig-sdk v0.6.0 (src/mcp/transport/envelope.zig, verify/verifyVersion; tests in
    src/mcp/transport/http_test.zig), ChristianPresley/zig-sdk#44. For this request it
    returns -32022 with data.supported: ["2026-07-28"] and data.requested: "2025-11-25".
    It still returns -32020 for a supported version with no Mcp-Method, and for a
    header that disagrees with _meta.
  • The 2026-07-28 gateway in a VS Code fork, ChristianPresley/vscode#3
    (src/vs/platform/mcp/node/mcpGatewayDispatcher.ts, prepareModernRequest).
    It is dual-era, so it serves initialize as legacy; the precedence applies to requests
    it classifies as modern: header and _meta naming the same unsupported revision →
    -32022 even without Mcp-Method; missing version header, or header ≠ _meta →
    -32020.

Conformance suite. The suite does not test the order of these two checks. We examined @modelcontextprotocol/conformance 0.2.0-alpha.12 and the current main. We also ran the suite (2026-10-21).

  • No check sends a request that has an unsupported version and an incorrect Mcp-Method or Mcp-Name. The standard header builder always adds a correct Mcp-Method.
  • sep-2575-server-unsupported-version-error and sep-2575-http-server-unsupported-version-400 (server-stateless) send v999.0.0 with correct headers. They examine the 400 status and the data fields. They do not examine the -32022 code.
  • ServerRejectsMissingMethodHeader (http-header-validation) sends a supported version. For 2026-07-28, this scenario is not_scored (pending).
  • sep-2575-http-server-header-mismatch-400 (supported header, v999.0.0 in _meta) expects -32020. This agrees with the mismatch exception above.

Test: We wrote two servers that are the same, except for the order of the checks. For the request above, the version-first server sent -32022 and the header-first server sent -32020. We ran server-stateless, http-header-validation, http-custom-header-server-validation and dns-rebinding-protection on each server. All 56 check results were the same. A control server that breaks the mismatch rule failed only sep-2575-http-server-header-mismatch-400. Thus, the suite runs the validation code, but it accepts both orders.

The stateless mock server (for the client scenarios) applies a third order. It sends -32602 for missing _meta keys before it examines the version. For the 2025-11-25 request above, it sent -32602 without data.supported. It does not examine Mcp-Method. The mock server is not normative, but a spec rule will also settle its order.

The zig-sdk v0.6.0 conformance server sent -32022 with data.supported for the request above. It passed server-stateless (30/30) and http-header-validation (14/14).

The VS Code gateway (ChristianPresley/vscode#4, commit 341562b287a) is a dual-era server. It sent -32022 with data.supported for an unsupported version without Mcp-Method, and for an unsupported version with an incorrect Mcp-Method. It served the 2025-11-25 request above with legacy rules. For the header v999.0.0 and a body without _meta, it sent -32022 with the supported versions of both eras. Before this fix, it selected legacy rules for that request and sent the legacy error -32000. It passed server-stateless (30/30) and http-header-validation (14/14).

Anything else?
  • Related, but not the same: #2721 (initialize.params.protocolVersion vs the header
    under 2025-11-25, open), #1943 ("invalid" vs "unsupported" versions, closed).
  • I have a draft diff ready against docs/specification/draft/: one paragraph after the
    Protocol Version Header's unsupported-version rule, a cross-reference after the Server
    Validation list, and a corrected Legacy → Modern HTTP cell in the compatibility matrix.
    I also have conformance checks drafted for modelcontextprotocol/conformance (five request combinations, including the request above). I'll open
    the PRs if maintainers agree with the direction.
  • AI disclosure (per AI_POLICY.md): this report and the proposed text were drafted with
    Claude Code from my own interop testing of the two implementations above. I reviewed
    the spec quotes and the test evidence.
Dominant language
TypeScript
Stars
9.8k
Forks
1.9k
Avg merge
2d 4h
Merged PRs (30d)
73

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from modelcontextprotocol/modelcontextprotocol

All issues in modelcontextprotocol/modelcontextprotocol

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.