modelcontextprotocol / modelcontextprotocol/python-sdk
Active Streamable HTTP sessions are not terminated during shutdown
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
Initial Checks
- I confirm that I'm using the latest version of MCP Python SDK
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
Description
Context
This is primarily a repost of this fastmcp issue as it seems to actually be a bug in the mcp python sdk and I want to make sure we've got visibility over here.
When shutting down a FastMCP server (CTRL+C) while clients have active streaming connections, Uvicorn logs:
ERROR: ASGI callable returned without completing response.The error occurs because StreamableHTTPSessionManager cancels the task group without first gracefully terminating active SSE/streaming connections.
Expected behavior would be the active connections being closed with a proper http response before the rest of shutdown.
Example Code
from fastmcp import FastMCP
mcp = FastMCP("Test Server")
@mcp.tool
def hello() -> str:
return "Hello, World!"
if __name__ == "__main__":
mcp.run(transport="streamable-http", port=8000)
Python & MCP Python SDK
Python 3.12
MCP Python SDK 1.26.0
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 con el manejo del shutdown de StreamableHTTPSessionManager y reproduce el problema usando el ejemplo streamable-http con Python 3.12. Traza cómo se cancelan las conexiones SSE o de streaming activas y, a continuación, verifica que el shutdown las cierre con una respuesta HTTP adecuada sin el error de Uvicorn ASGI.
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