Skip to content

MCPClient hangs when connecting to GitHub MCP server with streamable_http transport #399

Description

@sicoyle

Dapr Agents MCPClient.connect_streamable_http() hangs indefinitely when connecting to GitHub's MCP server (https://api.githubcopilot.com/mcp/) and calling list_tools() or other operations that return SSE responses.

The issue only occurs outside of debuggers - when running with a debugger attached, the timing overhead prevents the race condition and it works correctly.

Root Cause:
GitHub's MCP server only supports POST requests, not GET. The MCP SDK's streamablehttp_client transport has bug:

  1. Background GET stream starts: streamablehttp_client launches a background task for server-initiated SSE messages via GET
  2. GitHub returns 405: GitHub doesn't support GET, returns "405 Method Not Allowed"
  3. The GET stream retries twice (1 second each), then the background task exits
  4. When subsequent POST requests return text/event-stream content (like tools/list), the transport's SSE response handling expects the GET stream task to be alive for coordination
  5. Since the GET stream task is dead, the POST SSE response waits forever

You can repro consistently with https://github.com/sicoyle/release-note-agent

Relevant logs:

INFO:httpx:HTTP Request: POST https://api.githubcopilot.com/mcp/ "HTTP/1.1 202 Accepted"
INFO:httpx:HTTP Request: GET https://api.githubcopilot.com/mcp/ "HTTP/1.1 405 Method Not Allowed"
INFO:mcp.client.streamable_http:GET stream disconnected, reconnecting in 1000ms...
INFO:httpx:HTTP Request: POST https://api.githubcopilot.com/mcp/ "HTTP/1.1 200 OK"
DEBUG:mcp.client.streamable_http:Sending client message: root=JSONRPCRequest(method='tools/list'...)
# Hangs here

There are currently many hanging related issues on the MCP python sdk repo:
https://github.com/modelcontextprotocol/python-sdk/issues?q=is%3Aissue%20state%3Aopen%20hang

So, Dapr Agent users will likely also experience issues relating to the MCP Client and streamable_http transport, any POST_only MCP server, and Github's MCP server.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

Status
Just Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions