Progress notifications cause server to hang on stdio transport
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 48/100
Piste de recherche
Commencez par l’API Server de bas niveau et l’implémentation du transport stdio dans src/mcp/server/stdio.py:57. Exécutez l’exemple fourni de notifications de progression avec MCP 1.10.1 pour confirmer où l’appel à send se bloque, puis examinez le comportement du tampon du flux. Le travail est terminé lorsque les notifications de progression et le CallToolResult final parviennent tous deux au client sans que le serveur reste bloqué.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
When using the low-level Server API (mcp.server.lowlevel.Server) with stdio transport, sending progress notifications during request handling causes the server to hang indefinitely and never send the final response.
What I am seeing:
- Server successfully sends progress notification via
write_stream.send() - Server handler returns
CallToolResult - The final response is never sent to the client
- Client times out waiting for response
- Server remains blocked and time out eventually
Example Code
import asyncio
from mcp.server.lowlevel import Server
from mcp.server.stdio import stdio_server
from mcp.types import *
server = Server("progress-bug-demo")
@server.list_tools()
async def handle_list_tools() -> list[Tool]:
return [Tool(
name="test_tool",
description="Demonstrates the bug",
inputSchema={"type": "object", "properties": {}}
)]
@server.call_tool()
async def handle_call_tool(name: str, arguments: dict) -> list[TextContent]:
ctx = server.request_context
progress_token = ctx.meta.progressToken if ctx.meta else None
if progress_token:
# This causes the server to hang
await ctx.session.send_progress_notification(
progress_token=progress_token,
progress=0.5,
total=1.0,
message="Working..."
)
# This response is never sent due to the hang
return [TextContent(type="text", text="Task completed!")]
async def main():
async with stdio_server() as (read_stream, write_stream):
await server.run(
read_stream,
write_stream,
server.create_initialization_options()
)
if __name__ == "__main__":
asyncio.run(main())
Python & MCP Python SDK
MCP: 1.10.1
Python: 3.12.6
From deeper debugging looks like buffer size is the problem : https://github.com/modelcontextprotocol/python-sdk/blob/main/src/mcp/server/stdio.py#L57
Have to test locally if increasing it will most likely fix the issue and if its causing more problems than just fixing this.
- Langage dominant
- Python
- Étoiles
- 24.3k
- Forks
- 4k
- Merge moyen
- 1 j 19 min
- PR mergées (30 j)
- 29
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de modelcontextprotocol/python-sdk
-
Streamable HTTP client logs a WARNING for valid 202 Accepted on session termination (DELETE) Ouvertev1 v2
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
modelcontextprotocol/python-sdk#3546 · 5 commentaires ·
-
v1 v2
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
modelcontextprotocol/python-sdk#3545 · 1 commentaire ·
-
v1 v2
Difficulté 1/5 Moins d'une heure Accessibilité débutants 91/100
modelcontextprotocol/python-sdk#3508 · 2 commentaires ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
modelcontextprotocol/python-sdk#3504 ·
-
v1 v2
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
modelcontextprotocol/python-sdk#3492 · 1 commentaire ·
Toutes les issues de modelcontextprotocol/python-sdk
Issues similaires
-
货币战争手改优先级配置缺少列表元素类型校验(P3) Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
syfoud/Simulated_Scepter#172 ·
-
A cancelled tests run makes the coverage comment workflow fail and reports it as a red check on main Ouvertearea: ci bug perceived difficulty: 3
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Nitjsefnie-Harness-Commons/daedalus#921 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
EleutherAI/lm-evaluation-harness#4207 ·
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 92/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
ClickHouse/clickhouse-connect#1057 ·