Streamable HTTP: Content-Type handling is order dependent and accepts invalid values
Mantenedores costumam responder em até 1 dia
@jayzuccarelli já está trabalhando nisso.
Desde 12/10/2026.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 76/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- python
- Domínio
- backend-api-design, security
Direção de pesquisa
Comece lendo as verificações de Content-Type em src/mcp/server/transport_security.py e src/mcp/server/streamable_http.py e, em seguida, rastreie a verificação correspondente no transporte moderno. Adicione ou atualize testes para os valores de Content-Type listados, incluindo parâmetros e valores separados por vírgulas. O trabalho estará concluído quando apenas application/json, com parâmetros opcionais, for aceito de forma consistente em todos os transportes.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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`)
- Linguagem predominante
- Python
- Estrelas
- 24.5k
- Forks
- 4k
- Merge médio
- 18h 31min
- PRs com merge (30d)
- 38
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de modelcontextprotocol/python-sdk
-
bug v2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
modelcontextprotocol/python-sdk#3685 ·
Mantenedores costumam responder em até 1 dia
-
Type annotation gaps and unhandled FileNotFoundError in src/mcp/cli/cli.pyTalvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. Abertaenhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
modelcontextprotocol/python-sdk#3673 · 4 comentários ·
Mantenedores costumam responder em até 1 dia
-
Streamable HTTP server rejects a mixed-case Content-Type with 415Talvez já em andamento @CRYPTONIKAV assumiu há 3 dias. Abertabug v1 v2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
modelcontextprotocol/python-sdk#3670 · 4 comentários ·
Mantenedores costumam responder em até 1 dia
-
Audio(data=b"") raises "Either path or data can be provided", while Image(data=b"") worksTalvez já em andamento @ajay206 assumiu há 2 dias. Abertabug v1 v2
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
modelcontextprotocol/python-sdk#3656 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
modelcontextprotocol/python-sdk#3655 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de modelcontextprotocol/python-sdk
Issues semelhantes
-
vis.image() reports "Unsupported number of image channels: 224" for an HxWxC imageTalvez já em andamento @piyush182004 assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
fossasia/visdom#1997 · 3 comentários ·
Mantenedores costumam responder em até 6 dias
-
Byse new domainAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Gujal00/ResolveURL#1525 ·
Mantenedores costumam responder em até 1 dia
-
Serialisation fails with pydantic 2.14: wrap serialisers pass SerializationInfo as index_keyTalvez já em andamento @hugohills-regnosys assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
finos/rune-python-runtime#45 ·
-
[Bug]: LangGraph Store sync put bypasses namespace validationTalvez já em andamento @ktz03 assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
volcengine/OpenViking#6050 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
hummingbot/condor#283 ·
Mantenedores costumam responder em até 1 dia