modelcontextprotocol / modelcontextprotocol/python-sdk
Active Streamable HTTP sessions are not terminated during shutdown
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 24.3k
- Forks
- 4k
- Merge médio
- 1d 1h
- PRs com merge (30d)
- 31
Descrição
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
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.
Direção de pesquisa
Comece pelo tratamento de shutdown de StreamableHTTPSessionManager e reproduza o problema usando o exemplo streamable-http no Python 3.12. Rastreie como as conexões SSE ou de streaming ativas são canceladas e, em seguida, verifique se o shutdown as fecha com uma resposta HTTP adequada, sem o erro de Uvicorn ASGI.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- api, backend
- Tipo de issue
- Bug
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Pouca atividade
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 48/100