Streamable HTTP: Content-Type handling is order dependent and accepts invalid values
メンテナーはふだん 1 日以内に返信
@jayzuccarelli がすでに取り組んでいます。
2026年10月12日 から。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 76/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
まず src/mcp/server/transport_security.py と src/mcp/server/streamable_http.py の Content-Type チェックを読み、次に対応する modern transport のチェックをたどってください。パラメータやカンマ区切りの値を含め、列挙された Content-Type 値のテストを追加または更新してください。すべての transport で、オプションのパラメータ付き application/json のみが一貫して受け入れられれば完了です。
索引モデルが 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 (current stable)
Description
The Content-Type header:
- accepts values that are not JSON media types.
application/json, text/plainis accepted and the request is executed, although a comma cannot appear inside a media type. On the modern transportapplication/jsonxis accepted as well - The answer depends on order.
application/json, text/plainis accepted whiletext/plain, application/jsonis rejected, so the same invalid value gets opposite answers.
The first check is a prefix test in the middleware:
# src/mcp/server/transport_security.py
return content_type is not None and content_type.lower().startswith("application/json")
The second splits the value on ; and , and compares the result:
# src/mcp/server/streamable_http.py
content_type_parts = [part.strip() for part in content_type.split(";")[0].split(",")]
return any(part == CONTENT_TYPE_JSON for part in content_type_parts)
The second check rejects application/jsonx. The 2.x modern transport has no equivalent, so it accepts that value.
For reference, the TypeScript SDK answers 415 for application/json, text/plain and for application/jsonx, and mcp-go answers 400 for both.
Reproduction
Against a server started with stateless_http=True, so no session handshake is needed:
curl -s http://127.0.0.1:8901/mcp \
-H 'Content-Type: application/json, text/plain' \
-H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"ping","arguments":{}}}'
Observed: 200 with a normal JSON-RPC result, and the tool's handler runs.
Content-Type sent |
Expected | handshake transport (1.x and 2.x) | modern transport (2.x only) |
|---|---|---|---|
application/json |
accepted | 200 |
200 |
application/json; charset=utf-8 |
accepted | 200 |
200 |
application/json, text/plain |
rejected | 200, body executed |
200, body executed |
application/jsonx |
rejected | 415 |
200, body executed |
text/plain, application/json |
rejected | 400 |
400 |
text/plain |
rejected | 400 |
400 |
For modern transport calls were sent with MCP-Protocol-Version: 2026-07-28 plus the Mcp-Method and Mcp-Name headers.
Fix
Parse the media type, the segment before the first ;, and compare it exactly to application/json. Parameters keep working, so application/json; charset=utf-8 is unaffected, while the values above are rejected.
Python & MCP Python SDK
Reproduced on the 2.x line (`2.2.0`, `2.3.0`) and the 1.x line (`1.30.0`)
- 主要言語
- Python
- スター
- 24.5k
- フォーク
- 4k
- 平均マージ
- 18時間 28分
- マージ済み PR(30日)
- 38
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/python-sdk のほかの issue
-
bug v1 v2
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
modelcontextprotocol/python-sdk#3725 ·
メンテナーはふだん 1 日以内に返信
-
2026-07-28 SSE responses share one header list, so in-place middleware appends leak across responses再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンbug spec-2026-07-28 v2
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
modelcontextprotocol/python-sdk#3701 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug v1 v2
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
modelcontextprotocol/python-sdk#3698 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Skills: URI traversal validation skips percent-encoded dot-segments対応中かも @Varshith-Kali が 4 日前に担当しました。 オープンbug v2
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
modelcontextprotocol/python-sdk#3685 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Type annotation gaps and unhandled FileNotFoundError in src/mcp/cli/cli.py再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
modelcontextprotocol/python-sdk#3673 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
modelcontextprotocol/python-sdk の issue をすべて見る
似ている issue
-
bug needs-triage priority:medium
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
yeongseon/azure-functions-logging-python#583 ·
メンテナーはふだん 1 日以内に返信
-
documentation needs-triage priority:medium
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
yeongseon/azure-functions-validation-python#546 ·
メンテナーはふだん 1 日以内に返信
-
PHP workflow streaming requests buffer the full SSE response対応中かも @Winoren が今日担当しました。 オープンreview: medium
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
langgenius/dify#44270 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
P4: low
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
jeffknupp/association#523 ·
-
bug help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
DarkStarSystems/pcons#229 ·
メンテナーはふだん 1 日以内に返信