-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
When using the Streamable HTTP client, an ignored GeneratorExit error is raised repeatedly from the httpcore library.
For some reason, this error is only raised on Linux but not on Windows.
Here is the log trace for a ping request on Linux:
[07/29/25 13:38:34] DEBUG Sending client message: streamable_http.py:385
root=JSONRPCRequest(method='
ping', params=None,
jsonrpc='2.0', id=16)
DEBUG connect_tcp.started _trace.py:87
host='mcp.tavily.com' port=443
local_address=None timeout=30
socket_options=None
DEBUG connect_tcp.complete _trace.py:87
return_value=<httpcore._backends.anyio
.AnyIOStream object at 0x7f9d28658d40>
DEBUG start_tls.started _trace.py:87
ssl_context=<ssl.SSLContext object at
0x7f9d30bec150>
server_hostname='mcp.tavily.com'
timeout=30
DEBUG start_tls.complete _trace.py:87
return_value=<httpcore._backends.anyio
.AnyIOStream object at 0x7f9d29f78a70>
DEBUG send_request_headers.started _trace.py:87
request=<Request [b'POST']>
DEBUG send_request_headers.complete _trace.py:87
DEBUG send_request_body.started _trace.py:87
request=<Request [b'POST']>
DEBUG send_request_body.complete _trace.py:87
DEBUG receive_response_headers.started _trace.py:87
request=<Request [b'POST']>
DEBUG receive_response_headers.complete _trace.py:87
return_value=(b'HTTP/1.1', 200, b'OK',
[(b'Date', b'Tue, 29 Jul 2025 13:38:34
GMT'), (b'Content-Type',
b'text/event-stream'),
(b'Transfer-Encoding', b'chunked'),
(b'Connection', b'keep-alive'),
(b'server', b'uvicorn'),
(b'cache-control', b'no-cache,
no-transform'), (b'x-accel-buffering',
b'no')])
DEBUG receive_response_body.started _trace.py:87
request=<Request [b'POST']>
DEBUG SSE message: streamable_http.py:163
root=JSONRPCResponse(jsonrpc
='2.0', id=16, result={})
DEBUG receive_response_body.failed _trace.py:87
exception=GeneratorExit()
DEBUG response_closed.started _trace.py:87
Exception ignored in: <async_generator object HTTP11ConnectionByteStream.__aiter__ at 0x7f9d296eeb40>
Traceback (most recent call last):
File "/home/application_user/chat_application/.venv/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 404, in __aiter__
yield part
RuntimeError: async generator ignored GeneratorExit
And here is the log trace for a ping request on Windows:
DEBUG Sending client message: root=JSONRPCRequest(method='ping', params=None, jsonrpc='2.0', id=8) streamable_http.py:385
DEBUG connect_tcp.started host='mcp.tavily.com' port=443 local_address=None timeout=30 socket_options=None _trace.py:87
DEBUG connect_tcp.complete return_value=<httpcore._backends.anyio.AnyIOStream object at 0x000002371D9BC530> _trace.py:87
DEBUG start_tls.started ssl_context=<ssl.SSLContext object at 0x0000023713477A50> server_hostname='mcp.tavily.com' timeout=30 _trace.py:87
DEBUG start_tls.complete return_value=<httpcore._backends.anyio.AnyIOStream object at 0x000002371D6687A0> _trace.py:87
DEBUG send_request_headers.started request=<Request [b'POST']> _trace.py:87
DEBUG send_request_headers.complete _trace.py:87
DEBUG send_request_body.started request=<Request [b'POST']> _trace.py:87
DEBUG send_request_body.complete _trace.py:87
DEBUG receive_response_headers.started request=<Request [b'POST']> _trace.py:87
DEBUG rust notify timeout, continuing main.py:265
DEBUG receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Date', b'Tue, 29 Jul 2025 13:50:07 GMT'), (b'Content-Type', b'text/event-stream'), (b'Transfer-Encoding', b'chunked'), _trace.py:87
(b'Connection', b'keep-alive'), (b'server', b'uvicorn'), (b'cache-control', b'no-cache, no-transform'), (b'x-accel-buffering', b'no')])
DEBUG receive_response_body.started request=<Request [b'POST']> _trace.py:87
DEBUG SSE message: root=JSONRPCResponse(jsonrpc='2.0', id=8, result={}) streamable_http.py:163
DEBUG response_closed.started _trace.py:87
DEBUG response_closed.complete _trace.py:87
DEBUG receive_response_body.failed exception=GeneratorExit()
As you can see, the exception exists on Windows but is only raised on Linux.
Note:
- This issue is found to happen with the initialization, list_tools, call_tool, and send_ping requests, and has not been tested with the other requests.
- The Linux distro used is the one on the official python:3.12 image.
- The Windows used is Windows 10.
Example Code
Python & MCP Python SDK
Python: 3.12
MCP Python SDK: 1.12.2
Metadata
Metadata
Assignees
Labels
No labels