Title: Client hangs forever · Issue #1789 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Client hangs forever · Issue #1789 · modelcontextprotocol/python-sdk
X Title: Client hangs forever · Issue #1789 · modelcontextprotocol/python-sdk
Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue Description Client hangs forever w...
Open Graph Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this ...
X Description: Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening t...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/1789
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Client hangs forever","articleBody":"### Initial Checks\n\n- [x] I confirm that I'm using the latest version of MCP Python SDK\n- [x] I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue\n\n### Description\n\nClient hangs forever when `sse_read_timeout` is specified unless `read_timeout_seconds` in `session.call_tool` is also populated.\n\n### Example Code\n\n```Python\nimport threading\nimport time\nimport asyncio\nfrom typing import Literal\nfrom datetime import timedelta\n\nfrom mcp import ClientSession\nfrom mcp.client.streamable_http import streamablehttp_client\nfrom mcp.types import ImageContent as MCPImageContent\n\n\ndef start_comprehensive_mcp_server(transport: Literal[\"sse\", \"streamable-http\"], port=int):\n from mcp.server import FastMCP\n\n mcp = FastMCP(\"Comprehensive MCP Server\", port=port)\n\n @mcp.tool(description=\"Tool that will timeout\")\n def timeout_tool() -\u003e str:\n time.sleep(10)\n return \"This tool has timed out\"\n\n @mcp.tool(description=\"Calculator tool which performs calculations\")\n def calculator(x: int, y: int) -\u003e int:\n return x + y\n\n mcp.run(transport=transport)\n\n\n# Start server\nserver_thread = threading.Thread(\n target=start_comprehensive_mcp_server, \n kwargs={\"transport\": \"streamable-http\", \"port\": 8001}, \n daemon=True\n)\nserver_thread.start()\ntime.sleep(3)\nprint(\"SERVER STARTED\", flush=True)\n\n\nasync def test_raw_mcp():\n print(\"CREATING RAW MCP CONNECTION...\", flush=True)\n \n async with streamablehttp_client(\n url=\"http://127.0.0.1:8001/mcp\",\n sse_read_timeout=2, # 2 second timeout\n ) as (read_stream, write_stream, get_session_id):\n print(\"TRANSPORT CONNECTED\", flush=True)\n \n async with ClientSession(read_stream, write_stream) as session:\n print(\"SESSION CREATED\", flush=True)\n \n await session.initialize()\n print(\"SESSION INITIALIZED\", flush=True)\n \n print(\"CALLING TOOL (with 2s timeout)...\", flush=True)\n try:\n result = await session.call_tool(\n \"timeout_tool\", \n arguments={},\n # read_timeout_seconds=timedelta(seconds=5), # This needs to be provided or the client will hang forever\n )\n print(f\"TOOL RESULT: {result}\", flush=True)\n except Exception as e:\n print(f\"TOOL CALL EXCEPTION: {type(e).__name__}: {e}\", flush=True)\n \n print(\"DONE\", flush=True)\n\n\nprint(\"RUNNING TEST...\", flush=True)\nasyncio.run(test_raw_mcp())\nprint(\"TEST COMPLETE\", flush=True)\n```\n\n### Python \u0026 MCP Python SDK\n\n```Text\n1.24.0\n```","author":{"url":"https://github.com/afarntrog","@type":"Person","name":"afarntrog"},"datePublished":"2025-12-15T20:29:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/1789/python-sdk/issues/1789"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:84c72463-73e5-d1f6-7174-0e3151803548 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 98A6:116E4B:44A6D44:59C4C01:6A5D42F9 |
| html-safe-nonce | 5f72a609b2ffeda255ca9564c142ba4320f0033ad37c9814dc70f6d2b07215cc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OEE2OjExNkU0Qjo0NEE2RDQ0OjU5QzRDMDE6NkE1RDQyRjkiLCJ2aXNpdG9yX2lkIjoiODgwNjYxMjg4NDk1OTA4NTMwNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c34d3e7fe4f27967605e0469ccb071c10eb0ad5707290a725d25b20ca2e05ce0 |
| hovercard-subject-tag | issue:3732002166 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/1789/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c010530c96d5358366b2373cc6790d9843119fbea313ec1261aacdffdde831f9/modelcontextprotocol/python-sdk/issues/1789 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c010530c96d5358366b2373cc6790d9843119fbea313ec1261aacdffdde831f9/modelcontextprotocol/python-sdk/issues/1789 |
| og:image:alt | Initial Checks I confirm that I'm using the latest version of MCP Python SDK I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | afarntrog |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width