From 539876af114ac9194b2a6debd5db8701a3bde707 Mon Sep 17 00:00:00 2001 From: Monster-Beast <111898334+Monster-Beast@users.noreply.github.com> Date: Wed, 7 May 2025 10:38:21 +0800 Subject: [PATCH] docs: add API key instructions for MCP host mode (#7496) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### What problem does this PR solve? _Briefly describe what this PR aims to solve. Include background context that will help reviewers understand the purpose of the PR._ ### Type of change - [ ] Bug Fix (non-breaking change which fixes an issue) - [ ] New Feature (non-breaking change which adds functionality) - [x] Documentation Update - [ ] Refactoring - [ ] Performance Improvement - [ ] Other (please describe): --------- Co-authored-by: 马继龙 --- docs/develop/mcp.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/develop/mcp.md b/docs/develop/mcp.md index 82e624050..2de36a63a 100644 --- a/docs/develop/mcp.md +++ b/docs/develop/mcp.md @@ -153,6 +153,25 @@ ragflow-server | 2025-04-18 15:41:34,501 INFO 32 Use Elasticsearch http://e 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.