Skip to content

[Bug]: streamable_http - ERROR - Error in message router - ClosedResourceErrorΒ #803

@MohanLaksh

Description

@MohanLaksh

🐞 Bug Summary

The server intermittently disconnects due to an ERROR in streamable_http message router.

streamable_http - ERROR - Error in message router - ClosedResourceError

Image

🧩 Affected Component

Select the area of the project impacted:

  • mcpgateway - API
  • mcpgateway - UI (admin panel)
  • mcpgateway.wrapper - stdio wrapper
  • Federation or Transports
  • CLI, Makefiles, or shell scripts
  • Container setup (Docker/Podman/Compose)
  • Other (explain below)

πŸ” Steps to Reproduce

  1. make serve add a gateway with streamable_http transport type.

πŸ€” Expected Behavior

What should have happened instead?


πŸ““ Logs / Error Output


2025-08-21 07:46:26,221 - uvicorn.access - INFO - 127.0.0.1:45786 - "POST /mcp HTTP/1.1" 200
2025-08-21 07:46:26,222 - mcp.server.streamable_http - ERROR - Error in message router
Traceback (most recent call last):
File "/home/mohanlaksh/.venv/mcpgateway/lib/python3.12/site-packages/mcp/server/streamable_http.py", line 831, in message_router
async for session_message in write_stream_reader:
File "/home/mohanlaksh/.venv/mcpgateway/lib/python3.12/site-packages/anyio/abc/_streams.py", line 41, in anext
return await self.receive()
^^^^^^^^^^^^^^^^^^^^
File "/home/mohanlaksh/.venv/mcpgateway/lib/python3.12/site-packages/anyio/streams/memory.py", line 111, in receive
return self.receive_nowait()
^^^^^^^^^^^^^^^^^^^^^
File "/home/mohanlaksh/.venv/mcpgateway/lib/python3.12/site-packages/anyio/streams/memory.py", line 93, in receive_nowait
raise ClosedResourceError
anyio.ClosedResourceError
2025-08-21 07:46:26,241 - uvicorn.access - INFO - 127.0.0.1:45786 - "POST /mcp HTTP/1.1" 200
2025-08-21 07:46:26,241 - mcp.server.streamable_http - ERROR - Error in message router
Traceback (most recent call last):
File "/home/mohanlaksh/.venv/mcpgateway/lib/python3.12/site-packages/mcp/server/streamable_http.py", line 831, in message_router
async for session_message in write_stream_reader:
File "/home/mohanlaksh/.venv/mcpgateway/lib/python3.12/site-packages/anyio/abc/_streams.py", line 41, in anext
return await self.receive()
^^^^^^^^^^^^^^^^^^^^
File "/home/mohanlaksh/.venv/mcpgateway/lib/python3.12/site-packages/anyio/streams/memory.py", line 111, in receive
return self.receive_nowait()
^^^^^^^^^^^^^^^^^^^^^
File "/home/mohanlaksh/.venv/mcpgateway/lib/python3.12/site-packages/anyio/streams/memory.py", line 93, in receive_nowait
raise ClosedResourceError
anyio.ClosedResourceError
2025-08-21 08:56:11,451 - uvicorn.access - INFO - 127.0.0.1:60360 - "GET /admin/servers/ed196d49fa624d778cb3b4a8e2a2d12d HTTP/1.1" 401
[2025-08-21 09:29:11 +0000] [1745] [INFO] Handling signal: winch


🧠 Environment Info

You can retrieve most of this from the /version endpoint.

Key Value
Version or commit v0.5.0
Runtime Python 3.12.3
Platform / OS Ubuntu 22.04
Container none

🧩 Additional Context (optional)

Add any configuration details, flags, or related issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions