Initial Checks
Description
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.Python & MCP Python SDK
Initial Checks
Description
If the server dies during a tool call before it sends a response the client will get stuck forever.
Example Code
Python & MCP Python SDK