Update MCP protocol validation and defaults - #17
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| except Exception: # pragma: no cover - optional dependency | ||
| _MCP_TYPES_AVAILABLE = False | ||
| _PROTOCOL_VERSION = "2025-06-18" | ||
| _PROTOCOL_VERSION = "2025-11-25" |
There was a problem hiding this comment.
Respect negotiated MCP version for 2025-06-18 clients
When the MCP SDK is missing, _PROTOCOL_VERSION now defaults to 2025-11-25, yet the HTTP transport still accepts 2025-06-18 (see _validate_protocol_version). An older client that sends initialize with protocolVersion/header 2025-06-18 will now get an initialize response advertising 2025-11-25 because _handle_initialize always returns _PROTOCOL_VERSION, so strict clients will reject the handshake as a version mismatch despite being explicitly allowed. The server should either echo the client’s requested version when supported or fail negotiation instead of unilaterally upgrading.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Summary
- Added a shared
SUPPORTED_PROTOCOL_VERSIONSconstant to capture the preferred and compatible MCP protocol versions for negotiation. rmcp/core/server.pyL35-L50 - Introduced protocol negotiation in
initializehandling so responses echo a supported client version instead of always upgrading to the latest default. rmcp/core/server.pyL461-L532
Testing
- ✅
python -m compileall rmcp/transport/http.py rmcp/core/server.py tests/integration/protocol/test_mcp_protocol_compliance.py
Summary
Testing
Codex Task