fix: use negotiated protocol version in sse-multiple-streams raw POSTs (#415)

The stateful server-sse-multiple-streams scenario hard-coded
mcp-protocol-version: 2025-03-26 on its three raw concurrent POSTs
instead of the version negotiated during initialize. A server that
enforces the negotiated session version correctly returns 400 to all
three POSTs, so the scenario false-failed before exercising the
multi-stream behavior under test.

Read transport.protocolVersion after client.connect() and use it for
the raw POST headers, falling back to the run's spec version if the
transport does not expose one. Add a regression test driving the
scenario against a fixture server that 400s any request whose
MCP-Protocol-Version header does not match what it negotiated.

Fixes #412


Claude-Session: https://claude.ai/code/session_0178cz8nAyFRHQyq9cg2XgZz

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
claude[bot] 2026-07-27 11:59:17 +01:00 • committed by GitHub
commit 19a97f0465
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -37,6 +37,7 @@ export class ServerSSEMultipleStreamsScenario implements ClientScenario {
const stateless = specVersion === DRAFT_PROTOCOL_VERSION;
let sessionId: string | undefined;
let negotiatedProtocolVersion: string | undefined;
let client: Client | undefined;
let transport: StreamableHTTPClientTransport | undefined;
@ -59,8 +60,9 @@ export class ServerSSEMultipleStreamsScenario implements ClientScenario {
transport = new StreamableHTTPClientTransport(new URL(serverUrl));
await client.connect(transport);
// Extract session ID from transport
// Extract session ID and negotiated protocol version from transport
sessionId = (transport as unknown as { sessionId?: string }).sessionId;
negotiatedProtocolVersion = transport.protocolVersion;
if (!sessionId) {
checks.push({
@ -96,7 +98,7 @@ export class ServerSSEMultipleStreamsScenario implements ClientScenario {
'Content-Type': 'application/json',
Accept: 'text/event-stream, application/json',
'mcp-session-id': sessionId!,
'mcp-protocol-version': '2025-03-26'
'mcp-protocol-version': negotiatedProtocolVersion ?? specVersion
};
const requestParams = stateless
? {