Description
Initial Checks
- I confirm that I'm using the latest version of MCP Python SDK
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
Description
We observed the issue that, when an initialize message is sent to a server using python SDK, it always returns a message id of integer type, even though the initial request had the type of this id be of string type. this is an example request/response pair for the integration with MS Copilot Studio.
Request:
{
"id": "1",
"jsonrpc": "2.0",
"method": "initialize",
"params": {
"capabilities": {},
"clientInfo": {
"agentName": "Test agent python",
"appId": "d1296152-0c7a-4e79-8112-c1c87d5287e8",
"channelId": "pva-studio",
"name": "mcs",
"version": "1.0.0"
},
"protocolVersion": "2024-11-05",
"sessionContext": {}
}
}
Response:
id: 5e70c917-c5d7-416e-9daa-23bf521b7b82
event: message
data: {"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05","capabilities":{"experimental":{},"tools":{"listChanged":false}},"serverInfo":{"name":"
mcp-streamable-http-demo","version":"1.9.5.dev14+d0443a1"}}}
The flow then stops from microsoft side, likely because of a missing connection associated with this request id.
From the spec: https://modelcontextprotocol.io/specification/2025-06-18/basic#responses
Responses MUST include the same ID as the request they correspond to.
You could argue it's not explicitly mentioning the type here, but it seems to cause an issue even in the MCP inspector. If i hack the server to to return a id with a string type, even though the initialize call from the inspector is of integer type, i see the following message in the inspector logs:
Error from inspector client: Error: No connection established for request ID: 0
Example Code
Python & MCP Python SDK
1.9.4