fix: add backward compatibility for MCP servers returning older protocol versions #444
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.
Resolves #436
Related to #438
Add multi-protocol version support to fix MCP server compatibility issues
Motivation and Context
Some MCP server implementations that support the newer "2025-03-26" protocol version incorrectly return "2024-11-05" during initialization instead. This causes compatibility issues where streamable HTTP clients (which support 2025-03-26) cannot connect to these servers because they don't advertise support for the older protocol version.
This change refactors the protocol version handling to support multiple versions simultaneously, allowing streamable HTTP transports to advertise compatibility with both "2024-11-05" and "2025-03-26" protocol versions, ensuring broader server compatibility.
How Has This Been Tested?
Breaking Changes
Yes, this introduces breaking changes to the transport API:
protocolVersion()
method has been replaced withprotocolVersions()
returningList<String>
Types of changes
Checklist
Additional context
ProtocolVersions
interface to centralize protocol version constants and avoid hardcoded stringsMCP_2024_11_05
andMCP_2025_03_26
for maximum compatibilityLifecycleInitializer
to include more detailed exception information