modelcontextprotocol / modelcontextprotocol/python-sdk
HTTP transport swallows non-2xx status codes causing client to hang
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 24.3k
- Forks
- 4k
- Merge medio
- 1 d 1 h
- PR fusionados (30 d)
- 31
Descripción
Summary
When an MCP server returns non-2xx HTTP status codes (401/403/404/5xx), the Streamable HTTP and SSE transports do not reliably propagate the error to the caller. In the Streamable HTTP transport, post_writer catches exceptions and logs them, but the caller blocks indefinitely waiting for a response on the read stream. HTTP 404 responses are also converted to JSONRPCError(code=32600), losing the original HTTP status information.
Expected Behavior
- Non-2xx HTTP responses should be surfaced as exceptions to the caller, not silently logged
- The original HTTP status code should be preserved and accessible
- Auth-related errors (401/403) should be distinguishable from other failures
Current Behavior
post_writerin Streamable HTTP transport catches and logs errors without forwarding them through the read stream- Callers hang indefinitely waiting for a response
- HTTP 404 is converted to
JSONRPCError(code=32600), destroying HTTP-level context
Affected Code
src/mcp/client/streamable_http.py(post_writer)src/mcp/client/sse.py(sse_reader)
Related
- #1742 — broader typed error classes design
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza siguiendo el manejo de errores en src/mcp/client/streamable_http.py, especialmente en post_writer, y en src/mcp/client/sse.py, especialmente en sse_reader. Revisa el issue relacionado #1742 sobre el diseño de errores tipados. Se considera terminado cuando las respuestas con estados no-2xx llegan al llamador como excepciones, conservan su estado HTTP, distinguen entre 401/403 y dejan de hacer que los llamadores esperen indefinidamente.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- api, backend
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 48/100