Title: Streamable HTTP server never returns the spec-mandated 405 for GET requests it won't serve as SSE (406/400 instead) — breaks client SSE-probe fallback · Issue #3102 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Streamable HTTP server never returns the spec-mandated 405 for GET requests it won't serve as SSE (406/400 instead) — breaks client SSE-probe fallback · Issue #3102 · modelcontextprotocol/python-sdk
X Title: Streamable HTTP server never returns the spec-mandated 405 for GET requests it won't serve as SSE (406/400 instead) — breaks client SSE-probe fallback · Issue #3102 · modelcontextprotocol/python-sdk
Description: Summary The streamable-HTTP server transport never answers a GET it won't serve with 405 Method Not Allowed, even though the spec makes 405 the required signal: The server MUST either return Content-Type: text/event-stream in response to...
Open Graph Description: Summary The streamable-HTTP server transport never answers a GET it won't serve with 405 Method Not Allowed, even though the spec makes 405 the required signal: The server MUST either return Conten...
X Description: Summary The streamable-HTTP server transport never answers a GET it won't serve with 405 Method Not Allowed, even though the spec makes 405 the required signal: The server MUST either return Co...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/3102
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Streamable HTTP server never returns the spec-mandated 405 for GET requests it won't serve as SSE (406/400 instead) — breaks client SSE-probe fallback","articleBody":"## Summary\n\nThe streamable-HTTP **server** transport never answers a GET it won't serve with **405 Method Not Allowed**, even though the spec makes 405 the required signal:\n\n> *The server MUST either return `Content-Type: text/event-stream` in response to this HTTP GET, or else return HTTP 405 Method Not Allowed, indicating that the server does not offer an SSE stream at this endpoint.*\n> — [Streamable HTTP § Listening for Messages from the Server](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#listening-for-messages-from-the-server)\n\nInstead, a GET that can't be served yields:\n\n| Pre-session `GET /mcp` with… | Server response |\n|---|---|\n| `Accept: */*`, `Accept: application/json`, or no Accept | **406 Not Acceptable** (`_handle_get_request` → `_check_accept_headers`, which does literal prefix matching so `*/*` is not honored) |\n| `Accept: text/event-stream` (stateful server, no `mcp-session-id`) | **400 Bad Request: Missing session ID** (`_validate_session`) |\n\nSo in stateful mode there is **no request shape** for which a pre-session GET returns 405. (405 *is* used elsewhere: DELETE without a session and unsupported methods.)\n\n## Why it matters — real interop break\n\nSeveral client transports probe with exactly this GET **before** `initialize` to ask \"do you offer a standalone SSE stream?\", and treat **only 405** as the graceful \"no SSE — fall through to POST\" signal (e.g. the TypeScript SDK's `_startOrAuthSse` explicitly special-cases 405). Any other status is a transport error, so against a stock python-SDK server the connection aborts before `initialize` is ever sent.\n\nWe hit this in production between two independently-built agents: the client authenticated successfully, then its GET probe got 406 (its relay sent `Accept: */*`), the transport threw, and the handshake never reached `initialize` — surfacing as \"server doesn't respond to MCP protocol\" while the server looked perfectly healthy to every python-SDK client (which only GETs *after* initialize, with a session id). We've deployed a workaround (a small ASGI shim returning 405 + `Allow: POST` for session-less GETs on the MCP path), but every stock python-SDK deployment presumably reproduces this.\n\n## Repro (mcp 1.28.1, stateful StreamableHTTP server)\n\n```bash\ncurl -i -X GET http://localhost:8000/mcp -H 'Accept: */*' # → 406, expected 405\ncurl -i -X GET http://localhost:8000/mcp -H 'Accept: text/event-stream' # → 400, expected 405 (no session yet)\n```\n\n## Suggested behavior\n\nFor a GET the server cannot serve as an SSE stream, respond **405 with an `Allow` header** per the spec quote above — at minimum for the pre-session case (no `mcp-session-id`), where returning 400 makes the spec'd client probe impossible to satisfy. Separately (or as part of this), `_check_accept_headers` honoring `*/*` / `text/*` per RFC 9110 §12.5.1 would remove the 406 arm for wildcard clients.\n\n## Related\n\n- #2349 covers the POST-side strict dual-Accept requirement; this issue is about the GET/405 contract, which is distinct.\n- #1641 raised wildcard-Accept non-compliance and is closed, but on 1.28.1 `_check_accept_headers` still does literal prefix matching, and the GET path 406s wildcard clients.\n\nHappy to provide full header traces or a PR if the maintainers agree on the intended shape.","author":{"url":"https://github.com/fgranata","@type":"Person","name":"fgranata"},"datePublished":"2026-07-16T11:26:42Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/3102"}
| 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:c6123748-5ea2-7cc6-76ae-9a267a9153ad |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D52:2ADD62:86B78A:B46268:6B00B388 |
| html-safe-nonce | 516cda1305b952961cc50da4690c30056d8f78bd6d84cb5e06a45b8889ea91e2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDUyOjJBREQ2Mjo4NkI3OEE6QjQ2MjY4OjZCMDBCMzg4IiwidmlzaXRvcl9pZCI6IjExOTAzODI0OTQ2MjU2MDg1ODQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 267c19598052f761855f7d1fee0700da831543fb055b6cc2e2cd2da73ee4727f |
| hovercard-subject-tag | issue:4901517161 |
| 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/3102/issue_layout |
| twitter:image | https://opengraph.githubassets.com/552a3ce3a9c6f108895f32d79d33498eb1eee507bae784f8f2cb44613b50ef3a/modelcontextprotocol/python-sdk/issues/3102 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/552a3ce3a9c6f108895f32d79d33498eb1eee507bae784f8f2cb44613b50ef3a/modelcontextprotocol/python-sdk/issues/3102 |
| og:image:alt | Summary The streamable-HTTP server transport never answers a GET it won't serve with 405 Method Not Allowed, even though the spec makes 405 the required signal: The server MUST either return Conten... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fgranata |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1d07c25977adfc5ff6acb0a962a9bc168c07afbda6fef765f9761c350c2ae4a2 |
| 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 | 5429cbfc6aca8c7b9a086a3c8f47400346f38cc9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width