Fix mcp server startup failure (#7329)

### What problem does this PR solve?
0.18.0 mcp server can not start with upgrade from 0.17.2 or new install
except rebuild all docker

Close #7321

mcp server can not start auto from docker :
2025-04-25 17:30:44,512 INFO 25 task_executor_2a9f3e2de99a_0 reported
heartbeat: {"name": "task_executor_2a9f3e2de99a_0", "now":
"2025-04-25T17:30:44.509+08:00", "boot_at":
"2025-04-25T16:43:33.038+08:00", "pending": 0, "lag": 0, "done": 0,
"failed": 0, "current": {}}
usage: server.py [-h] [--base_url BASE_URL] [--host HOST] [--port PORT]
                 [--mode MODE] [--api_key API_KEY]
server.py: error: unrecognized arguments:

problem:
server.py in docker start arguments not correct , so mcp server start
fail
reason:
```
1. docker-copose.yaml
     example  - --mcp-host-api-key="ragflow-12345678" is wrong.  do not add "" to key or it says:"api-key wrong"
2.docker file  entrypoint.sh  can not translate config to exec command , we need mapping file from host to docker
     - ./entrypoint.sh:/ragflow/entrypoint.sh
3.just add one code raw fix all probelm 
```
### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
- [x] Documentation Update
- [x] Performance Improvement

---------

Co-authored-by: Yongteng Lei <yongtengrey@outlook.com>
Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
This commit is contained in:
yiminghub2024 2025-04-27 18:47:12 +08:00 committed by GitHub
parent 969c596d4c
commit 1aa97600df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 4 deletions

3
.gitattributes vendored
View File

@ -1 +1,2 @@
*.sh text eol=lf
*.sh text eol=lf
docker/entrypoint.sh text eol=lf executable

View File

@ -32,6 +32,7 @@ services:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ../history_data_agent:/ragflow/history_data_agent
- ./service_conf.yaml.template:/ragflow/conf/service_conf.yaml.template
- ./entrypoint.sh:/ragflow/entrypoint.sh
env_file: .env
environment:

0
docker/entrypoint.sh Normal file → Executable file
View File

View File

@ -63,7 +63,7 @@ Here are three augments required, the first two,`host` and `port`, are self-expl
Building a standalone MCP server image is straightforward and easy, so we just proposed a way to launch it with RAGFlow server here.
#### Alongside RAGFlow
#### Alongside RAGFlow {#alongside_ragflow}
As MCP server is an extra and optional component of RAGFlow server, we consume that not everybody going to use it. Thus, it is disable by default.
To enable it, simply find `docker/docker-compose.yml` to uncomment `services.ragflow.command` section.
@ -81,10 +81,26 @@ services:
- --mcp-base-url=http://127.0.0.1:9380
- --mcp-script-path=/ragflow/mcp/server/server.py
- --mcp-mode=self-host # `self-host` or `host`
- --mcp-host-api-key="ragflow-xxxxxxx" # only need to privide when mode is `self-host`
- --mcp-host-api-key=ragflow-xxxxxxx # only need to privide when mode is `self-host` and use bare string without quotation marks here.
```
Then launch it normally `docker compose -f docker-compose.yml`.
To troubleshoot, launch the service in the foreground using `docker compose -f docker-compose.yml`.
### For those upgrading from versions before v0.18.0
1. Get all MCP related files ready.
1. copy `mcp/` directory to local.
1. copy `docker/docker-compose.yml` to local.
1. copy `docker/entrypoint.sh` to local.
1. resolve necessary dependencies via `uv`.
- simply run `uv add mcp` if it works for you. Or:
- copy `pyproject.toml` and run `uv sync --python 3.10 --all-extras`.
1. Change `docker-compose.yml` to enable MCP as it is disable by default, [see last section](#alongside_ragflow).
1. Launch the service with `docker compose -f docker-compose.yml up -d`
### Check the MCP server status
Checking logs of RAGFlow server with `docker logs ragflow-server`. If you see the MCP server ASCII art there, it means all is OK!
```bash
ragflow-server | Starting MCP Server on 0.0.0.0:9382 with base URL http://127.0.0.1:9380...