Title: Stateless mode drops HTTP responses for long-running tool calls · Issue #1886 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Stateless mode drops HTTP responses for long-running tool calls · Issue #1886 · modelcontextprotocol/python-sdk
X Title: Stateless mode drops HTTP responses for long-running tool calls · Issue #1886 · modelcontextprotocol/python-sdk
Description: Description When using StreamableHTTPSessionManager with stateless=True and json_response=True, HTTP responses for long-running tool calls (2-5+ minutes) are never sent back to the client. The client receives an empty response immediatel...
Open Graph Description: Description When using StreamableHTTPSessionManager with stateless=True and json_response=True, HTTP responses for long-running tool calls (2-5+ minutes) are never sent back to the client. The clie...
X Description: Description When using StreamableHTTPSessionManager with stateless=True and json_response=True, HTTP responses for long-running tool calls (2-5+ minutes) are never sent back to the client. The clie...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/1886
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Stateless mode drops HTTP responses for long-running tool calls","articleBody":"## Description\n\nWhen using `StreamableHTTPSessionManager` with `stateless=True` and `json_response=True`, HTTP responses for long-running tool calls (2-5+ minutes) are never sent back to the client. The client receives an empty response immediately while the server continues processing.\n\n## Environment\n\n- MCP SDK: 1.25.0\n- Python: 3.13\n- Client: Claude Code 2.1.9 (MCP protocol version `2025-11-25`)\n\n## Reproduction\n\n**Server configuration:**\n```python\nsession_manager = StreamableHTTPSessionManager(\n app=mcp, \n json_response=True, \n stateless=True\n)\n```\n\n**Tool that takes several minutes:**\n```python\n@mcp.call_tool()\nasync def call_tool(name: str, arguments: dict):\n result = await long_running_operation() # 2-5 minutes\n return result\n```\n\n**Steps:**\n1. Connect Claude Code to the MCP server\n2. Call the long-running tool\n3. Client receives empty response immediately\n4. Server logs show tool completed successfully with valid result\n\n## Expected Behavior\n\nHTTP response should be sent after tool completes, containing the result.\n\n## Actual Behavior\n\n- Client receives empty response immediately\n- Server processes tool call successfully\n- Server generates result (logged correctly)\n- **HTTP response is never sent to client**\n\n## Log Evidence\n\n```\n12:01:55.130 - Client POST request received (mcp_protocol: 2025-11-25)\n12:01:56.080 - tool_call event logged\n12:06:50.269 - Tool result generated:\n content_count: 1, content_types: [\"text\"]\n ❌ NO HTTP response logged for client request\n```\n\nKey observation: Only ONE `mcp_request` logged but both `tools/list` and `tools/call` execute. Response routing appears broken for the second request.\n\n## Workaround Attempted\n\nSetting `stateless=False` causes `400 Bad Request: Missing session ID` - incompatible with Claude Code's connection pattern.\n\n## Hypothesis\n\nIn `_handle_stateless_request`, when rapid successive requests arrive from the same client, response routing fails for long-running operations. The response is generated but never correlated back to the correct HTTP connection.","author":{"url":"https://github.com/tony-nekola-silk","@type":"Person","name":"tony-nekola-silk"},"datePublished":"2026-01-16T13:35:16.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1886/python-sdk/issues/1886"}
| 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:3039a1a9-b98e-9101-ee7e-e6dbcbea3646 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BB66:3F8DBE:29221:37953:696E4751 |
| html-safe-nonce | bc9f92c81c2a779950add57e58a703c93bee366f8790ebc4965a3c5ac018f5ca |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjY2OjNGOERCRToyOTIyMTozNzk1Mzo2OTZFNDc1MSIsInZpc2l0b3JfaWQiOiI2MjUzOTYwMzc4OTI5MDA2NDE3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3293a9e5bdd277dee71c8b87b2c0f207a2ee6b506518dc9427a537a68cbe2033 |
| hovercard-subject-tag | issue:3822062750 |
| 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/1886/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1d81335767cc4550602a5803ee151bf4c56ec25d91249cb20e8763eb1ceff28d/modelcontextprotocol/python-sdk/issues/1886 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1d81335767cc4550602a5803ee151bf4c56ec25d91249cb20e8763eb1ceff28d/modelcontextprotocol/python-sdk/issues/1886 |
| og:image:alt | Description When using StreamableHTTPSessionManager with stateless=True and json_response=True, HTTP responses for long-running tool calls (2-5+ minutes) are never sent back to the client. The clie... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tony-nekola-silk |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3d96554e55b469c47dbcd31f74dc86278872b170531e84c6ce7f3389673e01d1 |
| 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 | ef576694863a4c791d0a5cc9d2b84384d4414bcd |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width