Progress notifications cause server to hang on stdio transport
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
從低階 Server API 和 src/mcp/server/stdio.py:57 中的 stdio 傳輸實作開始。使用 MCP 1.10.1 執行提供的進度通知範例,以確認 send 在哪裡發生阻塞,然後檢查串流緩衝區的行為。完成的標準是進度通知和最終的 CallToolResult 都能到達用戶端,且伺服器不會掛起。
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- Python
- 星號
- 24.3k
- 分支
- 4k
- 平均合併
- 1 天 7 小時
- 30 天內合併 PR
- 18
環境準備
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
modelcontextprotocol/python-sdk 的其他 Issue
-
v1 v2
難度 2/5 1-3 小時 新手友好度 86/100
modelcontextprotocol/python-sdk#3589 ·
維護者通常 1 天內回覆
-
v1 v2
難度 2/5 1-3 小時 新手友好度 84/100
modelcontextprotocol/python-sdk#3585 ·
維護者通常 1 天內回覆
-
v1 v2
難度 2/5 1-3 小時 新手友好度 70/100
modelcontextprotocol/python-sdk#3578 · 1 則留言 ·
維護者通常 1 天內回覆
-
v1 v2
難度 2/5 1-3 小時 新手友好度 65/100
modelcontextprotocol/python-sdk#3573 · 4 則留言 ·
維護者通常 1 天內回覆
-
v2
難度 2/5 1-3 小時 新手友好度 75/100
modelcontextprotocol/python-sdk#3566 ·
維護者通常 1 天內回覆
查看 modelcontextprotocol/python-sdk 的全部 Issue
相似的 Issue
-
docs pydanty:is-working
難度 2/5 1-3 小時 新手友好度 75/100
pydantic/pydantic-ai#8863 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
run-llama/llama_index#23278 ·
維護者通常 2 天內回覆
-
documentation from-review-extraction github-actions priority: low severity:nit
難度 1/5 1 小時以內 新手友好度 92/100
LearningCircuit/local-deep-research#6946 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
oracle/langchain-oracle#323 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 88/100
tenstorrent/tt-metal#58057 · 1 則留言 ·
維護者通常 1 天內回覆