Title: Streamable HTTP transport rejects Accept: text/event-stream without application/json · Issue #2349 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Streamable HTTP transport rejects Accept: text/event-stream without application/json · Issue #2349 · modelcontextprotocol/python-sdk
X Title: Streamable HTTP transport rejects Accept: text/event-stream without application/json · Issue #2349 · modelcontextprotocol/python-sdk
Description: Problem The StreamableHTTPTransport server validates the Accept header with a strict AND condition, requiring clients to send both application/json and text/event-stream: # mcp/server/streamable_http.py, _validate_accept_header() elif no...
Open Graph Description: Problem The StreamableHTTPTransport server validates the Accept header with a strict AND condition, requiring clients to send both application/json and text/event-stream: # mcp/server/streamable_ht...
X Description: Problem The StreamableHTTPTransport server validates the Accept header with a strict AND condition, requiring clients to send both application/json and text/event-stream: # mcp/server/streamable_ht...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/2349
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Streamable HTTP transport rejects Accept: text/event-stream without application/json","articleBody":"## Problem\n\nThe `StreamableHTTPTransport` server validates the `Accept` header with a strict AND condition, requiring clients to send **both** `application/json` and `text/event-stream`:\n\n```python\n# mcp/server/streamable_http.py, _validate_accept_header()\nelif not (has_json and has_sse):\n response = self._create_error_response(\n \"Not Acceptable: Client must accept both application/json and text/event-stream\",\n HTTPStatus.NOT_ACCEPTABLE,\n )\n```\n\nThis rejects clients that send only `Accept: text/event-stream`, returning a `406 Not Acceptable`.\n\n## Impact\n\nThis breaks compatibility with **Anthropic's MCP proxy** (used by Claude.ai for remote MCP integrations). The Anthropic proxy sends requests with `Accept: text/event-stream` to the `/mcp` endpoint and expects SSE responses. The strict AND validation rejects these requests.\n\nWhen `json_response=False` (the spec-compliant default for SSE-capable servers), the server should be able to handle clients that accept SSE responses even if they don't explicitly accept JSON.\n\n## Expected behavior\n\nThe server should accept requests with either `Accept: application/json` or `Accept: text/event-stream` (or both). The response format should match what the client accepts:\n- `Accept: text/event-stream` → respond with SSE\n- `Accept: application/json` → respond with JSON\n- `Accept: application/json, text/event-stream` → respond with SSE (current spec behavior)\n\n## Suggested fix\n\nChange the AND to OR in `_validate_accept_header()`:\n\n```python\n# Before\nelif not (has_json and has_sse):\n\n# After\nelif not (has_json or has_sse):\n```\n\nThis allows the server to accept clients that support at least one of the two content types, while still being able to negotiate the response format based on what the client accepts.\n\n## Reproduction\n\n```bash\n# Start any MCP server with StreamableHTTP transport (json_response=False)\n\n# This works (both Accept types):\ncurl -X POST http://localhost:8080/mcp \\\n -H \"Content-Type: application/json\" \\\n -H \"Accept: application/json, text/event-stream\" \\\n -d '{\"jsonrpc\":\"2.0\",\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2024-11-05\",\"capabilities\":{},\"clientInfo\":{\"name\":\"test\",\"version\":\"1.0\"}},\"id\":1}'\n# → 200 OK\n\n# This fails (SSE only):\ncurl -X POST http://localhost:8080/mcp \\\n -H \"Content-Type: application/json\" \\\n -H \"Accept: text/event-stream\" \\\n -d '{\"jsonrpc\":\"2.0\",\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2024-11-05\",\"capabilities\":{},\"clientInfo\":{\"name\":\"test\",\"version\":\"1.0\"}},\"id\":1}'\n# → 406 Not Acceptable\n```\n\n## Environment\n\n- MCP SDK version: 1.25.0\n- Discovered while using mcp-proxy v0.11.0 with Claude.ai remote MCP integration","author":{"url":"https://github.com/juliendoclot","@type":"Person","name":"juliendoclot"},"datePublished":"2026-03-25T19:21:44Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/2349"}
| 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:452bb934-e7b5-d509-8864-7f4c39af4866 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A952:6B887:179589:1F233C:6B00BC81 |
| html-safe-nonce | adbdd549474c85e13b511dc70e481b4006009f696a30ce3e6ae513447ebecbea |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTUyOjZCODg3OjE3OTU4OToxRjIzM0M6NkIwMEJDODEiLCJ2aXNpdG9yX2lkIjoiNTAwNDc0MzkwMzY4NTk1MDU5MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | baac691cf2d619dbaa823a7277ea06fd5fe83855884b08c7cb86c417cbf9fcf2 |
| hovercard-subject-tag | issue:4137918277 |
| 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/2349/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8be139910e2b611ea451626de8f100acdc6fd02e8fe089768fad0c9adf179239/modelcontextprotocol/python-sdk/issues/2349 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8be139910e2b611ea451626de8f100acdc6fd02e8fe089768fad0c9adf179239/modelcontextprotocol/python-sdk/issues/2349 |
| og:image:alt | Problem The StreamableHTTPTransport server validates the Accept header with a strict AND condition, requiring clients to send both application/json and text/event-stream: # mcp/server/streamable_ht... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | juliendoclot |
| 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