Initial Checks
Description
The streamable_http_client transport hangs indefinitely when connecting to MCP servers that only support POST requests (not GET), such as GitHub's MCP server at https://api.githubcopilot.com/mcp/. The issue manifests when calling operations like list_tools() or other methods that return SSE responses. This is also likely what some of the other issues are experiencing as there are many hanging related issues:
https://github.com/modelcontextprotocol/python-sdk/issues?q=is%3Aissue%20state%3Aopen%20hang however, I believe this could explain this issue in more detail potentially: #262
I tried with and without a debugger, and noticed that with a debugger attached, the timing overhead masks the race condition and operations complete successfully. So this has been difficult to unmask.
The MCP SDK's streamable_http_client has a race condition in its GET stream handling:
- After initialization,
streamable_http_client launches a background task (handle_get_stream) to receive server-initiated SSE messages via GET requests
- GitHub's MCP server doesn't support GET requests and returns
405 Method Not Allowed
- The GET stream retries twice according to
MAX_RECONNECTION_ATTEMPTS (with 1-second delays each), then the background task silently exits
- When subsequent POST requests return
text/event-stream content (like tools/list), the transport's SSE response handling may wait for coordination with the GET stream task
- Since the GET stream task is dead, the POST SSE response waits indefinitely
Full repro repo code that honestly isn't large: https://github.com/sicoyle/release-note-agent/blob/main/release_note_agent/release_note_agent.py#L12
Example Code
Full repro repo code that honestly isn't large with 2 cmds to run:
https://github.com/sicoyle/release-note-agent/blob/main/release_note_agent/release_note_agent.py#L12
Python & MCP Python SDK
i forked and tested my changes on an incoming PR to confirm the error and fix. Stay tuned for PR shortly
py 3.13
mcp python sdk at main
Initial Checks
Description
The
streamable_http_clienttransport hangs indefinitely when connecting to MCP servers that only support POST requests (not GET), such as GitHub's MCP server athttps://api.githubcopilot.com/mcp/. The issue manifests when calling operations likelist_tools()or other methods that return SSE responses. This is also likely what some of the other issues are experiencing as there are many hanging related issues:https://github.com/modelcontextprotocol/python-sdk/issues?q=is%3Aissue%20state%3Aopen%20hang however, I believe this could explain this issue in more detail potentially: #262
I tried with and without a debugger, and noticed that with a debugger attached, the timing overhead masks the race condition and operations complete successfully. So this has been difficult to unmask.
The MCP SDK's
streamable_http_clienthas a race condition in its GET stream handling:streamable_http_clientlaunches a background task (handle_get_stream) to receive server-initiated SSE messages via GET requests405 Method Not AllowedMAX_RECONNECTION_ATTEMPTS(with 1-second delays each), then the background task silently exitstext/event-streamcontent (liketools/list), the transport's SSE response handling may wait for coordination with the GET stream taskFull repro repo code that honestly isn't large: https://github.com/sicoyle/release-note-agent/blob/main/release_note_agent/release_note_agent.py#L12
Example Code
Python & MCP Python SDK