You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Client tool call hangs forever if server crashes or connection dies when using streamable-http #1577
If the server dies during a tool call before it sends a response the client will get stuck forever.
Example Code
# server.pyfrommcp.server.fastmcpimportFastMCPimportsysmcp=FastMCP("StatefulServer")
@mcp.tool()defgreet(name: str="World") ->str:
"""Greet someone by name."""sys.exit(0)
returnf"Hello, {name}!"if__name__=="__main__":
mcp.run(transport="streamable-http")
# client.pyimportasynciofrommcpimportClientSessionfrommcp.client.streamable_httpimportstreamablehttp_clientasyncdefmain():
# Connect to a streamable HTTP serverasyncwithstreamablehttp_client("http://localhost:8000/mcp") as (
read_stream,
write_stream,
_,
):
# Create a session using the client streamsasyncwithClientSession(read_stream, write_stream) assession:
# Initialize the connectionawaitsession.initialize()
res=awaitsession.call_tool("greet", {"name": "World"})
print(res)
if__name__=="__main__":
asyncio.run(main())
# Run server.py then client.py# client.py will hang forever in the tool call and never complete. I would expect it to throw an error since the connection died and it will never get a response.
"I encountered the same issue: exceptions at the underlying connection layer are not being broadcast to every waiting caller. Currently, the only workaround is to set a timeout for call tool operations to actively give up."
Activity
gyang-xai commentedon Nov 5, 2025
I have a possible PR that fixes this here: #1578 for reference but not sure if this is the best solution.
Implement SEP-1577: Sampling With Tools
owenliang commentedon Feb 18, 2026
"I encountered the same issue: exceptions at the underlying connection layer are not being broadcast to every waiting caller. Currently, the only workaround is to set a timeout for call tool operations to actively give up."
astro-angelfish commentedon Jul 2, 2026
Reproduced on my side, just made my framework hangs forever. Maybe a keep-alive mechanism is required for streamable-http.