modelcontextprotocol / modelcontextprotocol/python-sdk

Progress notifications cause server to hang on stdio transport

Open
#1,141 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3 ready for work
Dominant language
Python
Stars
24.3k
Forks
4k
Avg merge
1d 1h
Merged PRs (30d)
31

Description

Initial Checks
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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the low-level Server API and the stdio transport implementation at src/mcp/server/stdio.py:57. Run the provided progress-notification example with MCP 1.10.1 to confirm where the send blocks, then inspect the stream buffer behavior. Done means progress notifications and the final CallToolResult both reach the client without the server hanging.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.