Skip to content

Commit 2e571ae

Browse files
author
Alexander Doroshevich
committed
feat: add version negotiation conformance tests (closes #102)
Implements the three checks from issue #102: - version-echo (MUST): server echoes the requested protocolVersion when the client sends a version the server supports. - version-negotiate (MUST): server responds with a supported version, not a JSON-RPC error, when the client sends an unsupported version. - http-protocol-version-header (MUST): server accepts subsequent HTTP requests that carry the MCP-Protocol-Version header. Uses raw fetch() instead of connectToServer() because the TypeScript SDK hard-codes the protocol version and provides no public API to override it. The MCP StreamableHTTP transport responds with text/event-stream for all POST requests and keeps the connection open. To avoid blocking on response.text(), responses are read with a streaming reader that cancels via reader.cancel() in a finally block after extracting the first JSON-RPC message. All sessions opened during testing are cleaned up with DELETE /mcp. Scenario is registered in allClientScenariosList under lifecycle scenarios. npm test passes (88/88).
1 parent 050d9cf commit 2e571ae

File tree

2 files changed

+623
-0
lines changed

2 files changed

+623
-0
lines changed

src/scenarios/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { SSERetryScenario } from './client/sse-retry';
1111

1212
// Import all new server test scenarios
1313
import { ServerInitializeScenario } from './server/lifecycle';
14+
import { ServerVersionNegotiationScenario } from './server/version-negotiation';
1415

1516
import {
1617
PingScenario,
@@ -83,6 +84,7 @@ const pendingClientScenariosList: ClientScenario[] = [
8384
const allClientScenariosList: ClientScenario[] = [
8485
// Lifecycle scenarios
8586
new ServerInitializeScenario(),
87+
new ServerVersionNegotiationScenario(),
8688

8789
// Utilities scenarios
8890
new LoggingSetLevelScenario(),

0 commit comments

Comments
 (0)