-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
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
Log in client side like below. Server side has no log.
2025-09-15 08:48:20,963 - mcp.client.streamable_http - DEBUG - Connecting to StreamableHTTP endpoint: http://10.1.80.171:18091/mcp
2025-09-15 08:48:21,007 - mcp.client.streamable_http - DEBUG - Sending client message: root=JSONRPCRequest(method='initialize', params={'protocolVersion': '2025-06-18', 'capabilities': {}, 'clientInfo': {'name': 'mcp', 'version': '0.1.0'}}, jsonrpc='2.0', id=0)
2025-09-15 08:48:21,009 - sse_starlette.sse - DEBUG - ping: b': ping - 2025-09-15 08:48:21.009556+00:00\r\n\r\n'
2025-09-15 08:48:21,010 - sse_starlette.sse - DEBUG - ping: b': ping - 2025-09-15 08:48:21.010642+00:00\r\n\r\n'
2025-09-15 08:48:21,013 - httpcore.connection - DEBUG - connect_tcp.started host='10.1.80.171' port=18091 local_address=None timeout=30 socket_options=None
2025-09-15 08:48:21,015 - mcp.server.streamable_http_manager - DEBUG - Session already exists, handling request directly
2025-09-15 08:48:21,020 - httpcore.connection - DEBUG - connect_tcp.failed exception=CancelledError('Cancelled by cancel scope 733e277647e0')
2025-09-15 08:48:21,023 - mcp.server.lowlevel.server - INFO - Request 1 cancelled - duplicate response suppressed
2025-09-15 08:48:21,025 - mcp.server.streamable_http - DEBUG - Closing SSE writer
2025-09-15 08:48:21,027 - sse_starlette.sse - DEBUG - chunk: b'event: message\r\ndata: {"jsonrpc":"2.0","id":1,"error":{"code":0,"message":"Request cancelled"}}\r\n\r\n'
2025-09-15 08:48:21,029 - sse_starlette.sse - DEBUG - Got event: http.disconnect. Stop streaming.
2025-09-15 08:48:36,014 - sse_starlette.sse - DEBUG - ping: b': ping - 2025-09-15 08:48:36.014477+00:00\r\n\r\n'
2025-09-15 08:48:51,019 - sse_starlette.sse - DEBUG - ping: b': ping - 2025-09-15 08:48:51.019656+00:00\r\n\r\n'
2025-09-15 08:49:06,026 - sse_starlette.sse - DEBUG - ping: b': ping - 2025-09-15 08:49:06.026494+00:00\r\n\r\n'
I am calling a MCP server A
from a MCP server B
, and maybe after two or three calling, the next calling will be blocked in session.initialize().
I compared logs and find there is no Session already exists, handling request directly
in correct timing.
Calling codes like:
class MCPClient:
@staticmethod
async def run(url, func, args, elicitation_callback=None):
async with streamablehttp_client(url=url) as (
read_stream,
write_stream,
_,
):
async with ClientSession(
read_stream, write_stream,
elicitation_callback=elicitation_callback
) as session:
try:
await session.initialize()
except Exception as e:
raise
result = None
try:
result = await session.call_tool(
func, args
)
except Exception as e:
raise
return result
Example Code
I am tried but can not give a easy code to reproduce this.
Python & MCP Python SDK
Both `v1.14.0` and `v1.13.1` has this issue.
Python 3.13.2
Metadata
Metadata
Assignees
Labels
No labels