内容
# godot-mcp
用于Godot文档的离线MCP服务器。提供结构化查找、全文本搜索、语义搜索和知识图工具,所有功能均在本地运行。
## 设置
```bash
# 1. 安装依赖
uv sync
# 2. 检出 godot-docs 子模块(如果全新克隆)
git submodule update --init --recursive
# 3. 构建索引(首次,大约2-3分钟,包含嵌入)
uv run python scripts/index_docs.py
# 跳过嵌入以快速建立索引(3秒):
uv run python scripts/index_docs.py --no-rag
```
## MCP 配置
将以下内容添加到您的Claude Code / MCP客户端配置中:
```json
{
"mcpServers": {
"godot-docs": {
"command": "uv",
"args": ["run", "-m", "src.godot_docs.server"],
"cwd": "PATH/TO/PROJECT/godot-mcp"
}
}
}
```
## 可用工具
| 工具 | 描述 |
|---|---|
| `lookup_class(name)` | 类的完整API文档:属性、方法、信号 |
| `get_method(class_name, method_name)` | 特定方法的文档 |
| `list_classes(filter="")` | 列出所有类,可选过滤 |
| `search_docs(query, section="all")` | 全文本搜索(类 + 教程) |
| `semantic_search(query, n_results=5)` | 通过本地嵌入的语义/概念搜索 |
| `get_class_hierarchy(class_name)` | 继承链(祖先 + 子类) |
| `related_classes(class_name)` | 通过继承或类型使用相关的类 |
| `get_tutorial(rst_path)` | 教程的完整内容 |
| `index_status()` | 检查索引是否最新 |
## 更新文档
```bash
cd godot-docs && git pull && cd ..
uv run python scripts/index_docs.py
```
## 将其添加到游戏项目作为子模块
```bash
cd /path/to/your-game
git submodule add https://github.com/you/godot-mcp.git tools/godot-mcp
git submodule update --init --recursive
```