Title: streamable HTTP client: the standalone GET stream advertises Accept: application/json but can only read text/event-stream, then gives up silently · Issue #3503 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: streamable HTTP client: the standalone GET stream advertises Accept: application/json but can only read text/event-stream, then gives up silently · Issue #3503 · modelcontextprotocol/python-sdk
X Title: streamable HTTP client: the standalone GET stream advertises Accept: application/json but can only read text/event-stream, then gives up silently · Issue #3503 · modelcontextprotocol/python-sdk
Description: AI disclosure: I used Claude Code to read the transport, capture the headers and build the reproduction. I hit the problem myself, ran the repro, and stand behind the report. Initial Checks 2.2.0 (latest 2.x). The two files involved are ...
Open Graph Description: AI disclosure: I used Claude Code to read the transport, capture the headers and build the reproduction. I hit the problem myself, ran the repro, and stand behind the report. Initial Checks 2.2.0 (...
X Description: AI disclosure: I used Claude Code to read the transport, capture the headers and build the reproduction. I hit the problem myself, ran the repro, and stand behind the report. Initial Checks 2.2.0 (...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/3503
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"streamable HTTP client: the standalone GET stream advertises Accept: application/json but can only read text/event-stream, then gives up silently","articleBody":"_AI disclosure: I used Claude Code to read the transport, capture the headers and build the reproduction. I hit the problem myself, ran the repro, and stand behind the report._\n\n### Initial Checks\n\n- `2.2.0` (latest 2.x). The two files involved are byte-identical at `upstream/main` (`9972c21a`); `v1.x` has the same shape.\n- Searched first. Nearby reports cover the server side of the GET (#3102, #2474, PR #3129), Accept quality factors (#3154), and the reconnect loop (#3257, #3356, #2393). None covers the `Accept` the client sends.\n\n### Release line\n\n2.x (current stable)\n\n### Description\n\n`StreamableHTTPTransport._prepare_headers` is written for the POST — `accept: application/json, text/event-stream` plus `content-type: application/json` — but all five outbound requests use it:\n\n| Call site | Request | |\n| --- | --- | --- |\n| `_handle_post_request` | POST with a body | ok |\n| `handle_get_stream` | standalone SSE GET | `Accept` overridden, `Content-Type` with no body |\n| `_handle_resumption_request` | resumption SSE GET | same |\n| `_handle_reconnection` | reconnect SSE GET | same |\n| `terminate_session` | DELETE, no body | `Content-Type` with no body |\n\n`sse_within_origin` sets `_SSE_HEADERS = {\"Accept\": \"text/event-stream\", ...}` and then does `merged.update(headers or {})`, so the caller's `Accept` wins. Those GET responses are read only through `httpx2.EventSource`, which raises `SSEError` for anything but `text/event-stream`: the client offers a representation it will then refuse. On the wire:\n\n```\nGET /mcp\n accept: application/json, text/event-stream\n content-type: application/json\n```\n\nThe DELETE carries the same `content-type` with no body.\n\n**What it costs.** Answer that GET with `application/json` and the offer is honoured back at the client:\n\n```\nhttpx2.SSEError: Expected response with content type 'text/event-stream', got 'application/json'.\nDEBUG mcp.client.streamable_http GET stream max reconnection attempts (2) exceeded\n```\n\n`handle_get_stream` swallows it in its broad `except Exception` and returns. Client-to-server requests keep working — the repro still prints its `tools/call` result — so the session looks healthy while notifications, sampling, elicitation and roots are gone for its lifetime, with only a DEBUG line.\n\n**Expected.** The SSE GETs advertise only `text/event-stream`, and the bodyless GET and DELETE carry no `Content-Type`.\n\n**Scope.** Under the 2025-11-25 spec the client is within its rights (it \"**MUST** include an `Accept` header, listing `text/event-stream` as a supported content type\"; listing more is not forbidden) and the server is not (it \"**MUST** either return `Content-Type: text/event-stream` [...] or else return HTTP 405 Method Not Allowed\"). A compliant server never hits this, and the repro's server is deliberately non-compliant. What still looks wrong is offering what the client cannot read, and losing the channel silently when a server takes the offer up; the stray `Content-Type` is wrong regardless. `mcp/client/sse.py` is unaffected — it passes no headers.\n\nThe repro uses `mode=\"legacy\"` because `notifications/initialized` is sent only from `ClientSession.initialize()`; the modern path adopts a `DiscoverResult`, so `start_get_stream` never fires there.\n\n### Example Code\n\n```python\n# server.py — the official server, answering the GET with the content type the client accepts.\nimport uvicorn\nfrom mcp.server.mcpserver import MCPServer\n\nserver = MCPServer(name=\"probe\", version=\"0.1.0\")\n\n\n@server.tool()\ndef echo(text: str) -> str:\n return text\n\n\nclass TakeTheClientAtItsWord:\n def __init__(self, app):\n self.app = app\n\n async def __call__(self, scope, receive, send):\n if scope[\"type\"] == \"http\" and scope[\"method\"] == \"GET\":\n body = b'{\"jsonrpc\":\"2.0\"}'\n await send({\n \"type\": \"http.response.start\",\n \"status\": 200,\n \"headers\": [(b\"content-type\", b\"application/json\"), (b\"content-length\", str(len(body)).encode())],\n })\n await send({\"type\": \"http.response.body\", \"body\": body})\n return\n await self.app(scope, receive, send)\n\n\nuvicorn.run(TakeTheClientAtItsWord(server.streamable_http_app()), host=\"127.0.0.1\", port=8000)\n```\n\n```python\n# client.py\nimport asyncio\nimport logging\n\nfrom mcp import Client\n\nlogging.basicConfig(level=logging.DEBUG, format=\"%(levelname)s %(name)s %(message)s\")\n\n\nasync def main() -> None:\n async with Client(\"http://127.0.0.1:8000/mcp\", mode=\"legacy\") as client:\n print(\"tools/call still works:\", (await client.call_tool(\"echo\", {\"text\": \"hi\"})).content[0].text)\n await asyncio.sleep(3)\n\n\nasyncio.run(main())\n```\n\nDrop the `GET` branch from the wrapper and log `scope[\"headers\"]` to see the outgoing headers instead of the failure.\n\n### Python & MCP Python SDK\n\n```Text\nPython 3.14.3 (CPython, macOS arm64)\nmcp 2.2.0, httpx2 2.12.0, httpcore2 2.12.0, anyio 4.15.1, uvicorn 0.52.4\n```\n","author":{"url":"https://github.com/clemlesne","@type":"Person","name":"clemlesne"},"datePublished":"2026-09-14T16:56:25Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/3503"}
| 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:7db23a1f-3313-fd02-e3eb-1d1df605bc62 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D6D0:3F8A67:1308D1:1A1F0C:6B00BCDA |
| html-safe-nonce | 2bdf6ccc4816bbd6ae58c9ed6eb3a263b9eb59277235ceff42e3041ddf2cfc9d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENkQwOjNGOEE2NzoxMzA4RDE6MUExRjBDOjZCMDBCQ0RBIiwidmlzaXRvcl9pZCI6IjgyNzU0MDc4NzM5ODQwMjE4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f09a361c9339ed65b2c2d78677982e7e9ef43b646aefd0387333ca5a64536b13 |
| hovercard-subject-tag | issue:5452207074 |
| 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/3503/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5cf2a283770f7df0d8c799c7e6563432a764293f31622bd49479582ff8ef1345/modelcontextprotocol/python-sdk/issues/3503 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5cf2a283770f7df0d8c799c7e6563432a764293f31622bd49479582ff8ef1345/modelcontextprotocol/python-sdk/issues/3503 |
| og:image:alt | AI disclosure: I used Claude Code to read the transport, capture the headers and build the reproduction. I hit the problem myself, ran the repro, and stand behind the report. Initial Checks 2.2.0 (... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | clemlesne |
| hostname | github.com |
| expected-hostname | github.com |
| None | 93edd3bebc4afb7ce711ee74cb5d2a95927850b082a4d43e212222389cb1c415 |
| 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 | 1fee81a280ea86312b69448e261b418189bfd5b5 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width