Skip to content

feat: conformance scenario for MCP-Protocol-Version header 400 - #241

Closed
pja-ant wants to merge 1 commit into
mainfrom
protocol-version-header-400-conformance
Closed

pja-ant wants to merge 1 commit into
mainfrom
protocol-version-header-400-conformance

Conversation

@pja-ant

@pja-ant pja-ant commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds ServerProtocolVersionHeaderScenario testing the spec MUST that servers respond 400 Bad Request to an invalid or unsupported MCP-Protocol-Version header (basic/transports#protocol-version-header).
  • Three header values exercised: a malformed string, and well-formed-but-unsupported dates both before (2000-01-01) and after (2099-01-01) any real version — the past/future pair catches servers doing single-bound string comparison instead of an allowlist.
  • Each value is tested pre-init (no session) and post-init (after a full handshake with valid Mcp-Session-Id), so header validation is isolated from session-ID validation on stateful servers. Six checks total.

Test plan

  • npm run typecheck
  • npm run lint
  • npx vitest run src/scenarios/server/protocol-version-header.test.ts — 7 unit tests
  • Smoke-tested against examples/servers/typescript — 6/6 SUCCESS, post-init bodies confirm "Unsupported protocol version: <value>"

…sponse

Tests the spec MUST (basic/transports#protocol-version-header) that servers
respond with HTTP 400 to requests carrying an invalid or unsupported
MCP-Protocol-Version header.

The scenario sends tools/list with three bad header values:
- malformed: "invalid-protocol-version"
- unsupported past date: "2000-01-01"
- unsupported future date: "2099-01-01"

Each is tested both before initialize (no session) and after a full
initialize handshake (with valid Mcp-Session-Id), so header validation is
isolated from session-ID validation on stateful servers. Six checks total.
@pkg-pr-new

pkg-pr-new Bot commented Apr 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

npx https://pkg.pr.new/@modelcontextprotocol/conformance@241

commit: 878c03e

@LucaButBoring

Copy link
Copy Markdown

npm run typecheck fails after rebasing this:

> @modelcontextprotocol/[email protected] typecheck
> tsgo --noEmit

src/scenarios/index.ts:164:3 - error TS2741: Property 'source' is missing in type 'ServerProtocolVersionHeaderScenario' but required in type 'ClientScenario'.

164   new ServerProtocolVersionHeaderScenario(),
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  src/types.ts:148:3 - 'source' is declared here.
    148   source: ScenarioSource;
          ~~~~~~

src/scenarios/server/protocol-version-header.ts:67:9 - error TS2416: Property 'run' in type 'ServerProtocolVersionHeaderScenario' is not assignable to the same property in base type 'ClientScenario'.
  Type '(serverUrl: string) => Promise<ConformanceCheck[]>' is not assignable to type '(ctx: RunContext) => Promise<ConformanceCheck[]>'.
    Types of parameters 'serverUrl' and 'ctx' are incompatible.
      Type 'RunContext' is not assignable to type 'string'.

67   async run(serverUrl: string): Promise<ConformanceCheck[]> {
           ~~~


Found 2 errors in 2 files.

Errors  Files
     1  src/scenarios/index.ts:164
     1  src/scenarios/server/protocol-version-header.ts:67

@pcarleton

Copy link
Copy Markdown
Member

Backlog sweep: this needs a port to the current scenario API (source/RunContext, per the review comment above) and a negative fixture case before it can merge. If that's something you have time for, please re-open. Thanks for the contribution either way.

@pcarleton pcarleton closed this Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants