Repository navigation
feat(server-initialize): add server-version-echo and server-version-negotiate checks - #608
Open
seedfunded wants to merge 1 commit into
Open
seedfunded wants to merge 1 commit into
seedfunded wants to merge 1 commit into
Conversation
…egotiate checks Add lifecycle version negotiation checks to the existing `server-initialize` scenario (following AGENTS.md "fewer scenarios, more checks") for stateful initialize revisions (2025-06-18 through 2025-11-25): - `server-version-echo`: sends a raw `initialize` request with `ctx.specVersion` and verifies the server responds with the exact same `protocolVersion` (MUST). - `server-version-negotiate`: sends a raw `initialize` request with unsupported version `1999-01-01` (omitting `MCP-Protocol-Version` header) and verifies the server responds with a different supported `protocolVersion` rather than an HTTP/JSON-RPC error or echoing `1999-01-01` (MUST; WARNING for unrecognized future `YYYY-MM-DD` revisions to avoid false failures on newer spec releases). - Handles both `application/json` and `text/event-stream` responses, cancelling open SSE streams immediately after the first JSON-RPC response and sending `DELETE` to clean up any issued session. - Adds unit tests in `lifecycle.test.ts` and an end-to-end negative fixture (`examples/servers/typescript/version-negotiation-broken.ts`) verified in `negative.test.ts`. Updates modelcontextprotocol#102
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Updates #102 (server-side lifecycle version negotiation for stateful revisions
2025-06-18–2025-11-25, keeping the client-sideMCP-Protocol-Versionheader check for a focused follow-up PR).Following
AGENTS.md("fewer scenarios, more checks"), this extends the existingserver-initializescenario rather than adding a separate scenario:server-version-echo(MUST /FAILURE): sends a rawinitializewithctx.specVersionand verifies the server responds with the exact sameprotocolVersion.server-version-negotiate(MUST /FAILURE,WARNINGfor unrecognized futureYYYY-MM-DDdates): sends a rawinitializewith unsupported version1999-01-01(omittingMCP-Protocol-Versionheader so dual stateful/stateless servers route toinitialize) and verifies the server responds with another supportedprotocolVersioninstead of an HTTP/JSON-RPC error or echoing1999-01-01.application/jsonandtext/event-streamresponses viaEventSourceParserStream, cancelling open SSE streams immediately after the first JSON-RPC response and sendingDELETEto terminate any issued session.Testing
src/scenarios/server/lifecycle.test.ts(12 unit tests covering JSON + SSE cancellation, mismatched version echo, echoed unsupported version, JSON-RPC error, unrecognized future date warning, invalid non-date version, andDELETEcleanup).examples/servers/typescript/version-negotiation-broken.tsand end-to-end negative test insrc/scenarios/server/negative.test.tsprovingserver-version-negotiateemitsFAILURE.npm run check,npm run build, andnpm test(48 test files, 647 tests passing, including liveeverything-server).