{"id":30118402,"url":"https://github.com/tkellogg/fastmcp-deadlock-repro","last_synced_at":"2025-08-10T11:33:45.645Z","repository":{"id":292736754,"uuid":"981767867","full_name":"tkellogg/fastmcp-deadlock-repro","owner":"tkellogg","description":"reproduces a deadlock bug in fastmcp","archived":false,"fork":false,"pushed_at":"2025-05-11T21:09:15.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-11T22:19:46.451Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tkellogg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-11T20:49:44.000Z","updated_at":"2025-05-11T21:09:18.000Z","dependencies_parsed_at":"2025-05-11T22:29:50.084Z","dependency_job_id":null,"html_url":"https://github.com/tkellogg/fastmcp-deadlock-repro","commit_stats":null,"previous_names":["tkellogg/fastmcp-deadlock-repro"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tkellogg/fastmcp-deadlock-repro","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkellogg%2Ffastmcp-deadlock-repro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkellogg%2Ffastmcp-deadlock-repro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkellogg%2Ffastmcp-deadlock-repro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkellogg%2Ffastmcp-deadlock-repro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tkellogg","download_url":"https://codeload.github.com/tkellogg/fastmcp-deadlock-repro/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkellogg%2Ffastmcp-deadlock-repro/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269714827,"owners_count":24463470,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-10T11:31:19.374Z","updated_at":"2025-08-10T11:33:45.640Z","avatar_url":"https://github.com/tkellogg.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deadlock Bug\n\nThis is reproducible in `streamable-http` and `sse` but not `stdio`. That makes me think it's a core\nconcurrency issue in `mcp`.\n\n# Running\nIn all these examples, change the numeric argument on the client. What I've found\n\n* 10 — works easily, fast\n* 100 — works\n* 200 — works in `streamable-http`, deadlock in `sse`\n* 250 - deadlock in `streamable-http`\n* 500 — deadlock\n* 1000 — big deadlock\n\nFor both `streamable-http` and `sse`, the following error occurs frequently, followed by the script hanging:\n\n```\nError in post_writer: All connection attempts failed\n```\n\nIf it fails and I kill the client but not the server and re-run with a much lower number\n(e.g. 250 and then 10), the second small run works fine.\n\nconclusion: maybe the deadlock is in the client and the server is uneffected?\n\n\nThe `--tool-concurrency` flag changes the concurrency to not include connecting, one single connection\nserves all threads and only a tool call is made. In my experiments, this doesn't trigger a deadlock issue.\n\n## Running streamable-http\n\nserver:\n\n```bash\nuv run --script server.py streamable-http\n```\n\nclient:\n\n```bash\nuv run --script client.py 0.0.0.0 8000 streamable-http 1000\n```\n\n## Running sse\n\nserver:\n\n```bash\nuv run --script server.py streamable-http\n```\n\nclient:\n\n```bash\nuv run --script client.py 0.0.0.0 8000 sse 1000\n```\n\n\n## Running stdio\n\n```bash\n# lots of excess noise on stderr\nuv run --script client.py 0.0.0.0 8000 stdio 10 2\u003e/dev/null\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkellogg%2Ffastmcp-deadlock-repro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftkellogg%2Ffastmcp-deadlock-repro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkellogg%2Ffastmcp-deadlock-repro/lists"}