Mcp-Param-* schema listing is not cancelled when a 2026-07-28 SSE client disconnects
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- backend-api-design
Línea de trabajo
Start in the Streamable HTTP request path at handle_modern_request, then trace _mcp_param_rejection and _tool_input_schema through serve_one to see where schema listing runs before disconnect monitoring. Add or extend tests for an SSE client disconnecting during the fallback tools/list lookup; done means the lookup is cancelled and tools/call is never dispatched. The issue notes that the reporter already has a fix with tests on a branch.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
On the 2026-07-28 Streamable HTTP path, a low-level Server without get_tool_input_schema finds the called
tool's input schema for Mcp-Param-* validation by running its own tools/list handler before dispatch
(_mcp_param_rejection → _tool_input_schema, through serve_one, up to _MCP_PARAM_LIST_PAGE_CAP pages).
In handle_modern_request that lookup runs before the task group that starts watch_disconnect. So in SSE
mode, a client that goes away during the listing does not cancel it. The listing runs to completion; then the
tools/call handler is started and immediately cancelled.
The spec says closing the SSE response stream MUST be treated as cancellation, and the server SHOULD
stop work on the cancelled request as soon as practical (streamable-http, §Cancellation).
#3630 lets a server avoid the listing with get_tool_input_schema. This affects servers that still take the
listing fallback: the default for the low-level Server, and frameworks built on it that do not set the hook
yet (FastMCP 4.1.8 and 4.2.0a4, the latest releases; PrefectHQ/fastmcp#5666 adds it on their main). When tools/list is
expensive (per-user visibility, backend reads), every abandoned call still pays a full listing. We saw this in
production on 2.2.0, with a client that fires many short calls and abandons them.
Expected: a disconnect during the schema listing cancels it, and the call is never dispatched.
Actual: the listing runs to completion, then the call is dispatched and cancelled.
Example Code
import asyncio
import threading
import time
import uvicorn
from mcp import types
from mcp.client.client import Client
from mcp.server.lowlevel.server import Server
events: list[str] = []
async def on_list_tools(ctx, params):
events.append("tools/list started")
try:
await asyncio.sleep(1.0) # a slow, per-user listing
except asyncio.CancelledError:
events.append("tools/list cancelled")
raise
events.append("tools/list ran to completion")
return types.ListToolsResult(
tools=[types.Tool(name="echo", input_schema={"type": "object", "properties": {"text": {"type": "string"}}})]
)
async def on_call_tool(ctx, params):
events.append("tools/call dispatched")
try:
await asyncio.sleep(1.0)
except asyncio.CancelledError:
events.append("tools/call cancelled")
raise
return types.CallToolResult(content=[types.TextContent(type="text", text=params.arguments["text"])])
server = Server("repro", on_list_tools=on_list_tools, on_call_tool=on_call_tool)
app = server.streamable_http_app(stateless_http=True, json_response=False)
threading.Thread(target=uvicorn.Server(uvicorn.Config(app, port=8766, log_level="warning")).run, daemon=True).start()
time.sleep(1)
async def main():
async with Client("http://127.0.0.1:8766/mcp", mode="2026-07-28") as client:
try:
await client.call_tool("echo", {"text": "hi"}, read_timeout_seconds=0.2)
except Exception as exc:
print(f"client gave up: {type(exc).__name__}")
await asyncio.sleep(2.5)
for event in events:
print(" ", event)
asyncio.run(main())
On main (77001c96):
client gave up: MCPError
tools/list started
tools/list ran to completion
tools/call dispatched
tools/call cancelled
The client left after 0.2 s, but the listing ran its full second anyway. The fallback path is the same in
2.2.0 and 2.3.0.
Python & MCP Python SDK
Python 3.13, mcp 2.2.0 in production; reproduced on main @ 77001c96.
Related: #3565 / #3630 (the per-call cost of the listing), #3762 (JSON-response mode does not observe
disconnects).
I have a small fix with tests on a branch and am happy to open a PR if assigned.
Drafted with AI assistance (Claude Code), which also ran the reproduction above and wrote the fix.
- Lenguaje dominante
- Python
- Estrellas
- 25k
- Forks
- 4.2k
- Merge medio
- 10 min
- PR fusionados (30 d)
- 1
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la 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.
Más de modelcontextprotocol/python-sdk
-
v2
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
modelcontextprotocol/python-sdk#3978 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Client serves cached tools after its context exits with an exceptionPosiblemente ocupada @jonxsong la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
modelcontextprotocol/python-sdk#3968 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
modelcontextprotocol/python-sdk#3957 ·
Los mantenedores suelen responder en 1 día
-
v2
Dificultad 1/5 Menos de una hora Aptitud para principiantes 91/100
modelcontextprotocol/python-sdk#3934 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
bug v1
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
modelcontextprotocol/python-sdk#3929 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de modelcontextprotocol/python-sdk
Issues similares
-
soup prune-prompt exits 1 after writing its output on a file over 100,000 rows, and reports a capped row count otherwisePosiblemente ocupada @abdulwaarith0 la tomó hoy. Abiertoneeds-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
MakazhanAlpamys/Soup#3690 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
bug data-types native-format
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
ClickHouse/clickhouse-connect#1320 ·
Los mantenedores suelen responder en 1 día
-
Public benchmark import end-to-end test fails when the test stack's worker runs the parity jobAbiertoaccepted
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
future-agi/future-agi#6392 ·
Los mantenedores suelen responder en 1 día