Streamable HTTP: Content-Type handling is order dependent and accepts invalid values
Maintainer antworten meist innerhalb von 1 Tag
@jayzuccarelli arbeitet bereits daran.
Seit 12.10.2026.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 76/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- python
- Bereich
- backend-api-design, security
Rechercherichtung
Lies zunächst die Content-Type-Prüfungen in src/mcp/server/transport_security.py und src/mcp/server/streamable_http.py und verfolge anschließend die entsprechende Prüfung im modernen Transport. Ergänze oder aktualisiere Tests für die aufgeführten Content-Type-Werte, einschließlich Parametern und durch Kommas getrennten Werten. Fertig ist die Änderung, wenn über alle Transports hinweg nur application/json, optional mit Parametern, konsistent akzeptiert wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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`)
- Vorherrschende Sprache
- Python
- Sterne
- 24.5k
- Forks
- 4k
- Ø Merge
- 18 Std. 31 Min.
- Gemergte PRs (30 T.)
- 38
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus modelcontextprotocol/python-sdk
-
2026-07-28 SSE responses share one header list, so in-place middleware appends leak across responsesEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offenbug spec-2026-07-28 v2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
modelcontextprotocol/python-sdk#3701 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug v1 v2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
modelcontextprotocol/python-sdk#3698 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Skills: URI traversal validation skips percent-encoded dot-segmentsEvtl. vergeben @Varshith-Kali hat das vor 1 Tag übernommen. Offenbug v2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
modelcontextprotocol/python-sdk#3685 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Type annotation gaps and unhandled FileNotFoundError in src/mcp/cli/cli.pyEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offenenhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
modelcontextprotocol/python-sdk#3673 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Streamable HTTP server rejects a mixed-case Content-Type with 415Evtl. vergeben @CRYPTONIKAV hat das vor 4 Tagen übernommen. Offenbug v1 v2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
modelcontextprotocol/python-sdk#3670 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in modelcontextprotocol/python-sdk
Ähnliche Issues
-
customer-reported question
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Azure/azure-sdk-for-python#49548 · 1 Kommentar · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
btclib-org/btclib-wallet#409 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Phase 2 PSA Capability & Career Profile
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
bcgov/digital-journeys#2310 ·
-
bug good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
fastmachinelearning/hls4ml#1582 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
Sort modelsOffenenhancement good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Maintainer antworten meist innerhalb von 1 Tag