mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-16 02:46:02 +08:00
Docs: Initial editorial pass to MCP server (#7359)
### What problem does this PR solve? ### Type of change - [x] Documentation Update
This commit is contained in:
parent
9849230a04
commit
87317bcfc4
@ -8,7 +8,7 @@ services:
|
||||
mysql:
|
||||
condition: service_healthy
|
||||
image: ${RAGFLOW_IMAGE}
|
||||
# example to setup MCP server
|
||||
# Example configuration to set up an MCP server:
|
||||
# command:
|
||||
# - --enable-mcpserver
|
||||
# - --mcp-host=0.0.0.0
|
||||
@ -16,7 +16,7 @@ services:
|
||||
# - --mcp-base-url=http://127.0.0.1:9380
|
||||
# - --mcp-script-path=/ragflow/mcp/server/server.py
|
||||
# - --mcp-mode=self-host
|
||||
# - --mcp-host-api-key="ragflow-xxxxxxx"
|
||||
# - --mcp-host-api-key=ragflow-xxxxxxx
|
||||
container_name: ragflow-server
|
||||
ports:
|
||||
- ${SVR_HTTP_PORT}:9380
|
||||
@ -24,7 +24,7 @@ services:
|
||||
- 443:443
|
||||
- 5678:5678
|
||||
- 5679:5679
|
||||
- 9382:9382 # entry for MCP (host_port:docker_port). The docker_port should match with the value you set for `mcp-port` above
|
||||
- 9382:9382 # entry for MCP (host_port:docker_port). The docker_port must match the value you set for `mcp-port` above.
|
||||
volumes:
|
||||
- ./ragflow-logs:/ragflow/logs
|
||||
- ./nginx/ragflow.conf:/etc/nginx/conf.d/ragflow.conf
|
||||
@ -43,7 +43,7 @@ services:
|
||||
- ragflow
|
||||
restart: on-failure
|
||||
# https://docs.docker.com/engine/daemon/prometheus/#create-a-prometheus-configuration
|
||||
# If you're using Docker Desktop, the --add-host flag is optional. This flag makes sure that the host's internal IP gets exposed to the Prometheus container.
|
||||
# If you use Docker Desktop, the --add-host flag is optional. This flag ensures that the host's internal IP is exposed to the Prometheus container.
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
# executor:
|
||||
|
@ -180,7 +180,7 @@ The callback URL should be configured in your OAuth provider as:
|
||||
https://your-app.com/oauth/callback/<channel>
|
||||
```
|
||||
|
||||
For detailed instructions on configuring **service_conf.yaml.template**, please refer to [Usage](../api/apps/auth/README.md#usage).
|
||||
For detailed instructions on configuring **service_conf.yaml.template**, please refer to [Usage](https://github.com/infiniflow/ragflow/blob/main/api/apps/auth/README.md#usage).
|
||||
|
||||
### `user_default_llm`
|
||||
|
||||
|
@ -5,7 +5,7 @@ slug: /acquire_ragflow_api_key
|
||||
|
||||
# Acquire RAGFlow API key
|
||||
|
||||
A key is required for the RAGFlow server to authenticate your requests via HTTP or a Python API. This documents provides instructions on obtaining a RAGFlow API key.
|
||||
An API key is required for the RAGFlow server to authenticate your HTTP/Python or MCP requests. This documents provides instructions on obtaining a RAGFlow API key.
|
||||
|
||||
1. Click your avatar in the top right corner of the RAGFlow UI to access the configuration page.
|
||||
2. Click **API** to switch to the **API** page.
|
||||
|
202
docs/develop/launch_mcp_server.md
Normal file
202
docs/develop/launch_mcp_server.md
Normal file
@ -0,0 +1,202 @@
|
||||
---
|
||||
sidebar_position: 4
|
||||
slug: /launch_mcp_server
|
||||
---
|
||||
|
||||
# Launch RAGFlow MCP server
|
||||
|
||||
Launch an MCP server from source or via Docker.
|
||||
|
||||
---
|
||||
|
||||
A RAGFlow Model Context Protocol (MCP) server is designed as an independent component to complement the RAGFlow server. Note that an MCP server must operate alongside a properly functioning RAGFlow server.
|
||||
|
||||
An MCP server can start up in either self-host mode (default) or host mode:
|
||||
|
||||
- **Self-host mode**:
|
||||
When launching an MCP server in self-host mode, you must provide an API key to authenticate the MCP server with the RAGFlow server. In this mode, the MCP server can access *only* the datasets (knowledge bases) of a specified tenant on the RAGFlow server.
|
||||
- **Host mode**:
|
||||
In host mode, each MCP client can access their own knowledge bases on the RAGFlow server. However, each client request must include a valid API key to authenticate the client with the RAGFlow server.
|
||||
|
||||
Once a connection is established, an MCP server communicates with its client in MCP HTTP+SSE (Server-Sent Events) mode, unidirectionally pushing responses from the RAGFlow server to its client in real time.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. Ensure RAGFlow is upgraded to v0.18.0 or later.
|
||||
2. Have your RAGFlow API key ready. See [Acquire a RAGFlow API key](./acquire_ragflow_api_key.md).
|
||||
|
||||
:::tip INFO
|
||||
If you wish to try out our MCP server without upgrading RAGFlow, community contributor **yiminghub2024** 👏 shares their recommended steps [here](#launch-an-mcp-server-without-upgrading-ragflow).
|
||||
::
|
||||
|
||||
## Launch an MCP server
|
||||
|
||||
You can start an MCP server either from source code or via Docker.
|
||||
|
||||
### Launch from source code
|
||||
|
||||
1. Ensure that a RAGFlow server v0.18.0+ is properly running.
|
||||
2. Launch the MCP server:
|
||||
|
||||
|
||||
```bash
|
||||
# Launch the MCP server to work in self-host mode, run either of the following
|
||||
uv run mcp/server/server.py --host=127.0.0.1 --port=9382 --base_url=http://127.0.0.1:9380 --api_key=ragflow-xxxxx
|
||||
# uv run mcp/server/server.py --host=127.0.0.1 --port=9382 --base_url=http://127.0.0.1:9380 mode=self-host --api_key=ragflow-xxxxx
|
||||
|
||||
# To launch the MCP server to work in host mode, run the following instead:
|
||||
# uv run mcp/server/server.py --host=127.0.0.1 --port=9382 --base_url=http://127.0.0.1:9380 mode=host
|
||||
```
|
||||
|
||||
Where:
|
||||
|
||||
- `host`: The MCP server's host address.
|
||||
- `port`: The MCP server's listening port.
|
||||
- `base_url`**: The address of the running RAGFlow server.
|
||||
- `mode`: The launch mode.
|
||||
- `self-host`: (default) self-host mode.
|
||||
- `host`: host mode.
|
||||
- `api_key`: Required in self-host mode to authenticate the MCP server with the RAGFlow server.
|
||||
|
||||
### Launch from Docker
|
||||
|
||||
#### 1. Enable MCP server
|
||||
|
||||
The MCP server is designed as an optional, component that complements the RAGFlow server and is disable by default. To enable MCP server:
|
||||
|
||||
1. Navigate to `docker/docker-compose.yml`.
|
||||
2. Uncomment the `services.ragflow.command` section as shown below:
|
||||
|
||||
```yaml {6-13}
|
||||
services:
|
||||
ragflow:
|
||||
...
|
||||
image: ${RAGFLOW_IMAGE}
|
||||
# Example configuration to set up an MCP server:
|
||||
command:
|
||||
- --enable-mcpserver
|
||||
- --mcp-host=0.0.0.0
|
||||
- --mcp-port=9382
|
||||
- --mcp-base-url=http://127.0.0.1:9380
|
||||
- --mcp-script-path=/ragflow/mcp/server/server.py
|
||||
- --mcp-mode=self-host
|
||||
- --mcp-host-api-key=ragflow-xxxxxxx
|
||||
```
|
||||
|
||||
Where:
|
||||
|
||||
- `mcp-host`: The MCP server's host address.
|
||||
- `mcp-port`: The MCP server's listening port.
|
||||
- `mcp-base_url`: The address of the running RAGFlow server.
|
||||
- `mcp-script-path`: The file path to the MCP server’s main script.
|
||||
- `mcp-mode`: The launch mode.
|
||||
- `self-host`: (default) self-host mode.
|
||||
- `host`: host mode.
|
||||
- `mcp-host-api_key`: Required in self-host mode to authenticate the MCP server with the RAGFlow server.
|
||||
|
||||
#### 2. Launch a RAGFlow server alongside an MCP server
|
||||
|
||||
Run `docker compose -f docker-compose.yml` to launch the RAGFlow server together with the MCP server.
|
||||
|
||||
*The following ASCII art confirms a successful launch:*
|
||||
|
||||
```bash
|
||||
ragflow-server | Starting MCP Server on 0.0.0.0:9382 with base URL http://127.0.0.1:9380...
|
||||
ragflow-server | Starting 1 task executor(s) on host 'dd0b5e07e76f'...
|
||||
ragflow-server | 2025-04-18 15:41:18,816 INFO 27 ragflow_server log path: /ragflow/logs/ragflow_server.log, log levels: {'peewee': 'WARNING', 'pdfminer': 'WARNING', 'root': 'INFO'}
|
||||
ragflow-server |
|
||||
ragflow-server | __ __ ____ ____ ____ _____ ______ _______ ____
|
||||
ragflow-server | | \/ |/ ___| _ \ / ___|| ____| _ \ \ / / ____| _ \
|
||||
ragflow-server | | |\/| | | | |_) | \___ \| _| | |_) \ \ / /| _| | |_) |
|
||||
ragflow-server | | | | | |___| __/ ___) | |___| _ < \ V / | |___| _ <
|
||||
ragflow-server | |_| |_|\____|_| |____/|_____|_| \_\ \_/ |_____|_| \_\
|
||||
ragflow-server |
|
||||
ragflow-server | MCP launch mode: self-host
|
||||
ragflow-server | MCP host: 0.0.0.0
|
||||
ragflow-server | MCP port: 9382
|
||||
ragflow-server | MCP base_url: http://127.0.0.1:9380
|
||||
ragflow-server | INFO: Started server process [26]
|
||||
ragflow-server | INFO: Waiting for application startup.
|
||||
ragflow-server | INFO: Application startup complete.
|
||||
ragflow-server | INFO: Uvicorn running on http://0.0.0.0:9382 (Press CTRL+C to quit)
|
||||
ragflow-server | 2025-04-18 15:41:20,469 INFO 27 found 0 gpus
|
||||
ragflow-server | 2025-04-18 15:41:23,263 INFO 27 init database on cluster mode successfully
|
||||
ragflow-server | 2025-04-18 15:41:25,318 INFO 27 load_model /ragflow/rag/res/deepdoc/det.onnx uses CPU
|
||||
ragflow-server | 2025-04-18 15:41:25,367 INFO 27 load_model /ragflow/rag/res/deepdoc/rec.onnx uses CPU
|
||||
ragflow-server | ____ ___ ______ ______ __
|
||||
ragflow-server | / __ \ / | / ____// ____// /____ _ __
|
||||
ragflow-server | / /_/ // /| | / / __ / /_ / // __ \| | /| / /
|
||||
ragflow-server | / _, _// ___ |/ /_/ // __/ / // /_/ /| |/ |/ /
|
||||
ragflow-server | /_/ |_|/_/ |_|\____//_/ /_/ \____/ |__/|__/
|
||||
ragflow-server |
|
||||
ragflow-server |
|
||||
ragflow-server | 2025-04-18 15:41:29,088 INFO 27 RAGFlow version: v0.18.0-285-gb2c299fa full
|
||||
ragflow-server | 2025-04-18 15:41:29,088 INFO 27 project base: /ragflow
|
||||
ragflow-server | 2025-04-18 15:41:29,088 INFO 27 Current configs, from /ragflow/conf/service_conf.yaml:
|
||||
ragflow-server | ragflow: {'host': '0.0.0.0', 'http_port': 9380}
|
||||
...
|
||||
ragflow-server | * Running on all addresses (0.0.0.0)
|
||||
ragflow-server | * Running on http://127.0.0.1:9380
|
||||
ragflow-server | * Running on http://172.19.0.6:9380
|
||||
ragflow-server | ______ __ ______ __
|
||||
ragflow-server | /_ __/___ ______/ /__ / ____/ _____ _______ __/ /_____ _____
|
||||
ragflow-server | / / / __ `/ ___/ //_/ / __/ | |/_/ _ \/ ___/ / / / __/ __ \/ ___/
|
||||
ragflow-server | / / / /_/ (__ ) ,< / /____> </ __/ /__/ /_/ / /_/ /_/ / /
|
||||
ragflow-server | /_/ \__,_/____/_/|_| /_____/_/|_|\___/\___/\__,_/\__/\____/_/
|
||||
ragflow-server |
|
||||
ragflow-server | 2025-04-18 15:41:34,501 INFO 32 TaskExecutor: RAGFlow version: v0.18.0-285-gb2c299fa full
|
||||
ragflow-server | 2025-04-18 15:41:34,501 INFO 32 Use Elasticsearch http://es01:9200 as the doc engine.
|
||||
...
|
||||
```
|
||||
|
||||
#### Launch an MCP server without upgrading RAGFlow
|
||||
|
||||
:::tip KUDOS-TO
|
||||
This section is contributed by our community contributor **yiminghub2024**. 👏
|
||||
:::
|
||||
|
||||
1. Prepare all MCP-specific files and directories.
|
||||
i. Copy the [mcp/](https://github.com/infiniflow/ragflow/tree/main/mcp) directory to your local working directory.
|
||||
ii. Copy [docker/docker-compose.yml](https://github.com/infiniflow/ragflow/blob/main/docker/docker-compose.yml) locally.
|
||||
iii. Copy [docker/entrypoint.sh](https://github.com/infiniflow/ragflow/blob/main/docker/entrypoint.sh) locally.
|
||||
iv. Install required dependencies using `uv`:
|
||||
- Run `uv add mcp` or
|
||||
- Copy pyproject.toml and run `uv sync --python 3.10 --all-extras`.
|
||||
2. Edit **docker-compose.yml** to enable MCP (disable by default).
|
||||
3. Launch the MCP server:
|
||||
|
||||
```bash
|
||||
docker compose -f docker-compose.yml up -d`
|
||||
```
|
||||
|
||||
### Check MCP server status
|
||||
|
||||
Run the following to check the logs the RAGFlow server and the MCP server:
|
||||
|
||||
```bash
|
||||
docker logs ragflow-server
|
||||
```
|
||||
|
||||
## MCP client example
|
||||
|
||||
We provide a *prototype* MCP client example for testing [here](https://github.com/infiniflow/ragflow/blob/main/mcp/client/client.py).
|
||||
|
||||
:::danger IMPORTANT
|
||||
If your MCP server is running in host mode, include your acquired API key in your client's `headers` as shown below:
|
||||
```python
|
||||
async with sse_client("http://localhost:9382/sse", headers={"api_key": "YOUR_KEY_HERE"}) as streams:
|
||||
# Rest of your code...
|
||||
```
|
||||
:::
|
||||
|
||||
## API
|
||||
|
||||
The MCP server currently offers an API to assist users in searching for relevant information powered by RAGFlow DeepDoc technology:
|
||||
|
||||
- **retrieve**: Fetches relevant chunks from specified `dataset_ids` and optional `document_ids` using the RAGFlow retrieve interface, based on a given question. Details of all available datasets, namely, `id` and `description`, are provided within the tool description for each individual dataset.
|
||||
|
||||
## Security considerations
|
||||
|
||||
As MCP technology is still at early stage and no official best practices for authentication or authorization have been established, RAGFlow currently uses [API key](./acquire_ragflow_api_key.md) to validate identity for the operations described earlier. However, in public environments, this makeshift solution could expose your MCP server to potential network attacks. Therefore, when running a local SSE server, it is recommended to bind only to localhost (`127.0.0.1`) rather than to all interfaces (`0.0.0.0`).
|
||||
|
||||
For further guidance, see the [official MCP documentation](https://modelcontextprotocol.io/docs/concepts/transports#security-considerations).
|
@ -1,230 +0,0 @@
|
||||
---
|
||||
sidebar_position: 4
|
||||
slug: /mcp_server
|
||||
---
|
||||
|
||||
# RAGFlow MCP server overview
|
||||
|
||||
The RAGFlow Model Context Protocol (MCP) server operates as an independent component that complements the RAGFlow server. However, it requires a RAGFlow server to work functionally well, meaning, the MCP client and server communicate with each other in MCP HTTP+SSE mode (once the connection is established, server pushes messages to client only), and responses are expected from RAGFlow server.
|
||||
|
||||
The MCP server currently offers a specific tool to assist users in searching for relevant information powered by RAGFlow DeepDoc technology:
|
||||
|
||||
- **retrieve**: Fetches relevant chunks from specified `dataset_ids` and optional `document_ids` using the RAGFlow retrieve interface, based on a given question. Details of all available datasets, namely, `id` and `description`, are provided within the tool description for each individual dataset.
|
||||
|
||||
## Launching the MCP Server
|
||||
|
||||
Similar to launching the RAGFlow server, the MCP server can be started either from source code or via Docker.
|
||||
|
||||
### Launch Modes
|
||||
|
||||
The MCP server supports two launch modes:
|
||||
|
||||
1. **Self-Host Mode**:
|
||||
|
||||
- In this mode, the MCP server is launched to access a specific tenant's datasets.
|
||||
- This is the default mode.
|
||||
- The `--api_key` argument is **required** to authenticate the server with the RAGFlow server.
|
||||
- Example:
|
||||
```bash
|
||||
uv run mcp/server/server.py --host=127.0.0.1 --port=9382 --base_url=http://127.0.0.1:9380 --mode=self-host --api_key=ragflow-xxxxx
|
||||
```
|
||||
|
||||
1. **Host Mode**:
|
||||
|
||||
- In this mode, the MCP server allows each user to access their own datasets.
|
||||
- To ensure secure access, a valid API key must be included in the request headers to identify the user.
|
||||
- The `--api_key` argument is **not required** during server launch but must be provided in the headers on each client request for user authentication.
|
||||
- Example:
|
||||
```bash
|
||||
uv run mcp/server/server.py --host=127.0.0.1 --port=9382 --base_url=http://127.0.0.1:9380 --mode=host
|
||||
```
|
||||
|
||||
### Launching from Source Code
|
||||
|
||||
All you need to do is stand on the right place and strike out command, assuming you are on the project working directory.
|
||||
|
||||
```bash
|
||||
uv run mcp/server/server.py --host=127.0.0.1 --port=9382 --base_url=http://127.0.0.1:9380 --api_key=ragflow-xxxxx
|
||||
```
|
||||
|
||||
For testing purposes, there is an [MCP client example](#example_mcp_client) provided, free to take!
|
||||
|
||||
#### Required Arguments
|
||||
|
||||
- **`host`**: Specifies the server's host address.
|
||||
- **`port`**: Defines the server's listening port.
|
||||
- **`base_url`**: The address of the RAGFlow server that is already running and ready to handle tasks.
|
||||
- **`mode`**: Launch mode, only accept `self-host` or `host`.
|
||||
- **`api_key`**: Required when `mode` is `self-host` to authenticate the MCP server with the RAGFlow server.
|
||||
|
||||
Here are three augments required, the first two,`host` and `port`, are self-explained. The`base_url` is the address of the ready-to-serve RAGFlow server to actually perform the task.
|
||||
|
||||
### Launching from Docker
|
||||
|
||||
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}
|
||||
|
||||
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.
|
||||
|
||||
```yaml
|
||||
services:
|
||||
ragflow:
|
||||
...
|
||||
image: ${RAGFLOW_IMAGE}
|
||||
# example to setup MCP server
|
||||
command:
|
||||
- --enable-mcpserver
|
||||
- --mcp-host=0.0.0.0
|
||||
- --mcp-port=9382
|
||||
- --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` and use bare string without quotation marks here.
|
||||
```
|
||||
|
||||
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...
|
||||
ragflow-server | Starting 1 task executor(s) on host 'dd0b5e07e76f'...
|
||||
ragflow-server | 2025-04-18 15:41:18,816 INFO 27 ragflow_server log path: /ragflow/logs/ragflow_server.log, log levels: {'peewee': 'WARNING', 'pdfminer': 'WARNING', 'root': 'INFO'}
|
||||
ragflow-server |
|
||||
ragflow-server | __ __ ____ ____ ____ _____ ______ _______ ____
|
||||
ragflow-server | | \/ |/ ___| _ \ / ___|| ____| _ \ \ / / ____| _ \
|
||||
ragflow-server | | |\/| | | | |_) | \___ \| _| | |_) \ \ / /| _| | |_) |
|
||||
ragflow-server | | | | | |___| __/ ___) | |___| _ < \ V / | |___| _ <
|
||||
ragflow-server | |_| |_|\____|_| |____/|_____|_| \_\ \_/ |_____|_| \_\
|
||||
ragflow-server |
|
||||
ragflow-server | MCP launch mode: self-host
|
||||
ragflow-server | MCP host: 0.0.0.0
|
||||
ragflow-server | MCP port: 9382
|
||||
ragflow-server | MCP base_url: http://127.0.0.1:9380
|
||||
ragflow-server | INFO: Started server process [26]
|
||||
ragflow-server | INFO: Waiting for application startup.
|
||||
ragflow-server | INFO: Application startup complete.
|
||||
ragflow-server | INFO: Uvicorn running on http://0.0.0.0:9382 (Press CTRL+C to quit)
|
||||
ragflow-server | 2025-04-18 15:41:20,469 INFO 27 found 0 gpus
|
||||
ragflow-server | 2025-04-18 15:41:23,263 INFO 27 init database on cluster mode successfully
|
||||
ragflow-server | 2025-04-18 15:41:25,318 INFO 27 load_model /ragflow/rag/res/deepdoc/det.onnx uses CPU
|
||||
ragflow-server | 2025-04-18 15:41:25,367 INFO 27 load_model /ragflow/rag/res/deepdoc/rec.onnx uses CPU
|
||||
ragflow-server | ____ ___ ______ ______ __
|
||||
ragflow-server | / __ \ / | / ____// ____// /____ _ __
|
||||
ragflow-server | / /_/ // /| | / / __ / /_ / // __ \| | /| / /
|
||||
ragflow-server | / _, _// ___ |/ /_/ // __/ / // /_/ /| |/ |/ /
|
||||
ragflow-server | /_/ |_|/_/ |_|\____//_/ /_/ \____/ |__/|__/
|
||||
ragflow-server |
|
||||
ragflow-server |
|
||||
ragflow-server | 2025-04-18 15:41:29,088 INFO 27 RAGFlow version: v0.18.0-285-gb2c299fa full
|
||||
ragflow-server | 2025-04-18 15:41:29,088 INFO 27 project base: /ragflow
|
||||
ragflow-server | 2025-04-18 15:41:29,088 INFO 27 Current configs, from /ragflow/conf/service_conf.yaml:
|
||||
ragflow-server | ragflow: {'host': '0.0.0.0', 'http_port': 9380}
|
||||
...
|
||||
ragflow-server | * Running on all addresses (0.0.0.0)
|
||||
ragflow-server | * Running on http://127.0.0.1:9380
|
||||
ragflow-server | * Running on http://172.19.0.6:9380
|
||||
ragflow-server | ______ __ ______ __
|
||||
ragflow-server | /_ __/___ ______/ /__ / ____/ _____ _______ __/ /_____ _____
|
||||
ragflow-server | / / / __ `/ ___/ //_/ / __/ | |/_/ _ \/ ___/ / / / __/ __ \/ ___/
|
||||
ragflow-server | / / / /_/ (__ ) ,< / /____> </ __/ /__/ /_/ / /_/ /_/ / /
|
||||
ragflow-server | /_/ \__,_/____/_/|_| /_____/_/|_|\___/\___/\__,_/\__/\____/_/
|
||||
ragflow-server |
|
||||
ragflow-server | 2025-04-18 15:41:34,501 INFO 32 TaskExecutor: RAGFlow version: v0.18.0-285-gb2c299fa full
|
||||
ragflow-server | 2025-04-18 15:41:34,501 INFO 32 Use Elasticsearch http://es01:9200 as the doc engine.
|
||||
...
|
||||
```
|
||||
|
||||
You are ready to brew🍺!
|
||||
|
||||
#### Getting API Keys for Host Mode
|
||||
|
||||
When running the MCP server in `host` mode (by setting `--mcp-mode=host` in the configuration), each client needs to provide their own API key in requests. This API key is **different** from the `--mcp-host-api-key` specified in the server configuration.
|
||||
|
||||
To get a valid API key for use in your client scripts (like `test_mcp.py`):
|
||||
|
||||
1. Access the RAGFlow UI in your browser (typically `http://localhost:9380`)
|
||||
2. Log in to your account
|
||||
3. Click on your avatar/profile in the top-right corner
|
||||
4. Select **API** from the dropdown menu
|
||||
5. On the API page, generate a new API key or copy an existing one
|
||||
6. Use this key in your client script as follows:
|
||||
|
||||
```python
|
||||
# Client script example (test_mcp.py)
|
||||
async with sse_client("http://localhost:9382/sse", headers={"api_key": "YOUR_KEY_HERE"}) as streams:
|
||||
# Rest of your code...
|
||||
```
|
||||
|
||||
## Testing and Usage
|
||||
|
||||
Typically, there are various ways to utilize an MCP server. You can integrate it with LLMs or use it as a standalone tool. You find the way.
|
||||
|
||||
### Example MCP Client {#example_mcp_client}
|
||||
|
||||
```python
|
||||
#
|
||||
# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
|
||||
from mcp.client.session import ClientSession
|
||||
from mcp.client.sse import sse_client
|
||||
|
||||
|
||||
async def main():
|
||||
try:
|
||||
# To access RAGFlow server in `host` mode, you need to attach `api_key` for each request to indicate identification.
|
||||
# async with sse_client("http://localhost:9382/sse", headers={"api_key": "ragflow-IyMGI1ZDhjMTA2ZTExZjBiYTMyMGQ4Zm"}) as streams:
|
||||
async with sse_client("http://localhost:9382/sse") as streams:
|
||||
async with ClientSession(
|
||||
streams[0],
|
||||
streams[1],
|
||||
) as session:
|
||||
await session.initialize()
|
||||
tools = await session.list_tools()
|
||||
print(f"{tools.tools=}")
|
||||
response = await session.call_tool(name="ragflow_retrieval", arguments={"dataset_ids": ["ce3bb17cf27a11efa69751e139332ced"], "document_ids": [], "question": "How to install neovim?"})
|
||||
print(f"Tool response: {response.model_dump()}")
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from anyio import run
|
||||
|
||||
run(main)
|
||||
```
|
||||
|
||||
## Security and Concerns
|
||||
|
||||
Since MCP technology is still in booming age and there are still no official Authentication and Authorization best practices to follow, RAGFlow uses `api_key` to validate the identification, and it is required to perform any operations mentioned in the preview section. Obviously, this is not a premium solution to do so, thus this RAGFlow MCP server is not expected to exposed to public use as it could be highly venerable to be attacked. For local SSE server, bind only to localhost (127.0.0.1) instead of all interfaces (0.0.0.0). For additional guidance, you can refer to [MCP official website](https://modelcontextprotocol.io/docs/concepts/transports#security-considerations).
|
@ -83,7 +83,7 @@ This toggle sets whether to cite the original text as reference.
|
||||
|
||||
|
||||
:::tip NOTE
|
||||
This feature is applicable *only* when the original documents are uploaded to a knowledge base and have finished file parsing.
|
||||
This feature applies *only* after the original documents have been uploaded to the corresponding knowledge base(s) and file parsing is complete.
|
||||
:::
|
||||
|
||||
### Message window size
|
||||
|
@ -89,4 +89,8 @@ Nope. The knowledge graph does *not* automatically update *until* a newly upload
|
||||
|
||||
### How to remove a generated knowledge graph?
|
||||
|
||||
To remove the generated knowledge graph, delete all related files in your knowledge base. Although the **Knowledge graph** entry will still be visible, the graph has actually been deleted.
|
||||
To remove the generated knowledge graph, delete all related files in your knowledge base. Although the **Knowledge graph** entry will still be visible, the graph has actually been deleted.
|
||||
|
||||
### Where is the created knowledge graph stored?
|
||||
|
||||
All chunks of the created knowledge graph are stored in RAGFlow's document engine: either Elasticsearch or [Infinity](https://github.com/infiniflow/infinity).
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
sidebar_position: 3
|
||||
sidebar_position: 5
|
||||
slug: /share_agent
|
||||
---
|
||||
|
||||
|
8
docs/guides/team/share_chat_assistant.md
Normal file
8
docs/guides/team/share_chat_assistant.md
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
sidebar_position: 4
|
||||
slug: /share_chat_assistant
|
||||
---
|
||||
|
||||
# Share chat assistant
|
||||
|
||||
Sharing chat assistant is currently exclusive to RAGFlow Enterprise, but will be made available in due course.
|
@ -1,8 +1,8 @@
|
||||
---
|
||||
sidebar_position: 3
|
||||
sidebar_position: 6
|
||||
slug: /share_model
|
||||
---
|
||||
|
||||
# Share models
|
||||
|
||||
Sharing models is available only on RAGFlow Enterprise!
|
||||
Sharing models is currently exclusive to RAGFlow Enterprise.
|
@ -855,7 +855,7 @@ curl --request PUT \
|
||||
- `"parser_config"`: (*Body parameter*), `object`
|
||||
The configuration settings for the dataset parser. The attributes in this JSON object vary with the selected `"chunk_method"`:
|
||||
- If `"chunk_method"` is `"naive"`, the `"parser_config"` object contains the following attributes:
|
||||
- `"chunk_token_count"`: Defaults to `128`.
|
||||
- `"chunk_token_count"`: Defaults to `256`.
|
||||
- `"layout_recognize"`: Defaults to `true`.
|
||||
- `"html4excel"`: Indicates whether to convert Excel documents into HTML format. Defaults to `false`.
|
||||
- `"delimiter"`: Defaults to `"\n"`.
|
||||
|
@ -291,7 +291,7 @@ Released on November 26, 2024.
|
||||
|
||||
### Compatibility changes
|
||||
|
||||
As of this release, **service_config.yaml.template** replaces **service_config.yaml** for configuring backend services. Upon Docker container startup, the environment variables defined in this template file are automatically populated and a **service_config.yaml** is auto-generated from it. [#3341](https://github.com/infiniflow/ragflow/pull/3341)
|
||||
From this release onwards, **service_config.yaml.template** replaces **service_config.yaml** for configuring backend services. Upon Docker container startup, the environment variables defined in this template file are automatically populated and a **service_config.yaml** is auto-generated from it. [#3341](https://github.com/infiniflow/ragflow/pull/3341)
|
||||
|
||||
This approach eliminates the need to manually update **service_config.yaml** after making changes to **.env**, facilitating dynamic environment configurations.
|
||||
|
||||
@ -365,7 +365,7 @@ Released on September 30, 2024.
|
||||
|
||||
### Compatibility changes
|
||||
|
||||
As of this release, RAGFlow offers slim editions of its Docker images to improve the experience for users with limited Internet access. A slim edition of RAGFlow's Docker image does not include built-in BGE/BCE embedding models and has a size of about 1GB; a full edition of RAGFlow is approximately 9GB and includes both built-in embedding models and embedding models that will be downloaded once you select them in the RAGFlow UI.
|
||||
From this release onwards, RAGFlow offers slim editions of its Docker images to improve the experience for users with limited Internet access. A slim edition of RAGFlow's Docker image does not include built-in BGE/BCE embedding models and has a size of about 1GB; a full edition of RAGFlow is approximately 9GB and includes both built-in embedding models and embedding models that will be downloaded once you select them in the RAGFlow UI.
|
||||
|
||||
The default Docker image edition is `nightly-slim`. The following list clarifies the differences between various editions:
|
||||
|
||||
|
@ -334,7 +334,7 @@ export default {
|
||||
`,
|
||||
useRaptor: 'RAPTOR zur Verbesserung des Abrufs verwenden',
|
||||
useRaptorTip:
|
||||
'Rekursive Abstrakte Verarbeitung für Baumorganisierten Abruf, weitere Informationen unter https://huggingface.co/papers/2401.18059.',
|
||||
'RAPTOR für Multi-Hop-Frage-Antwort-Aufgaben aktivieren. Details unter https://ragflow.io/docs/dev/enable_raptor.',
|
||||
prompt: 'Prompt',
|
||||
promptTip:
|
||||
'Verwenden Sie den Systemprompt, um die Aufgabe für das LLM zu beschreiben, festzulegen, wie es antworten soll, und andere verschiedene Anforderungen zu skizzieren. Der Systemprompt wird oft in Verbindung mit Schlüsseln (Variablen) verwendet, die als verschiedene Dateninputs für das LLM dienen. Verwenden Sie einen Schrägstrich `/` oder die (x)-Schaltfläche, um die zu verwendenden Schlüssel anzuzeigen.',
|
||||
|
@ -327,7 +327,7 @@ export default {
|
||||
`,
|
||||
useRaptor: 'Use RAPTOR to enhance retrieval',
|
||||
useRaptorTip:
|
||||
'Recursive Abstractive Processing for Tree-Organized Retrieval, see https://huggingface.co/papers/2401.18059 for more information.',
|
||||
'Enable RAPTOR for multi-hop question-answering tasks. See https://ragflow.io/docs/dev/enable_raptor for details.',
|
||||
prompt: 'Prompt',
|
||||
promptTip:
|
||||
'Use the system prompt to describe the task for the LLM, specify how it should respond, and outline other miscellaneous requirements. The system prompt is often used in conjunction with keys (variables), which serve as various data inputs for the LLM. Use a forward slash `/` or the (x) button to show the keys to use.',
|
||||
|
@ -290,7 +290,7 @@ export default {
|
||||
Perhatikan jenis entitas yang perlu Anda tentukan.</p>`,
|
||||
useRaptor: 'Gunakan RAPTOR untuk meningkatkan pengambilan',
|
||||
useRaptorTip:
|
||||
'Pemrosesan Abstraktif Rekursif untuk Pengambilan Terorganisasi Pohon, silakan merujuk ke https://huggingface.co/papers/2401.18059',
|
||||
'Aktifkan RAPTOR untuk tugas tanya jawab multi-langkah. Lihat https://ragflow.io/docs/dev/enable_raptor untuk informasi lebih lanjut.',
|
||||
prompt: 'Prompt',
|
||||
promptTip:
|
||||
'Gunakan prompt sistem untuk menjelaskan tugas untuk LLM, tentukan bagaimana harus merespons, dan menguraikan persyaratan lainnya. Prompt sistem sering digunakan bersama dengan kunci (variabel), yang berfungsi sebagai berbagai input data untuk LLM. Gunakan garis miring `/` atau tombol (x) untuk menampilkan kunci yang digunakan.',
|
||||
|
@ -285,7 +285,7 @@ export default {
|
||||
<p><b>エンティティタイプ</b>を設定することを忘れないでください。</p>`,
|
||||
useRaptor: 'RAPTORを使用して検索を強化',
|
||||
useRaptorTip:
|
||||
'ツリー構造化検索のための再帰的抽象処理(RAPTOR)については、詳細はhttps://huggingface.co/papers/2401.18059をご覧ください',
|
||||
'マルチホップ質問応答タスクでRAPTORを有効にしてください。詳細は https://ragflow.io/docs/dev/enable_raptor をご覧ください。',
|
||||
prompt: 'プロンプト',
|
||||
promptTip:
|
||||
'LLMのタスクを説明し、どのように応答すべきかを指定し、他のさまざまな要件を概説するためにシステムプロンプトを使用します。システムプロンプトは、LLMのさまざまなデータ入力として機能するキー(変数)と共に使用されることがよくあります。使用するキーを表示するには、スラッシュ `/` または (x) ボタンを使用します。',
|
||||
|
@ -262,7 +262,7 @@ export default {
|
||||
<p><i>Linhas de texto que não seguirem essas regras serão ignoradas, e cada par de Pergunta & Resposta será tratado como um fragmento distinto.</i></p>`,
|
||||
useRaptor: 'Usar RAPTOR para melhorar a recuperação',
|
||||
useRaptorTip:
|
||||
'Processamento Abstrativo Recursivo para Recuperação Organizada em Árvore. Veja mais em https://huggingface.co/papers/2401.18059.',
|
||||
'Ative o RAPTOR para tarefas de perguntas e respostas multi-hop. Veja https://ragflow.io/docs/dev/enable_raptor para mais detalhes.',
|
||||
prompt: 'Prompt',
|
||||
promptTip:
|
||||
'Use o prompt do sistema para descrever a tarefa para o LLM, especificar como ele deve responder e esboçar outros requisitos diversos. O prompt do sistema é frequentemente usado em conjunto com chaves (variáveis), que servem como várias entradas de dados para o LLM. Use uma barra `/` ou o botão (x) para mostrar as chaves a serem usadas.',
|
||||
|
@ -295,7 +295,7 @@ export default {
|
||||
<p>Đảm bảo bạn đã đặt <b>Loại thực thể</b>.</p>`,
|
||||
useRaptor: 'Sử dụng RAPTOR để cải thiện truy xuất',
|
||||
useRaptorTip:
|
||||
'Recursive Abstractive Processing for Tree-Organized Retrieval, xem https://huggingface.co/papers/2401.18059 để biết thêm thông tin',
|
||||
'Kích hoạt RAPTOR cho các tác vụ hỏi đáp đa bước. Xem chi tiết tại https://ragflow.io/docs/dev/enable_raptor.',
|
||||
prompt: 'Nhắc nhở',
|
||||
promptTip:
|
||||
'Sử dụng lời nhắc hệ thống để mô tả nhiệm vụ cho LLM, chỉ định cách nó nên phản hồi và phác thảo các yêu cầu khác nhau. Lời nhắc hệ thống thường được sử dụng kết hợp với các khóa (biến), đóng vai trò là các đầu vào dữ liệu khác nhau cho LLM. Sử dụng dấu gạch chéo `/` hoặc nút (x) để hiển thị các khóa cần sử dụng.',
|
||||
|
@ -316,8 +316,8 @@ export default {
|
||||
<p>標籤欄中,標籤之間用英文逗號分隔。</p>
|
||||
<i>不符合上述規則的文字行將被忽略。</i>
|
||||
`,
|
||||
useRaptor: '使用RAPTOR文件增強策略',
|
||||
useRaptorTip: '請參考 https://huggingface.co/papers/2401.18059',
|
||||
useRaptor: '使用 RAPTOR 文件增強策略',
|
||||
useRaptorTip: '啟用 RAPTOR 以用於多跳問答任務。詳情請參見:https://ragflow.io/docs/dev/enable_raptor',
|
||||
prompt: '提示詞',
|
||||
promptMessage: '提示詞是必填項',
|
||||
promptText: `请請總結以下段落。 小心數字,不要編造。 段落如下:
|
||||
|
@ -333,8 +333,8 @@ export default {
|
||||
<p>在标签列中,标签之间使用英文逗号分隔。</p>
|
||||
<i>不符合上述规则的文本行将被忽略。</i>
|
||||
`,
|
||||
useRaptor: '使用召回增强RAPTOR策略',
|
||||
useRaptorTip: '请参考 https://huggingface.co/papers/2401.18059',
|
||||
useRaptor: '使用召回增强 RAPTOR 策略',
|
||||
useRaptorTip: '为多跳问答任务启用 RAPTOR,详情请见 : https://ragflow.io/docs/dev/enable_raptor。',
|
||||
prompt: '提示词',
|
||||
promptMessage: '提示词是必填项',
|
||||
promptText: `请总结以下段落。 小心数字,不要编造。 段落如下:
|
||||
|
Loading…
x
Reference in New Issue
Block a user