Skip to content

MCP server in the HTTP Streamable mode broken #1190

@akolotov

Description

@akolotov

Starting from v1.12.0 (checked with v1.12.0 and v1.12.1) any request to the MCP server in the HTTP Streamable mode produces an error:

INFO:     127.0.0.1:32926 - "POST /mcp/ HTTP/1.1" 307 Temporary Redirect
[07/23/25 16:34:18] INFO     Processing request of type ListToolsRequest                                        server.py:625
INFO:     127.0.0.1:32926 - "POST /mcp HTTP/1.1" 200 OK
                    INFO     Terminating session: None                                                 streamable_http.py:630
                    ERROR    Error in message router                                                   streamable_http.py:880
                             ╭────────────────── Traceback (most recent call last) ──────────────────╮                       
                             │ /usr/local/lib/python3.12/site-packages/mcp/server/streamable_http.py │                       
                             │ :831 in message_router                                                │                       
                             │                                                                       │                       
                             │   828 │   │   │   # Create a message router that distributes messages │                       
                             │   829 │   │   │   async def message_router():                         │                       
                             │   830 │   │   │   │   try:                                            │                       
                             │ ❱ 831 │   │   │   │   │   async for session_message in write_stream_r │                       
                             │   832 │   │   │   │   │   │   # Determine which request stream(s) sho │                       
                             │   833 │   │   │   │   │   │   message = session_message.message       │                       
                             │   834 │   │   │   │   │   │   target_request_id = None                │                       
                             │                                                                       │                       
                             │ /usr/local/lib/python3.12/site-packages/anyio/abc/_streams.py:35 in   │                       
                             │ __anext__                                                             │                       
                             │                                                                       │                       
                             │    32 │                                                               │                       
                             │    33 │   async def __anext__(self) -> T_co:                          │                       
                             │    34 │   │   try:                                                    │                       
                             │ ❱  35 │   │   │   return await self.receive()                         │                       
                             │    36 │   │   except EndOfStream:                                     │                       
                             │    37 │   │   │   raise StopAsyncIteration                            │                       
                             │    38                                                                 │                       
                             │                                                                       │                       
                             │ /usr/local/lib/python3.12/site-packages/anyio/streams/memory.py:111   │                       
                             │ in receive                                                            │                       
                             │                                                                       │                       
                             │   108 │   async def receive(self) -> T_co:                            │                       
                             │   109 │   │   await checkpoint()                                      │                       
                             │   110 │   │   try:                                                    │                       
                             │ ❱ 111 │   │   │   return self.receive_nowait()                        │                       
                             │   112 │   │   except WouldBlock:                                      │                       
                             │   113 │   │   │   # Add ourselves in the queue                        │                       
                             │   114 │   │   │   receive_event = Event()                             │                       
                             │                                                                       │                       
                             │ /usr/local/lib/python3.12/site-packages/anyio/streams/memory.py:93 in │                       
                             │ receive_nowait                                                        │                       
                             │                                                                       │                       
                             │    90 │   │                                                           │                       
                             │    91 │   │   """                                                     │                       
                             │    92 │   │   if self._closed:                                        │                       
                             │ ❱  93 │   │   │   raise ClosedResourceError                           │                       
                             │    94 │   │                                                           │                       
                             │    95 │   │   if self._state.waiting_senders:                         │                       
                             │    96 │   │   │   # Get the item from the next sender                 │                       
                             ╰───────────────────────────────────────────────────────────────────────╯                       
                             ClosedResourceError

Rollback to 1.11.0 fix the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Significant bug affecting many users, highly requested featurebugSomething isn't workingready for workEnough information for someone to start working on

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions