Repository navigation
MCP server in the HTTP Streamable mode broken #1190
Copy link
Copy link
Closed
Labels
P1Significant bug affecting many users, highly requested featureSignificant bug affecting many users, highly requested featurebugSomething isn't workingSomething isn't workingready for workEnough information for someone to start working onEnough information for someone to start working on
Milestone
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P1Significant bug affecting many users, highly requested featureSignificant bug affecting many users, highly requested featurebugSomething isn't workingSomething isn't workingready for workEnough information for someone to start working onEnough information for someone to start working on
Activity
akolotov commentedon Jul 23, 2025
Probably addressed by #1188
danielefuselli-project commentedon Jul 25, 2025
same problem here and mentioned PR has been rejected
FernandoBenayas commentedon Jul 27, 2025
Same problem here
huineng commentedon Jul 29, 2025
for what it's worth (maybe not related)
MCP version: 1.12.2
i initially had
but then changing to
so that works i just had to add /mcp after my path
danielefuselli-project commentedon Jul 29, 2025
@huineng from my point of view, not related to this issue.
Here any request to the MCP server in the HTTP Streamable mode produces an error in the logs.
281743556 commentedon Jul 31, 2025
Same problem here
MCP version: 1.12.2
use
_handle_stateless_request>run_stateless_server>http_transport.connect()>for session_message in write_stream_readerIt will go in twice, and an exception(yio.ClosedResourceError) will be thrown when the second request has been closed
View logs:
Terminating has already released memory first
debug for : first

debug for : second
281743556 commentedon Jul 31, 2025
issues:#1219
ochafik commentedon Sep 5, 2025
Would anyone be able to confirm whether this is still ocurring?
danielefuselli-project commentedon Sep 5, 2025
still present for me in 1.13.1
danielefuselli-project commentedon Sep 19, 2025
still present for me in 1.14.0
elioengcomp commentedon Oct 2, 2025
Still present for me in 1.15.0 but only if I set
json_response=True5 remaining items
christoph88 commentedon Oct 17, 2025
I still have issues with this streaming http server. how can I send you debug info? https://docs.ahrefs.com/docs/mcp/reference/introduction
felixweinberger commentedon Oct 17, 2025
Is your issue with the ahrefs server specifically or something you built? Are you running a server yourself or you mean you have trouble connecting to the ahrefs mcp server?
christoph88 commentedon Oct 17, 2025
I have trouble connecting through chatmcp. The MCP server itself works when using it through my ide with the same setup. It's a streaming http server.
Is there a way I can provide you with logs
felixweinberger commentedon Oct 17, 2025
Just paste them here in this issue or share a gist if it's a lot
ofek commentedon Oct 21, 2025
@felixweinberger This is bloating our logs and can be easily reproduced as follows:
maxisbey commentedon Dec 2, 2025
Consolidating duplicate issues:
The following issues have been closed as duplicates of this one:
_handle_stateless_requestClosedResourceErrorRoot Cause Summary (from #1363):
This is a race condition in
message_router()atstreamable_http.py:959:message_routerentersasync for write_stream_readerloopcheckpoint(), yielding controlterminate(), closing the streammessage_routerresumes and encounters closed stream →ClosedResourceErrorProposed Fix: PR #1384 adds explicit
ClosedResourceErrorhandling before the genericexcept Exceptionblock.Workaround (from #1363): Suppress logs via uvicorn config:
AI Disclaimer
ofek commentedon Dec 2, 2025
@maxisbey What's blocking the proposed fix that you mentioned from being merged?