You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Tiering] Add conformance tests for Version Negotiation #102
The MCP lifecycle spec requires specific version negotiation behavior during initialization, but the conformance test suite only tests basic initialization without verifying version negotiation. Additionally, HTTP clients must include the MCP-Protocol-Version header on subsequent requests.
Missing Coverage
Check: version-echo
Spec: "If the server supports the requested protocol version, it MUST respond with the same version."
Server receives initialize with a supported version → server responds with the same version.
Check: version-negotiate
Spec: "Otherwise, the server MUST respond with another protocol version it supports."
Server receives initialize with an unsupported version → server responds with a different supported version (not an error).
Check: http-protocol-version-header
Spec: "If using HTTP, the client MUST include the MCP-Protocol-Version: HTTP header on all subsequent requests to the MCP server."
After initialization, client includes MCP-Protocol-Version header on all HTTP requests.
Spec Requirements
Keyword
Statement
MUST
The client MUST send a protocol version it supports
SHOULD
This SHOULD be the latest version supported by the client
MUST
If the server supports the requested protocol version, it MUST respond with the same version
MUST
Otherwise, the server MUST respond with another protocol version it supports
SHOULD
This SHOULD be the latest version supported by the server
SHOULD
If the client does not support the version in the server's response, it SHOULD disconnect
MUST
If using HTTP, the client MUST include the MCP-Protocol-Version header on all subsequent requests
Current State
lifecycle.ts only tests that initialization succeeds - no version mismatch scenarios.
version-echo — sends 2025-11-25, verifies the server echoes the same version back.
version-negotiate — sends 1999-01-01, verifies the server responds with a supported version rather than a JSON-RPC error. Reports WARNING (not FAILURE) if the server returns a valid-format version the harness doesn't recognise, to avoid false failures on servers running a newer spec release.
http-protocol-version-header — sends a subsequent ping carrying the negotiated MCP-Protocol-Version header, verifies the server returns 2xx.
One non-obvious implementation detail: the StreamableHTTPServerTransport responds with text/event-stream for all POST requests (including initialize and ping) and keeps the connection open, so the checks use a streaming reader that extracts the first JSON-RPC event and cancels via reader.cancel() in a finally block rather than buffering the full response.
All 106 tests pass including the new scenario (13 unit tests for the version negotiation scenario alone).
I'd like to pick this up, since #224 was closed in the backlog sweep. Proposed scope for a first PR, following AGENTS.md ("fewer scenarios, more checks"):
Add two checks to the existing server-initialize scenario (initialize/session wire, 2025-06-18 to 2025-11-25):
server-version-echo: a raw initialize with the run's --spec-version must come back with the same protocolVersion (MUST, so FAILURE).
server-version-negotiate: a raw initialize with 1999-01-01 must come back with a different, supported protocolVersion, not a JSON-RPC error and not the same string echoed (MUST, so FAILURE).
Raw fetch rather than the SDK client, because the SDK rejects an unknown response version, which is what the check needs to see. Any session opened by a probe is terminated with DELETE.
Negative fixture examples/servers/typescript/version-negotiation-broken.ts (echoes any requested version), with a case in negative.test.ts.
The 2026-07-28 wire is already covered by server-stateless (UnsupportedProtocolVersionError), so this is scoped to the stateful wire only.
I'd leave the client-side MCP-Protocol-Version header check for the 2025 wire to a follow-up PR, to keep this one small.
One question: server-initialize is scored in requirements/2025-11-25.yaml, so new MUST checks could turn some SDKs' runs red. Do you want them added at WARNING first, or behind an expected-failures round?
I have this working locally. The everything-server passes 5/5 on --spec-version 2025-06-18 and 2025-11-25, and npm test passes (648 tests). Happy to adjust the scope before opening the PR.
Activity
feat: add version negotiation conformance tests (closes modelcontextp…
alexdoroshevich commentedon Apr 13, 2026
Working on this — PR #224 is open.
Implements all three checks from the issue:
version-echo— sends2025-11-25, verifies the server echoes the same version back.version-negotiate— sends1999-01-01, verifies the server responds with a supported version rather than a JSON-RPC error. Reports WARNING (not FAILURE) if the server returns a valid-format version the harness doesn't recognise, to avoid false failures on servers running a newer spec release.http-protocol-version-header— sends a subsequent ping carrying the negotiatedMCP-Protocol-Versionheader, verifies the server returns 2xx.One non-obvious implementation detail: the
StreamableHTTPServerTransportresponds withtext/event-streamfor all POST requests (includinginitializeandping) and keeps the connection open, so the checks use a streaming reader that extracts the first JSON-RPC event and cancels viareader.cancel()in afinallyblock rather than buffering the full response.All 106 tests pass including the new scenario (13 unit tests for the version negotiation scenario alone).
feat: add version negotiation conformance tests (closes modelcontextp…
feat: add version negotiation conformance tests (closes modelcontextp…
feat: add version negotiation conformance scenario (closes modelconte…
happy520ai commentedon Sep 27, 2026
happy520ai commentedon Sep 28, 2026
sangaraju1988 commentedon Oct 18, 2026
I'd like to pick this up, since #224 was closed in the backlog sweep. Proposed scope for a first PR, following AGENTS.md ("fewer scenarios, more checks"):
server-initializescenario (initialize/session wire, 2025-06-18 to 2025-11-25):server-version-echo: a rawinitializewith the run's--spec-versionmust come back with the sameprotocolVersion(MUST, so FAILURE).server-version-negotiate: a rawinitializewith1999-01-01must come back with a different, supportedprotocolVersion, not a JSON-RPC error and not the same string echoed (MUST, so FAILURE).fetchrather than the SDK client, because the SDK rejects an unknown response version, which is what the check needs to see. Any session opened by a probe is terminated with DELETE.examples/servers/typescript/version-negotiation-broken.ts(echoes any requested version), with a case innegative.test.ts.server-stateless(UnsupportedProtocolVersionError), so this is scoped to the stateful wire only.I'd leave the client-side
MCP-Protocol-Versionheader check for the 2025 wire to a follow-up PR, to keep this one small.One question:
server-initializeis scored inrequirements/2025-11-25.yaml, so new MUST checks could turn some SDKs' runs red. Do you want them added at WARNING first, or behind an expected-failures round?I have this working locally. The everything-server passes 5/5 on
--spec-version 2025-06-18and2025-11-25, andnpm testpasses (648 tests). Happy to adjust the scope before opening the PR.