Skip to content

Commit 2a5da9a

Browse files
committed
fix: update protocol negotiation error code from -32004 to -32022 across all transport versions
1 parent 6163898 commit 2a5da9a

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

packages/toolbox-core/src/toolbox_core/mcp_transport/v20250618/mcp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ async def _send_request(
7373
# Check for JSON-RPC Error
7474
if "error" in json_resp:
7575
err_val = json_resp["error"]
76-
if isinstance(err_val, dict) and err_val.get("code") == -32004:
76+
if isinstance(err_val, dict) and err_val.get("code") == -32022:
7777
server_supported = err_val.get("data", {}).get("supported", [])
7878
client_supported = self._supported_protocols
7979
mutually_supported = [

packages/toolbox-core/src/toolbox_core/mcp_transport/v20251125/mcp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ async def _send_request(
7373
# Check for JSON-RPC Error
7474
if "error" in json_resp:
7575
err_val = json_resp["error"]
76-
if isinstance(err_val, dict) and err_val.get("code") == -32004:
76+
if isinstance(err_val, dict) and err_val.get("code") == -32022:
7777
server_supported = err_val.get("data", {}).get("supported", [])
7878
client_supported = self._supported_protocols
7979
mutually_supported = [

packages/toolbox-core/src/toolbox_core/mcp_transport/v20260618/mcp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ async def _send_request(
8383
json_resp = await response.json()
8484
if "error" in json_resp:
8585
err_val = json_resp["error"]
86-
if isinstance(err_val, dict) and err_val.get("code") == -32004:
86+
if isinstance(err_val, dict) and err_val.get("code") == -32022:
8787
server_supported = err_val.get("data", {}).get(
8888
"supported", []
8989
)

packages/toolbox-core/tests/mcp_transport/test_v20260618.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ async def test_version_negotiation_raises_fallback(self, transport):
239239
"jsonrpc": "2.0",
240240
"id": "1",
241241
"error": {
242-
"code": -32004,
242+
"code": -32022,
243243
"message": "Unsupported protocol version",
244244
"data": {"supported": ["DRAFT-2026-v1"]},
245245
},
@@ -266,7 +266,7 @@ def get_result_model(self):
266266
assert transport._session.post.call_count == 1
267267

268268
async def test_version_negotiation_raises_fallback_200_ok(self, transport):
269-
"""Tests that the client raises ProtocolNegotiationError when the server returns 200 OK with -32004."""
269+
"""Tests that the client raises ProtocolNegotiationError when the server returns 200 OK with -32022."""
270270
from toolbox_core.exceptions import ProtocolNegotiationError
271271

272272
mock_response_reject = AsyncMock()
@@ -277,7 +277,7 @@ async def test_version_negotiation_raises_fallback_200_ok(self, transport):
277277
"jsonrpc": "2.0",
278278
"id": "1",
279279
"error": {
280-
"code": -32004,
280+
"code": -32022,
281281
"message": "Unsupported protocol version",
282282
"data": {"supported": ["DRAFT-2026-v1"]},
283283
},
@@ -312,7 +312,7 @@ async def test_version_negotiation_empty_intersection(self, transport):
312312
"jsonrpc": "2.0",
313313
"id": "1",
314314
"error": {
315-
"code": -32004,
315+
"code": -32022,
316316
"message": "Unsupported protocol version",
317317
"data": {"supported": ["UNSUPPORTED-VERSION"]},
318318
},

0 commit comments

Comments
 (0)