Skip to content

[Tiering] Add conformance tests for Version Negotiation #102

Open

Description

@pcarleton

Summary

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.

Spec References

Activity

  1. added a commit that references this issue on Apr 13, 2026
    0822cdd
  2. alexdoroshevich commented on Apr 13, 2026

    @alexdoroshevich

    Working on this — PR #224 is open.

    Implements all three checks from the issue:

    • 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).

  3. added 3 commits that reference this issue on Apr 13, 2026
    2e571ae
    c75c3c4
    f9f9ce6
  4. happy520ai commented on Sep 27, 2026

    @happy520ai
  5. happy520ai commented on Sep 28, 2026

    @happy520ai
  6. sangaraju1988 commented on Oct 18, 2026

    @sangaraju1988

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions