Skip to content

Commit b3d81bc

Browse files
authored
Update MCP protocol validation and defaults (#17)
1 parent 4a7285b commit b3d81bc

3 files changed

Lines changed: 26 additions & 10 deletions

File tree

rmcp/core/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
_SUPPORTED_LOG_LEVELS = ["debug", "info", "warning", "error"]
3434
except Exception: # pragma: no cover - optional dependency
3535
_MCP_TYPES_AVAILABLE = False
36-
_PROTOCOL_VERSION = "2025-06-18"
36+
_PROTOCOL_VERSION = "2025-11-25"
3737
_SUPPORTED_LOG_LEVELS = [
3838
"debug",
3939
"info",

rmcp/transport/http.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ def __init__(
150150
## Protocol
151151
152152
This server implements the Model Context Protocol (MCP) specification for statistical analysis tools.
153-
All requests after initialization must include the `MCP-Protocol-Version: 2025-06-18` header.
153+
All requests after initialization must include the `MCP-Protocol-Version` header. Use `2025-11-25`
154+
for the latest spec (preferred); `2025-06-18` remains supported for compatibility.
154155
""".strip(),
155156
contact={
156157
"name": "RMCP Project",
@@ -218,16 +219,29 @@ def _validate_origin(self, request: Request) -> None:
218219
def _validate_protocol_version(self, request: Request, method: str) -> None:
219220
"""Validate MCP-Protocol-Version header according to MCP specification."""
220221
protocol_version = request.headers.get("mcp-protocol-version")
221-
supported_versions = ("2025-06-18",)
222+
supported_versions = ("2025-11-25", "2025-06-18")
223+
preferred_version = supported_versions[0]
222224

223225
if method == "initialize":
224226
# Initialize requests don't require the header (it's set after negotiation)
225-
if protocol_version and protocol_version not in supported_versions:
227+
if not protocol_version:
228+
# Default to the latest version when the client doesn't specify one
229+
request.state.protocol_version = preferred_version
230+
return
231+
if protocol_version not in supported_versions:
226232
raise HTTPException(
227233
400,
228234
f"Unsupported protocol version: {protocol_version}. "
229235
f"Supported versions: {', '.join(supported_versions)}",
230236
)
237+
if protocol_version != preferred_version:
238+
logger.info(
239+
"Client requested older MCP protocol version %s; "
240+
"preferring %s for responses",
241+
protocol_version,
242+
preferred_version,
243+
)
244+
request.state.protocol_version = protocol_version
231245
else:
232246
# All non-initialize requests MUST include the MCP-Protocol-Version header
233247
if not protocol_version:
@@ -281,7 +295,8 @@ def _setup_routes(self) -> None:
281295
282296
**Required Headers:**
283297
- `Content-Type: application/json`
284-
- `MCP-Protocol-Version: 2025-06-18` (after initialization)
298+
- `MCP-Protocol-Version: 2025-11-25` (preferred after initialization; `2025-06-18`
299+
remains supported)
285300
286301
**Session Management:**
287302
Sessions must be initialized before other operations.
@@ -501,8 +516,8 @@ async def landing_page() -> Response:
501516
<pre style="background: #f4f4f4; padding: 15px; border-radius: 4px; overflow-x: auto;">
502517
curl -X POST https://rmcp-server-394229601724.us-central1.run.app/mcp \\
503518
-H "Content-Type: application/json" \\
504-
-H "MCP-Protocol-Version: 2025-06-18" \\
505-
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"test-client","version":"1.0"}}}'</pre>
519+
-H "MCP-Protocol-Version: 2025-11-25" \\
520+
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"test-client","version":"1.0"}}}'</pre>
506521
507522
<div class="footer">
508523
<p>RMCP v0.5.1 | MIT License | <a href="https://github.com/finite-sample/rmcp">GitHub</a></p>

tests/integration/protocol/test_mcp_protocol_compliance.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""
22
MCP Protocol Compliance Tests
33
4-
Tests that RMCP correctly implements the Model Context Protocol 2025-06-18 specification
5-
that Claude Desktop, Cursor, VS Code, and other MCP clients expect.
4+
Tests that RMCP correctly implements the Model Context Protocol 2025-11-25 specification
5+
while maintaining compatibility with the 2025-06-18 clients that Claude Desktop, Cursor,
6+
VS Code, and other MCP clients expect.
67
78
These tests simulate the exact JSON-RPC message sequences that IDEs send.
89
"""
@@ -411,7 +412,7 @@ async def test_complete_mcp_conversation():
411412
def test_mcp_protocol_version_compatibility():
412413
"""Test that RMCP declares compatibility with the correct MCP version."""
413414
# This test doesn't need async since it's just checking constants
414-
expected_version = "2025-06-18"
415+
expected_version = "2025-11-25"
415416

416417
# Check that our server reports the correct protocol version
417418
# This would be checked during initialization in real usage

0 commit comments

Comments
 (0)