Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Streamable HTTP: Content-Type handling is order dependent and accepts invalid values

Abierto Apto para principiantes
#3,691 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@jayzuccarelli ya está trabajando en esto.

Desde el 12/10/2026.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
76/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

Empieza leyendo las comprobaciones de Content-Type en src/mcp/server/transport_security.py y src/mcp/server/streamable_http.py, y luego sigue la comprobación correspondiente del transporte moderno. Añade o actualiza pruebas para los valores de Content-Type indicados, incluidos los parámetros y los valores separados por comas. El trabajo estará terminado cuando solo se acepte application/json, con parámetros opcionales, de forma coherente en todos los transportes.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug v1 v2
Initial Checks
Release line

2.x (current stable)

Description

The Content-Type header:

  • accepts values that are not JSON media types. application/json, text/plain is accepted and the request is executed, although a comma cannot appear inside a media type. On the modern transport application/jsonx is accepted as well
  • The answer depends on order. application/json, text/plain is accepted while text/plain, application/json is 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`)
Lenguaje dominante
Python
Estrellas
24.5k
Forks
4k
Merge medio
18 h 31 min
PR fusionados (30 d)
38

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de modelcontextprotocol/python-sdk

Todos los issues de modelcontextprotocol/python-sdk

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.