anyio.BrokenResourceError when Saving Memory via SSE from Claude Desktop
🐛 Describe the bug
I'm experiencing an anyio.BrokenResourceError when attempting to save a memory from Claude Desktop using the SSE endpoint of the OpenMemory MCP server.
Environment:
- Claude Desktop Version: 0.1.0
-
OpenMemory MCP Server Version: [Please specify, e.g., latest from
mainbranch] - Python Version: 3.12
- Operating System: [e.g., Windows 11 / macOS 14 / Ubuntu 22.04]
- Docker: [Yes/No]([Latenode Official Community][1])
Steps to Reproduce:
- Start the OpenMemory MCP server.
- Launch Claude Desktop and connect it to the MCP server via the SSE endpoint.
- Attempt to save a memory (e.g., using the
add_memoriestool). - Observe the server logs for errors.([Reddit][2])
Observed Behavior:
The server logs the following traceback:
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/anyio/streams/memory.py", line 213, in send_nowait
raise BrokenResourceError
anyio.BrokenResourceError
This error occurs during the execution of handle_post_message in the sse.py module:
await writer.send(session_message)
Expected Behavior:
The memory should be saved successfully without any exceptions, and the server should handle the SSE communication gracefully.
I am having similar issue. The memory basiccally fails to save because it times out. The mcp logs:
| File "/usr/local/lib/python3.12/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
| return await dependant.call(**values)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/usr/src/openmemory/app/mcp_server.py", line 339, in handle_sse
| async with sse.connect_sse(
| ^^^^^^^^^^^^^^^^
| File "/usr/local/lib/python3.12/contextlib.py", line 231, in __aexit__
| await self.gen.athrow(value)
| File "/usr/local/lib/python3.12/site-packages/mcp/server/sse.py", line 128, in connect_sse
| async with anyio.create_task_group() as tg:
| ^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/usr/local/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__
| raise BaseExceptionGroup(
| ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
+-+---------------- 1 ----------------
| Exception Group Traceback (most recent call last):
| File "/usr/local/lib/python3.12/site-packages/mcp/server/sse.py", line 147, in connect_sse
| yield (read_stream, write_stream)
| File "/usr/src/openmemory/app/mcp_server.py", line 344, in handle_sse
| await mcp._mcp_server.run(
| File "/usr/local/lib/python3.12/site-packages/mcp/server/lowlevel/server.py", line 489, in run
| async with AsyncExitStack() as stack:
| ^^^^^^^^^^^^^^^^
| File "/usr/local/lib/python3.12/contextlib.py", line 754, in __aexit__
| raise exc_details[1]
| File "/usr/local/lib/python3.12/contextlib.py", line 737, in __aexit__
| cb_suppress = await cb(*exc_details)
| ^^^^^^^^^^^^^^^^^^^^^^
| File "/usr/local/lib/python3.12/site-packages/mcp/shared/session.py", line 209, in __aexit__
| return await self._task_group.__aexit__(exc_type, exc_val, exc_tb)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/usr/local/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__
| raise BaseExceptionGroup(
| ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
+-+---------------- 1 ----------------
| Traceback (most recent call last):
| File "/usr/local/lib/python3.12/site-packages/mcp/server/session.py", line 146, in _receive_loop
| await super()._receive_loop()
| File "/usr/local/lib/python3.12/site-packages/mcp/shared/session.py", line 348, in _receive_loop
| await self._received_request(responder)
| File "/usr/local/lib/python3.12/site-packages/mcp/server/session.py", line 171, in _received_request
| raise RuntimeError(
| RuntimeError: Received request before initialization was complete
+------------------------------------
INFO: 192.168.65.1:62866 - "GET /mcp/claude/sse/Martin HTTP/1.1" 200 OK
I have had a similar issue, but with Claude Code. Another thread said that it might be related to an MCP version mismatch. I haven't checked the version that Claude is on directly, but someone said it was a version from 2024. I have had some success by using supergateway to do a conversion between versions, but it is spotty at best. I'll get some documents saved, but others just flake out.
"openmemory": { "command": "npx", "args": ["-y", "supergateway", "--sse", "http://localhost:8765/mcp/claude/sse/<user>", "--outputTransport", "stdio"], "env": {} }