Skip to content

streamable_http client hangs indefinitely when connecting to POST-only MCP servers (ex: GitHub MCP) #1941

@sicoyle

Description

@sicoyle

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:

  1. After initialization, streamable_http_client launches a background task (handle_get_stream) to receive server-initiated SSE messages via GET requests
  2. GitHub's MCP server doesn't support GET requests and returns 405 Method Not Allowed
  3. The GET stream retries twice according to MAX_RECONNECTION_ATTEMPTS (with 1-second delays each), then the background task silently exits
  4. 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
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions