Streamable HTTP: malformed requests return raw pydantic errors to the client
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Il testo grezzo di pydantic e del parsing JSON proviene dal gestore POST in src/mcp/server/streamable_http.py, intorno alle righe 580-596. Il percorso 2026-07-28 in _streamable_http_modern.py (intorno alla riga 415) restituisce già messaggi fissi, quindi copia quello schema. Esegui lo script di esempio per vedere i body attuali, poi verifica che un input malformato restituisca il testo fisso «Parse error» o «Invalid JSON-RPC message», mentre i dettagli finiscono solo nel log del server. Aggiungi test per i casi con jsonrpc mancante e con contenuto non JSON, e verifica la stessa modifica su v1.x.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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)
Also applies to latest 1.x
Description
When the Streamable HTTP POST handler rejects a malformed body, it returns the raw exception text to the client (streamable_http.py L580-L596):
- No
"jsonrpc"field →"Validation error: 6 validation errors for union[JSONRPCRequest,...] ... input_value={...} ... https://errors.pydantic.dev/2.14/v/missing" - Not JSON →
"Parse error: EOF while parsing a value at line 1 column 27"
A security audit of our MCP server flagged this: the errors reveal that the backend is Python, using pydantic (down to the exact version) and the MCP Python SDK, which helps an attacker enumerate the environment.
Expected: fixed messages (Parse error, Invalid JSON-RPC message), with detail in the server log only. The 2026-07-28 path already does this (_streamable_http_modern.py L415).
The same code is on v1.x, which we run. I’d like to fix both if assigned: a few lines plus tests, with no new API.
Related: #3557 (error code on these lines), #3572 (same pydantic text in tool-argument errors).
Disclosure: this issue was drafte by Claude Code and reviewed/iterated by myself and another senior developer. I ran the reproduction and verified the output myself.
Example Code
import json
from mcp.server import MCPServer
from mcp.server.transport_security import TransportSecuritySettings
from starlette.testclient import TestClient
server = MCPServer("repro")
@server.tool()
def echo(text: str) -> str:
return text
app = server.streamable_http_app(
stateless_http=True,
transport_security=TransportSecuritySettings(enable_dns_rebinding_protection=False),
)
headers = {
"Accept": "application/json, text/event-stream",
"Content-Type": "application/json",
"mcp-protocol-version": "2025-06-18",
}
with TestClient(app) as client:
for body in (
json.dumps({"id": 1, "method": "tools/call", "params": {"name": "echo", "arguments": {"text": "hi"}}}),
json.dumps([{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}]),
'{"jsonrpc": "2.0", "id": 1,',
):
response = client.post("/mcp", content=body, headers=headers)
print(response.status_code, json.dumps(response.json(), indent=2))
Python & MCP Python SDK
Python 3.12.9
mcp 2.3.0
pydantic 2.14.0
- Lingua principale
- Python
- Stelle
- 24.5k
- Fork
- 4k
- Merge medio
- 18h 31m
- PR unite (30g)
- 38
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di modelcontextprotocol/python-sdk
-
2026-07-28 SSE responses share one header list, so in-place middleware appends leak across responsesForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertabug spec-2026-07-28 v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
modelcontextprotocol/python-sdk#3701 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Streamable HTTP: Content-Type handling is order dependent and accepts invalid valuesForse già presa @jayzuccarelli l’ha presa 3 giorni fa. Apertabug v1 v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
modelcontextprotocol/python-sdk#3691 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Skills: URI traversal validation skips percent-encoded dot-segmentsForse già presa @Varshith-Kali l’ha presa 2 giorni fa. Apertabug v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
modelcontextprotocol/python-sdk#3685 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Type annotation gaps and unhandled FileNotFoundError in src/mcp/cli/cli.pyForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
modelcontextprotocol/python-sdk#3673 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Streamable HTTP server rejects a mixed-case Content-Type with 415Forse già presa @CRYPTONIKAV l’ha presa 5 giorni fa. Apertabug v1 v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
modelcontextprotocol/python-sdk#3670 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di modelcontextprotocol/python-sdk
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
jbacalso24/mimry#291 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 82/100
eli-alvarado/us-watchlist-alerts#14 ·
I maintainer di solito rispondono entro 1 giorno
-
from-review-extraction python severity:nit
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
LearningCircuit/local-deep-research#7462 ·
I maintainer di solito rispondono entro 2 giorni
-
mermaid_extract.py silently discards single-line state-diagram notes; sequence notes are keptAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
cathrynlavery/diagram-design#441 ·
I maintainer di solito rispondono entro 2 giorni
-
[Cleanup] Include the public header in work_split.cppForse già presa @blozano-tt l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
tenstorrent/tt-metal#60850 ·
I maintainer di solito rispondono entro 1 giorno