Skip to content

Commit 4032710

Browse files
committed
fix: align JSON-RPC error response with TypeScript SDK
Use error code -32001 (server error) and null id to match the TypeScript SDK's session not found response format. Github-Issue: #1727
1 parent 7199c1f commit 4032710

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/mcp/server/streamable_http_manager.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,15 @@ async def run_server(
289289
await http_transport.handle_request(scope, receive, send)
290290
else: # pragma: no cover
291291
# Unknown or expired session ID - return 404 per MCP spec
292-
# Use JSON-RPC error format for consistency with transport errors
292+
# Match TypeScript SDK exactly: jsonrpc, error, id order
293293
error_body = json.dumps(
294294
{
295295
"jsonrpc": "2.0",
296-
"id": "server-error",
297-
"error": {"code": -32600, "message": "Session not found"},
296+
"error": {
297+
"code": -32001,
298+
"message": "Session not found",
299+
},
300+
"id": None,
298301
}
299302
)
300303
response = Response(

0 commit comments

Comments
 (0)