Fastmcp Deadlock Repro
reproduces a deadlock bug in fastmcp
Ask AI about Fastmcp Deadlock Repro
Powered by Claude Β· Grounded in docs
I know everything about Fastmcp Deadlock Repro. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
Deadlock Bug
This is reproducible in streamable-http and sse but not stdio. That makes me think it's a core
concurrency issue in mcp.
Running
In all these examples, change the numeric argument on the client. What I've found
- 10 β works easily, fast
- 100 β works
- 200 β works in
streamable-http, deadlock insse - 250 - deadlock in
streamable-http - 500 β deadlock
- 1000 β big deadlock
For both streamable-http and sse, the following error occurs frequently, followed by the script hanging:
Error in post_writer: All connection attempts failed
If it fails and I kill the client but not the server and re-run with a much lower number (e.g. 250 and then 10), the second small run works fine.
conclusion: maybe the deadlock is in the client and the server is uneffected?
The --tool-concurrency flag changes the concurrency to not include connecting, one single connection
serves all threads and only a tool call is made. In my experiments, this doesn't trigger a deadlock issue.
Running streamable-http
server:
uv run --script server.py streamable-http
client:
uv run --script client.py 0.0.0.0 8000 streamable-http 1000
Running sse
server:
uv run --script server.py streamable-http
client:
uv run --script client.py 0.0.0.0 8000 sse 1000
Running stdio
# lots of excess noise on stderr
uv run --script client.py 0.0.0.0 8000 stdio 10 2>/dev/null
