Title: Modern Streamable HTTP JSON response mode does not observe client disconnects · Issue #3762 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Modern Streamable HTTP JSON response mode does not observe client disconnects · Issue #3762 · modelcontextprotocol/python-sdk
X Title: Modern Streamable HTTP JSON response mode does not observe client disconnects · Issue #3762 · modelcontextprotocol/python-sdk
Description: Scope clarification This issue now tracks disconnect handling for an in-flight json_response=True request on the modern, per-request Streamable HTTP transport. The original report combined cancellation with notification delivery; those n...
Open Graph Description: Scope clarification This issue now tracks disconnect handling for an in-flight json_response=True request on the modern, per-request Streamable HTTP transport. The original report combined cancella...
X Description: Scope clarification This issue now tracks disconnect handling for an in-flight json_response=True request on the modern, per-request Streamable HTTP transport. The original report combined cancella...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/3762
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Modern Streamable HTTP JSON response mode does not observe client disconnects","articleBody":"### Scope clarification\n\nThis issue now tracks disconnect handling for an in-flight `json_response=True` request on the modern, per-request Streamable HTTP transport. The original report combined cancellation with notification delivery; those need separate decisions.\n\n### Observed behavior\n\nIn the original reproduction with Python SDK 2.3.0 and FastMCP slim 4.1.3, closing the POST while a tool was waiting did not cancel the handler. The same modern request using the SSE response path observed cancellation.\n\nCurrent source in `src/mcp/server/_streamable_http_modern.py` awaits `serve_one(...)` directly in the JSON-response branch. That branch returns before the sibling `watch_disconnect` task used by the SSE path is started.\n\n### Reproduction and desired regression coverage\n\nUse the modern protocol revision `2026-07-28` and a valid `tools/call` request with its required metadata/headers. Configure `json_response=True`. Have an async tool signal that it has started, wait, and record cancellation and cleanup. Close the client POST before the tool completes.\n\nThe modern JSON path should observe the disconnect and cancel the in-flight work with cleanup. Normal completion must still return one `application/json` terminal response. `subscriptions/listen` must keep its dedicated SSE path.\n\nThe [modern Streamable HTTP cancellation rules](https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/streamable-http#cancellation) explicitly describe closing an SSE response stream as cancellation. Applying disconnect handling to the JSON branch is the SDK consistency question here; this report does not claim the specification explicitly spells out JSON-mode cancellation.\n\n### Notification semantics are separate\n\n`test_json_mode_drops_progress` already pins progress as a no-op in JSON mode. The original expectation that offering SSE in `Accept` should override an explicitly configured `json_response=True` is withdrawn. Notification diagnostics/documentation can be discussed separately without blocking a cancellation fix.\n\n### Legacy transport is a separate compatibility question\n\nDo not apply the modern disconnect behavior to legacy transports solely for symmetry: [2025-11-25](https://modelcontextprotocol.io/specification/2025-11-25/basic/transports#sending-messages-to-the-server) says disconnection should not be interpreted as cancellation and describes an explicit cancellation notification instead.\n\nAI disclosure: Codex reviewed current source and protocol text and drafted this scope clarification. No SDK patch or new transport test was run in this follow-up.","author":{"url":"https://github.com/DMomplaisir","@type":"Person","name":"DMomplaisir"},"datePublished":"2026-10-25T22:04:27Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/3762"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:df989925-9c45-bf7d-664b-547add8f907d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C8BC:842EC:126D752:18A2315:6B0123A9 |
| html-safe-nonce | aec63ccd8acdaf3cf0d53a0296b8723c91c068d62228dea824ad4b12be43d0ed |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOEJDOjg0MkVDOjEyNkQ3NTI6MThBMjMxNTo2QjAxMjNBOSIsInZpc2l0b3JfaWQiOiI3MzQwNDA5MDYxMjY5MTE5OTEzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 626f454b1f75fb07bec488d770a92c330ad7c7c26b94b227593db17259672b59 |
| hovercard-subject-tag | issue:6029875530 |
| 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/3762/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b29240900910d42a1c4b28fb1f1ba103de4e51ca0e1b3017ff0c3815550e3628/modelcontextprotocol/python-sdk/issues/3762 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b29240900910d42a1c4b28fb1f1ba103de4e51ca0e1b3017ff0c3815550e3628/modelcontextprotocol/python-sdk/issues/3762 |
| og:image:alt | Scope clarification This issue now tracks disconnect handling for an in-flight json_response=True request on the modern, per-request Streamable HTTP transport. The original report combined cancella... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DMomplaisir |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width