Skip to content

Commit 623a8df

Browse files
cliffhallclaude
andcommitted
Call out the unknown-method error code change from SDK v2
SDK v1 answered every unknown method with -32602 "Invalid request parameters" (its request union failed to parse); SDK v2 answers -32601 "Method not found", the code JSON-RPC defines. The era tests' comments claimed v1 parity, and the server headers and serve() comments claimed an unchanged wire. Correct them to say what holds (tool results are unchanged) and record the error code as a behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
1 parent 019d40c commit 623a8df

6 files changed

Lines changed: 33 additions & 18 deletions

File tree

‎src/fetch/src/mcp_server_fetch/server.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#
77
# Built on the MCP Python SDK v2's low-level `Server` (#4851). That SDK no
88
# longer validates tool arguments or folds tool exceptions into `isError`
9-
# results, so `call_tool` does both with SDK v1's messages, and `serve()` runs
10-
# the legacy (2025-11-25) handshake loop only, keeping the wire as it was on v1.
11-
# Serving 2026-07-28 is #4853.
9+
# results, so `call_tool` does both with SDK v1's messages, keeping tool
10+
# results as they were on v1. `serve()` runs the legacy (2025-11-25) handshake
11+
# loop only; serving 2026-07-28 is #4853.
1212

1313
import asyncio
1414
import ipaddress
@@ -488,7 +488,7 @@ async def call_tool(
488488
) -> CallToolResult:
489489
# SDK v2's low-level server neither validates arguments nor turns a
490490
# handler exception into an isError result, both of which SDK v1 did.
491-
# Both are done here, with v1's messages, so the wire is unchanged.
491+
# Both are done here, with v1's messages, so tool results are unchanged.
492492
arguments = params.arguments or {}
493493
if params.name == tool.name:
494494
try:
@@ -552,7 +552,7 @@ async def get_prompt(
552552
# Legacy era only. Server.run() would also serve 2026-07-28 (its
553553
# dual-era loop answers server/discover and per-request envelopes);
554554
# adopting that era is #4853, so this port (#4851) serves the
555-
# handshake loop alone and keeps the wire unchanged.
555+
# handshake loop alone, the only era it served on SDK v1.
556556
async with server.lifespan(server) as lifespan_state:
557557
await serve_loop(
558558
server,

‎src/fetch/tests/test_protocol.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,12 @@ async def test_modern_era_is_not_served() -> None:
10161016
# #4851: the SDK v2 port serves the 2025-11-25 handshake era only.
10171017
# Server.run() would also open a 2026-07-28 connection for a request that
10181018
# carries the per-request `_meta` envelope; adopting that era is #4853.
1019-
# Until then such a request is refused as it was on SDK v1.
1019+
# Until then such a request is refused as an unknown method.
1020+
#
1021+
# Behavior change in the SDK v2 port: SDK v1 answered every unknown
1022+
# method with -32602 "Invalid request parameters" (its request union
1023+
# failed to parse); SDK v2 answers -32601 "Method not found", the code
1024+
# JSON-RPC defines for it.
10201025
discover = JSONRPCRequest(
10211026
jsonrpc="2.0",
10221027
id=1,

‎src/git/src/mcp_server_git/server.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#
66
# Built on the MCP Python SDK v2's low-level `Server` (#4851). That SDK no
77
# longer validates tool arguments or folds tool exceptions into `isError`
8-
# results, so `call_tool` does both with SDK v1's messages, and `serve()` runs
9-
# the legacy (2025-11-25) handshake loop only, keeping the wire as it was on v1.
10-
# Serving 2026-07-28 is #4853.
8+
# results, so `call_tool` does both with SDK v1's messages, keeping tool
9+
# results as they were on v1. `serve()` runs the legacy (2025-11-25) handshake
10+
# loop only; serving 2026-07-28 is #4853.
1111

1212
import logging
1313
from importlib.metadata import version
@@ -751,7 +751,7 @@ async def call_tool(
751751
) -> CallToolResult:
752752
# SDK v2's low-level server neither validates arguments nor turns a
753753
# handler exception into an isError result, both of which SDK v1 did.
754-
# Both are done here, with v1's messages, so the wire is unchanged.
754+
# Both are done here, with v1's messages, so tool results are unchanged.
755755
arguments = params.arguments or {}
756756
schema = schemas.get(params.name)
757757
if schema is not None:
@@ -775,7 +775,7 @@ async def call_tool(
775775
# Legacy era only. Server.run() would also serve 2026-07-28 (its
776776
# dual-era loop answers server/discover and per-request envelopes);
777777
# adopting that era is #4853, so this port (#4851) serves the
778-
# handshake loop alone and keeps the wire unchanged.
778+
# handshake loop alone, the only era it served on SDK v1.
779779
async with server.lifespan(server) as lifespan_state:
780780
await serve_loop(
781781
server,

‎src/git/tests/test_protocol.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,12 @@ async def test_modern_era_is_not_served() -> None:
11651165
# #4851: the SDK v2 port serves the 2025-11-25 handshake era only.
11661166
# Server.run() would also open a 2026-07-28 connection for a request that
11671167
# carries the per-request `_meta` envelope; adopting that era is #4853.
1168-
# Until then such a request is refused as it was on SDK v1.
1168+
# Until then such a request is refused as an unknown method.
1169+
#
1170+
# Behavior change in the SDK v2 port: SDK v1 answered every unknown
1171+
# method with -32602 "Invalid request parameters" (its request union
1172+
# failed to parse); SDK v2 answers -32601 "Method not found", the code
1173+
# JSON-RPC defines for it.
11691174
discover = JSONRPCRequest(
11701175
jsonrpc="2.0",
11711176
id=1,

‎src/time/src/mcp_server_time/server.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#
55
# Built on the MCP Python SDK v2's low-level `Server` (#4851). That SDK no
66
# longer validates tool arguments or folds tool exceptions into `isError`
7-
# results, so `call_tool` does both with SDK v1's messages, and `serve()` runs
8-
# the legacy (2025-11-25) handshake loop only, keeping the wire as it was on v1.
9-
# Serving 2026-07-28 is #4853.
7+
# results, so `call_tool` does both with SDK v1's messages, keeping tool
8+
# results as they were on v1. `serve()` runs the legacy (2025-11-25) handshake
9+
# loop only; serving 2026-07-28 is #4853.
1010

1111
from datetime import datetime, timedelta
1212
from importlib.metadata import version
@@ -282,7 +282,7 @@ async def call_tool(
282282
) -> CallToolResult:
283283
# SDK v2's low-level server neither validates arguments nor turns a
284284
# handler exception into an isError result, both of which SDK v1 did.
285-
# Both are done here, with v1's messages, so the wire is unchanged.
285+
# Both are done here, with v1's messages, so tool results are unchanged.
286286
arguments = params.arguments or {}
287287
schema = schemas.get(params.name)
288288
if schema is not None:
@@ -306,7 +306,7 @@ async def call_tool(
306306
# Legacy era only. Server.run() would also serve 2026-07-28 (its
307307
# dual-era loop answers server/discover and per-request envelopes);
308308
# adopting that era is #4853, so this port (#4851) serves the
309-
# handshake loop alone and keeps the wire unchanged.
309+
# handshake loop alone, the only era it served on SDK v1.
310310
async with server.lifespan(server) as lifespan_state:
311311
await serve_loop(
312312
server,

‎src/time/tests/test_protocol.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,12 @@ async def test_modern_era_is_not_served() -> None:
933933
# #4851: the SDK v2 port serves the 2025-11-25 handshake era only.
934934
# Server.run() would also open a 2026-07-28 connection for a request that
935935
# carries the per-request `_meta` envelope; adopting that era is #4853.
936-
# Until then such a request is refused as it was on SDK v1.
936+
# Until then such a request is refused as an unknown method.
937+
#
938+
# Behavior change in the SDK v2 port: SDK v1 answered every unknown
939+
# method with -32602 "Invalid request parameters" (its request union
940+
# failed to parse); SDK v2 answers -32601 "Method not found", the code
941+
# JSON-RPC defines for it.
937942
discover = JSONRPCRequest(
938943
jsonrpc="2.0",
939944
id=1,

0 commit comments

Comments
 (0)