Title: stdio dual-era server refuses initialize after a failed server/discover probe (era latched by the first request) · Issue #3851 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: stdio dual-era server refuses initialize after a failed server/discover probe (era latched by the first request) · Issue #3851 · modelcontextprotocol/python-sdk
X Title: stdio dual-era server refuses initialize after a failed server/discover probe (era latched by the first request) · Issue #3851 · modelcontextprotocol/python-sdk
Description: Summary On stdio, serve_dual_era_loop fixes the connection's protocol era from the first request it reads. If that first request is a 2026-07-28 server/discover probe that the server rejects, the connection is still latched to the modern...
Open Graph Description: Summary On stdio, serve_dual_era_loop fixes the connection's protocol era from the first request it reads. If that first request is a 2026-07-28 server/discover probe that the server rejects, the c...
X Description: Summary On stdio, serve_dual_era_loop fixes the connection's protocol era from the first request it reads. If that first request is a 2026-07-28 server/discover probe that the server rejects, t...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/3851
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"stdio dual-era server refuses initialize after a failed server/discover probe (era latched by the first request)","articleBody":"### Summary\n\nOn stdio, `serve_dual_era_loop` fixes the connection's protocol era from the\nfirst request it reads. If that first request is a 2026-07-28 `server/discover`\nprobe that the server **rejects**, the connection is still latched to the modern\nera, and the client's spec-described fallback to `initialize` on the same process\nis refused with `-32022 \"connection is serving the 2026-07-28 protocol; the\ninitialize handshake is not accepted\"`.\n\nThe same server answers `initialize` normally when it is the first request, so it\ndoes support 2025-11-25. It just can't be reached after a failed probe.\n\n### Spec (2026-07-28)\n\n- stdio, *Backward Compatibility*: a dual-version client SHOULD probe with\n `server/discover` first. If \"the server returns any other error [than a\n recognized modern error], or does not respond within a reasonable timeout: the\n server is legacy. Fall back to the `initialize` handshake.\" The fallback MUST\n NOT be keyed to one specific error code.\n- Versioning: \"An `initialize` request selects legacy semantics, scoped to the\n stdio process\", and \"A dual-era server MAY serve both eras concurrently on the\n same endpoint or process.\"\n- Base protocol, *Statelessness*: \"Servers MUST NOT rely on prior requests over\n the same connection to establish context (e.g., capabilities, protocol\n version, client identity).\"\n\nThe spec doesn't say whether the fallback reuses the process or starts a new\none. But a client that follows the stdio text literally sends `initialize` next\non the same process, and a rejected request arguably shouldn't establish the\nconnection's version.\n\n### Reproduction (mcp 2.3.0, Python 3.12)\n\n`server.py`:\n\n```python\nfrom mcp.server import MCPServer\n\napp = MCPServer(\"era-latch-repro\")\n\n@app.tool()\ndef ping() -> str:\n return \"pong\"\n\nif __name__ == \"__main__\":\n app.run() # stdio\n```\n\n`drive.py` (one stdio process: a probe the server rejects with a non-modern\nerror, then the fallback `initialize`):\n\n```python\nimport json, subprocess, sys\n\nMETA = \"io.modelcontextprotocol/protocolVersion\"\nmsgs = [\n # Envelope missing clientCapabilities -> the SDK answers -32602 (a non-modern error)\n {\"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"server/discover\",\n \"params\": {\"_meta\": {META: \"2026-07-28\"}}},\n {\"jsonrpc\": \"2.0\", \"id\": 2, \"method\": \"initialize\",\n \"params\": {\"protocolVersion\": \"2025-11-25\", \"capabilities\": {},\n \"clientInfo\": {\"name\": \"repro\", \"version\": \"0\"}}},\n]\np = subprocess.Popen([sys.executable, \"server.py\"], stdin=subprocess.PIPE,\n stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True)\nfor m in msgs:\n p.stdin.write(json.dumps(m) + \"\\n\"); p.stdin.flush()\n print(\"\u003c\u003c\", p.stdout.readline().strip())\np.stdin.close(); p.wait(timeout=5)\n```\n\nOutput:\n\n```\n\u003c\u003c {\"jsonrpc\":\"2.0\",\"id\":1,\"error\":{\"code\":-32602,\"message\":\"params._meta is missing the required envelope key(s): io.modelcontextprotocol/clientCapabilities\"}}\n\u003c\u003c {\"jsonrpc\":\"2.0\",\"id\":2,\"error\":{\"code\":-32022,\"message\":\"connection is serving the 2026-07-28 protocol; the initialize handshake is not accepted\",\"data\":{\"supported\":[\"2026-07-28\"],\"requested\":\"2025-11-25\"}}}\n```\n\nControl: sending only the `initialize` (no probe) on a fresh process returns a\nnormal result with `\"protocolVersion\":\"2025-11-25\"`.\n\nA legacy-only server built with the SDK (one whose request handling refuses\nmodern versions before `initialize`) hits the same latch: the refused probe fixes\nthe era, and the fallback `initialize` is rejected.\n\n### Expected\n\nA first request that the server rejects shouldn't decide the era. Two options:\nlatch only on a request that succeeds, or still accept `initialize` while no\nmodern request has been answered successfully. Either would let the stdio\nfallback work on the same process.\n\n### Secondary observation\n\nThe `-32022` data lists `\"supported\": [\"2026-07-28\"]` (both on the refused\n`initialize` and on a well-formed probe with an unknown version), although the\nsame server answers `initialize` at 2025-11-25 when that comes first. The\nspec's example of this error lists both eras (`[\"2026-07-28\", \"2025-11-25\"]`).\n\n### Code\n\n`src/mcp/server/runner.py`: `serve_dual_era_loop` / `_replay_from_opening_request`\ndecide `opens_modern` from the opening request alone, and `_serve_modern_stream`\nraises `UNSUPPORTED_PROTOCOL_VERSION` for any later `initialize`. The docstring\nsays this is intentional (\"A later claim from the other era is refused\"), so this\nmay be a design question rather than a bug. Raising it because of the spec's\nstdio fallback text.\n","author":{"url":"https://github.com/kuberaplutus224","@type":"Person","name":"kuberaplutus224"},"datePublished":"2026-11-13T02:16:49Z","url":"https://github.com/modelcontextprotocol/python-sdk/issues/3851"}
| 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:c25fa50b-5059-b267-a3c3-50179c354e9d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C502:1F67:7E19FE:AEF1FB:6B05655C |
| html-safe-nonce | e3c20b3efcfa9b3e898ecba04aad71409855432f7bc9de692a6389efeb0216b6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNTAyOjFGNjc6N0UxOUZFOkFFRjFGQjo2QjA1NjU1QyIsInZpc2l0b3JfaWQiOiI3ODc0ODgwNDM5NDY1NjMzMTE2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 52b2072d020deadf6db62ec87900d29a3f6e177d5a786e97fbbd146bb4096652 |
| hovercard-subject-tag | issue:6363259874 |
| 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/3851/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fabc8696f0c511e1bf9a561896a1c4caae8263148b9ffedd3bb989644fccb6b7/modelcontextprotocol/python-sdk/issues/3851 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fabc8696f0c511e1bf9a561896a1c4caae8263148b9ffedd3bb989644fccb6b7/modelcontextprotocol/python-sdk/issues/3851 |
| og:image:alt | Summary On stdio, serve_dual_era_loop fixes the connection's protocol era from the first request it reads. If that first request is a 2026-07-28 server/discover probe that the server rejects, the c... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kuberaplutus224 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1be5cc09efdd4833c24a4ffa71d698e3999fa09071e159fe14c2c08e41c98331 |
| 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 | f6d69234e682c947a48074340e69d45d5901de31 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width