Streamable HTTP: Content-Type handling is order dependent and accepts invalid values
Les mainteneurs répondent en général sous 1 jour
@jayzuccarelli y travaille déjà.
Depuis le 12/10/2026.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 76/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- python
- Domaine
- backend-api-design, security
Piste de recherche
Commencez par lire les vérifications de Content-Type dans src/mcp/server/transport_security.py et src/mcp/server/streamable_http.py, puis suivez la vérification correspondante du transport moderne. Ajoutez ou mettez à jour les tests pour les valeurs de Content-Type indiquées, y compris les paramètres et les valeurs séparées par des virgules. Le travail est terminé lorsque seul application/json, avec des paramètres facultatifs, est accepté de manière cohérente sur tous les transports.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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`)
- Langage dominant
- Python
- Étoiles
- 24.6k
- Forks
- 4.2k
- Merge moyen
- 18 h
- PR mergées (30 j)
- 39
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de modelcontextprotocol/python-sdk
-
bug v1 v2
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
modelcontextprotocol/python-sdk#3729 ·
Les mainteneurs répondent en général sous 1 jour
-
bug v1 v2
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
modelcontextprotocol/python-sdk#3725 · 4 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
bug v1 v2
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
modelcontextprotocol/python-sdk#3698 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Skills: URI traversal validation skips percent-encoded dot-segmentsPeut-être pris @Varshith-Kali l’a pris il y a 6 jours. Ouvertebug v2
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
modelcontextprotocol/python-sdk#3685 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Type annotation gaps and unhandled FileNotFoundError in src/mcp/cli/cli.pyPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverteenhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
modelcontextprotocol/python-sdk#3673 · 4 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de modelcontextprotocol/python-sdk
Issues similaires
-
Edit tool converts CRLF files to LFPeut-être pris @RaphaelFakhri l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
huggingface/tau#774 ·
Les mainteneurs répondent en général sous 1 jour
-
show ignores the row limit when a column or table name contains "limit"Peut-être pris @RaphaelFakhri l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
Les mainteneurs répondent en général sous 1 jour
-
Agents panel: Codex token stats always empty because Codex now writes `*.jsonl.zst` sessionsOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
Les mainteneurs répondent en général sous 2 jours
-
documentation good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
eclipse-score/inc_someip_gateway#356 ·
Les mainteneurs répondent en général sous 2 jours