[Bug]: MCP Server returns "'str' object has no attribute 'get'" with anyio.ClosedResourceError in v0.26.3 #16624
qweAzxc912
started this conversation in
General
Replies: 1 comment
|
I got the same issue and it was fixed when switching to v0.26.4. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Self Checks
I have searched for existing issues, including closed ones.
I confirm that I am using English to submit this report.
I have not modified this template and have filled in all required fields.
RAGFlow workspace code commit ID
32c5cb1 (v0.26.3 tag)
RAGFlow image version
infiniflow/ragflow:v0.26.3
Other environment information
OS: Windows 11 Pro (WSL2 Ubuntu 24.04.4 LTS)
Kernel: 6.6.114.1
Docker version: 29.6.0
Docker Compose version: v5.1.4
CPU: Intel Core i5-14400F
GPU: NVIDIA GeForce RTX 4060 Ti (8GB)
Deployment: Docker Compose with GPU profile
Actual behavior
MCP Server starts successfully (logs show Uvicorn running on http://0.0.0.0:9382), but when a client sends a tools/list request, the server returns an internal error:
Client response:
json
{"jsonrpc":"2.0","id":1,"error":{"code":0,"message":"'str' object has no attribute 'get'"}}
Server-side error log:
text
ERROR:mcp.server.streamable_http:Error in message router
Traceback (most recent call last):
File "/ragflow/.venv/lib/python3.13/site-packages/mcp/server/streamable_http.py", line 831, in message_router
async for session_message in write_stream_reader:
...<45 lines>...
)
File "/ragflow/.venv/lib/python3.13/site-packages/anyio/abc/_streams.py", line 41, in anext
return await self.receive()
^^^^^^^^^^^^^^^^^^^^
File "/ragflow/.venv/lib/python3.13/site-packages/anyio/streams/memory.py", line 117, in receive
return self.receive_nowait()
~~~~~~~~~~~~~~~~~~~^^
File "/ragflow/.venv/lib/python3.13/site-packages/anyio/streams/memory.py", line 99, in receive_nowait
raise ClosedResourceError
anyio.ClosedResourceError
MCP Server startup log:
text
MCP launch mode: self-host
MCP host: 0.0.0.0
MCP port: 9382
MCP base_url: http://ragflow-gpu:9380
SSE transport enabled: yes
SSE endpoint available at /sse
Streamable HTTP transport enabled: yes
Streamable HTTP endpoint available at /mcp
Streamable HTTP mode: JSON response enabled
INFO: Started server process [1]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:9382 (Press CTRL+C to quit)
Expected behavior
MCP Server should properly handle tools/list requests and return the list of available tools, as described in the official MCP server documentation.
Steps to reproduce
yaml
ragflow-mcp:
depends_on:
ragflow-gpu:
condition: service_started
image: infiniflow/ragflow:v0.26.3
profiles:
- gpu
entrypoint: python
command:
- /ragflow/mcp/server/server.py
- --mode=self-host
- --base-url=http://ragflow-gpu:9380
- --host=0.0.0.0
- --port=9382
- --api-key=ragflow-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ports:
- 9392:9382
networks:
- ragflow
restart: unless-stopped
2. Start the services:
bash
COMPOSE_PROFILES=gpu,elasticsearch docker compose up -d
3. Send a tools/list request:
bash
curl -X POST http://localhost:9392/mcp
-H "api_key: ragflow-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
-H "Content-Type: application/json"
-H "Accept: application/json, text/event-stream"
-d '{"jsonrpc":"2.0","method":"tools/list","id":1}'
4. Check MCP Server logs:
bash
docker logs docker-ragflow-mcp-1
Additional information
This issue does not affect the main RAGFlow services (Web UI on port 8090, API on port 9388, Admin on port 9389). All core services work correctly.
The MCP Server is started directly via python /ragflow/mcp/server/server.py with the correct parameters (--base-url, --host, --port, --mode, --api-key), not via entrypoint.sh with --enable-mcpserver. Previous discussions (#9365, #7445) have clarified that --enable-mcpserver and --mcp-* arguments are not valid for server.py.
The anyio.ClosedResourceError suggests a problem with the streamable HTTP transport implementation in the MCP Python SDK or its integration with RAGFlow.
Related issues: #7249, #7321, #9365, #10982
Configuration Details
Hermes MCP client configuration (~/.hermes/config.yaml):
yaml
mcp_servers:
ragflow:
url: http://localhost:9392/mcp
headers:
api_key: ragflow-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Accept: application/json, text/event-stream
timeout: 300
connect_timeout: 120
Thanks in advance!
All reactions