使用说明
项目简介
本项目实现了一个MCP服务器,用于为Godot RAG(Retrieval-Augmented Generation)模型提供Godot引擎的官方文档作为上下文信息。它允许LLM客户端通过MCP协议调用工具,查询Godot文档的相关内容,从而提升模型在Godot引擎相关问题上的回答质量。
主要功能点
- 文档检索工具: 提供 'get_godot_context' 工具,根据用户查询检索Godot文档的片段。
- 上下文服务: 通过MCP协议与LLM客户端通信,提供文档上下文信息。
- 可配置的向量数据库: 使用ChromaDB存储和检索文档向量,支持多种embedding模型。
安装步骤
- 安装Python虚拟环境:
uv venv --python 3.12 source ./.venv/bin/activate uv sync - 复制环境变量文件:
(可选) 如果使用 'main_with_api.py' (使用 OpenAI API),请在 '.env.local' 文件中配置 'OPENAI_API_KEY'。cp .env.example .env.local - 下载Godot文档并进行预处理:
(或者,如果使用 OpenAI API,则运行 'python vectorizer_api.py -i artifacts/chunks/artifacts_chunks_SZ_400_O_20.jsonl -m BAAI/bge-m3')python download_godot_docs.py python convert_rst2md.py python chunker.py -i artifacts python vectorizer.py -i artifacts/chunks/artifacts_chunks_SZ_400_O_20.jsonl
服务器配置
MCP客户端需要配置以下JSON以连接到此MCP服务器:
{ "mcpServers": { "godot-rag": { "command": "python", "args": [ "<path to the server script 'main.py'>", // 请替换为 'main.py' 脚本的实际路径,例如 './main.py' "-d", "<path to the chroma_db on your computer>", // 请替换为 ChromaDB 数据库的路径,例如 'artifacts/vector_stores/chroma_db' "-c", "<name of the collection in the chroma_db>" // 请替换为 ChromaDB 集合的名称,例如 'artifacts_chunks_SZ_400_O_20_all-MiniLM-L6-v2' ] } } }
注意:'<path to the server script 'main.py'>'、'<path to the chroma_db on your computer>' 和 '<name of the collection in the chroma_db>' 需要根据实际情况替换。
基本使用方法
- 启动MCP服务器:
(或者,如果使用 OpenAI API,则运行 'python main_with_api.py -d artifacts/vector_stores/chroma_db -c artifacts_chunks_SZ_400_O_20_BAAI-bge-m3 -k <your openai api key>')python main.py -d artifacts/vector_stores/chroma_db -c artifacts_chunks_SZ_400_O_20_all-MiniLM-L6-v2 - 在MCP客户端中配置上述服务器配置JSON。
- 客户端可以通过MCP协议调用 'get_godot_context' 工具,并传入关于Godot引擎的查询关键词,服务器将返回相关的Godot文档片段作为上下文。
信息
分类
开发者工具