Skip to content

Disconnect when the server picks an unsupported protocol version - #316

Open
jaeminbird wants to merge 1 commit into
modelcontextprotocol:mainfrom
jaeminbird:fix/client-reject-unsupported-version
Open

jaeminbird wants to merge 1 commit into
modelcontextprotocol:mainfrom
jaeminbird:fix/client-reject-unsupported-version

Conversation

@jaeminbird

Copy link
Copy Markdown

Motivation and Context

The lifecycle spec says a client that doesn't support the version in the server's initialize response SHOULD disconnect. The client accepts any version and sends notifications/initialized. It now checks Version.supported and, on a mismatch, disconnects and throws, as the TypeScript and Python SDKs do.

How Has This Been Tested?

A new ClientTest has the server answer with 1999-01-01 and asserts that connect throws, notifications/initialized is never sent, and the transport is disconnected; it fails on main and passes with the fix. Full swift test passes on Linux (Swift 6.1).

Breaking Changes

A client talking to a server that answers with an unsupported version now fails to connect instead of continuing.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

The check applies in strict and non-strict mode, since the spec says SHOULD and the reference SDKs always disconnect.

The lifecycle spec says a client that does not support the protocol version in
the server's initialize response should disconnect. The client stored any
version the server returned and finished the handshake with
notifications/initialized.

Check the version against Version.supported, and on a mismatch disconnect and
throw instead of sending notifications/initialized.
@jaeminbird
jaeminbird requested a review from a team as a code owner October 29, 2026 06:24
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.

1 participant