Streamable HTTP serves a 2026-07-28 request as legacy when the MCP-Protocol-Version header is 2025-era or missing
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 55/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
Start with StreamableHTTPSessionManager._handle_request in src/mcp/server/streamable_http_manager.py and compare its header based routing with _has_modern_envelope in src/mcp/server/runner.py and classify_inbound_request. Reproduce the issue using the script in the report, then inspect the existing streamable HTTP tests. Done means requests whose body protocol version disagrees with the header, or lacks a header, receive HTTP 400 with a HeaderMismatch JSON-RPC error while legacy requests retain their current behavior.
索引モデルが issue の本文から書いたものです。
説明
Initial Checks
- I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1)
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
Release line
2.x
Description
StreamableHTTPSessionManager picks the protocol era from the MCP-Protocol-Version header alone. A request can carry the 2026-07-28 _meta envelope in its body while its header says 2025-11-25, or has no header at all. Either way it goes to the legacy path and gets HTTP 200 with a 2025-shaped result.
The Protocol Version Header section says the header must match _meta's io.modelcontextprotocol/protocolVersion, and the server "MUST reject the request with 400 Bad Request and a HeaderMismatch JSON-RPC error" when it doesn't.
Running the script in Example Code prints:
2026-07-28 200 {"jsonrpc":"2.0","id":1,"result":{"cacheScope":"private","resultType":"complete","tools":[
2025-11-25 200 {"jsonrpc":"2.0","id":1,"result":{"tools":[{"description":"","inputSchema":{"properties":{
None 200 {"jsonrpc":"2.0","id":1,"result":{"tools":[{"description":"","inputSchema":{"properties":{
The last two are answered as 2025 requests. I'd expect 400 with error -32020.
I had a look at how this could work. The routing is header-only on purpose for now (the TODO in _handle_request), but most of the pieces seem to be there already. The stdio runner picks the era from the body (_has_modern_envelope), and classify_inbound_request already answers a missing or different header with HEADER_MISMATCH. So maybe HTTP could use the same body check before falling back to legacy, roughly:
# StreamableHTTPSessionManager._handle_request
if pv is not None and pv not in HANDSHAKE_PROTOCOL_VERSIONS:
await handle_modern_request(...)
return
+if scope["method"] == "POST":
+ # body is already buffered by RequestBodyLimitMiddleware
+ message = await receive()
+ receive = replay(message, then=receive)
+ body = parse_json_or_none(message["body"])
+ if isinstance(body, dict) and body.get("method") != "initialize" and has_modern_envelope(body.get("params")):
+ await handle_modern_request(..., receive, send) # existing ladder -> 400 / -32020
+ return
if self.stateless:
...
-# runner.py
-def _has_modern_envelope(params): ...
+# shared/inbound.py, used by both stdio and HTTP
+def has_modern_envelope(params): ...
That keeps legacy traffic (including unparseable bodies) on the same path as today. A couple of questions before I go further:
- Should batches and notifications that carry the 2026-07-28
_metabe covered too, like the TypeScript SDK does? I kept them out of the sketch to keep it small. - Is the
TODO(L49)follow-up already planned on your side? If so, I'm happy to leave it with you.
If this direction makes sense, I'm happy to open a PR for it. Ofc I've used Claude to work on this issue. The repro, the testing and any mistakes are all mine.
Example Code
# uv run --with mcp repro.py
import threading
import time
import httpx2
import uvicorn
from mcp.server.mcpserver import MCPServer
mcp = MCPServer("repro")
@mcp.tool()
def ping() -> str:
return "pong"
app = mcp.streamable_http_app(stateless_http=True, json_response=True)
server = uvicorn.Server(uvicorn.Config(app, port=8765, log_level="warning"))
threading.Thread(target=server.run, daemon=True).start()
while not server.started:
time.sleep(0.1)
body = {
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list",
"params": {
"_meta": {
"io.modelcontextprotocol/protocolVersion": "2026-07-28",
"io.modelcontextprotocol/clientCapabilities": {},
}
},
}
for version in ["2026-07-28", "2025-11-25", None]:
headers = {"accept": "application/json", "mcp-method": "tools/list"}
if version:
headers["mcp-protocol-version"] = version
response = httpx2.post("http://127.0.0.1:8765/mcp", json=body, headers=headers)
print(version, response.status_code, response.text[:90])
Python & MCP Python SDK
Python 3.13.0
mcp 2.3.0 (also reproduced on main at 77001c9)
- 主要言語
- Python
- スター
- 25k
- フォーク
- 4.2k
- 平均マージ
- 10分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/python-sdk のほかの issue
-
v2
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
modelcontextprotocol/python-sdk#3978 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Client serves cached tools after its context exits with an exception対応中かも @jonxsong が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
modelcontextprotocol/python-sdk#3968 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
modelcontextprotocol/python-sdk#3957 ·
メンテナーはふだん 1 日以内に返信
-
v2
難易度 1/5 1時間未満 初心者へのやさしさ 91/100
modelcontextprotocol/python-sdk#3934 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug v1
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
modelcontextprotocol/python-sdk#3929 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
modelcontextprotocol/python-sdk の issue をすべて見る
似ている issue
-
auto-reported bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
stix-atlas.json: the same relationship id is used for several different mitigates relationshipsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
backend bug
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
nolte/kamerplanter#3193 ·
メンテナーはふだん 1 日以内に返信
-
soup prune-prompt exits 1 after writing its output on a file over 100,000 rows, and reports a capped row count otherwise対応中かも @abdulwaarith0 が今日担当しました。 オープンneeds-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
MakazhanAlpamys/Soup#3690 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信