戈多特MCP
((((((( (((((((
((((((((((( (((((((((((
((((((((((((( (((((((((((((
(((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((
((((( ((((((((((((((((((((((((((((((((((((((((( (((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((@@@@@@@(((((((((((((((((((((((((((@@@@@@@(((((((((((
(((((((((@@@@,,,,,@@@(((((((((((((((((((((@@@,,,,,@@@@(((((((((
((((((((@@@,,,,,,,,,@@(((((((@@@@@(((((((@@,,,,,,,,,@@@((((((((
((((((((@@@,,,,,,,,,@@(((((((@@@@@(((((((@@,,,,,,,,,@@@((((((((
(((((((((@@@,,,,,,,@@((((((((@@@@@((((((((@@,,,,,,,@@@(((((((((
((((((((((((@@@@@@(((((((((((@@@@@(((((((((((@@@@@@((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
@@@@@@@@@@@@@((((((((((((@@@@@@@@@@@@@((((((((((((@@@@@@@@@@@@@
((((((((( @@@(((((((((((@@(((((((((((@@(((((((((((@@@ (((((((((
(((((((((( @@((((((((((@@@(((((((((((@@@((((((((((@@ ((((((((((
(((((((((((@@@@@@@@@@@@@@(((((((((((@@@@@@@@@@@@@@(((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((
/$$ /$$ /$$$$$$ /$$$$$$$
| $$$ /$$$ /$$__ $$| $$__ $$
| $$$$ /$$$$| $$ \__/| $$ \ $$
| $$ $$/$$ $$| $$ | $$$$$$$/
| $$ $$$| $$| $$ | $$____/
| $$\ $ | $$| $$ $$| $$
| $$ \/ | $$| $$$$$$/| $$
|__/ |__/ \______/ |__/
一个模式背景协议(MCP)服务器,用于与Godot游戏引擎互动.
导言
Godot MCP使AI助手能够启动Godot编辑器,运行项目,抓取调试输出,以及控制项目执行——全部通过标准化接口.
这个直接回馈循环帮助克洛德等AI助手理解什么在真正的Godot项目中有效,什么不有效,从而导致更好的代码生成和调试帮助.
特征
- 启动 Godot 编辑器: 为特定工程打开 Godot 编辑器
- 运行 Godot 项目: 在调试模式下执行 Godot 项目
- 抓取调试输出: 获取控制台输出和出错消息
- 控制执行:在方案上开始和停止戈多项目
- 获取 Godot 版本: 获取已安装的 Godot 版本
- 列出 Godot 项目: 在指定的目录中查找 Godot 项目
- 项目分析:获得关于项目结构的详细资料
- 场景管理数字 :
- 创建带有指定根节点类型的新场景
- 在现有场景中添加带有自定义属性的节点
- 将图示和纹理装入Sprite2D节点
- 导出 3D 场景为 GridMap 的 MeshLibrary 资源
- 使用创建变体的选项保存场景
- UID 管理器 (用于哥多特4.4+):
- 获取特定文件的 UID
- 通过重新保存资源更新 UID 引用
所需资源
- 哥多发动机 安装在您的系统中
- 节点.js和npm
- 支持 MCP( 线、 光标等) 的AI 助手
安装和配置
步骤1:安装和建造
首先,克隆寄存器并构建MCP服务器:
git clone https://github.com/Coding-Solo/godot-mcp.git
cd godot-mcp
npm install
npm run build
步骤2: 配置您的 AI 助理
选项A: 配置 Cline
添加到您的 Cline MCP 设置文件( E)~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json:
{
"mcpServers": {
"godot": {
"command": "node",
"args": ["/absolute/path/to/godot-mcp/build/index.js"],
"env": {
"DEBUG": "true" // Optional: Enable detailed logging
},
"disabled": false,
"autoApprove": [
"launch_editor",
"run_project",
"get_debug_output",
"stop_project",
"get_godot_version",
"list_projects",
"get_project_info",
"create_scene",
"add_node",
"load_sprite",
"export_mesh_library",
"save_scene",
"get_uid",
"update_project_uids"
]
}
}
}
选项 B: 配置光标
使用光标 UI :
- 转到 光标设置 > 翻译: 特征 > 翻译: MCP 磁共振
- 点击 + 添加新的 MCP 服务器 按钮
- 填写表格 :
- 名称 :
godot(或你喜欢的任何名字) - 类型 :
command - 命令 :
node /absolute/path/to/godot-mcp/build/index.js
- 名称 :
- 点击“ 添加”
- 您可能需要按下 MCP 服务器卡右上角的刷新按钮来填充工具列表
使用特定工程配置 :
创建文件于 .cursor/mcp.json 包含以下内容的项目目录中:
{
"mcpServers": {
"godot": {
"command": "node",
"args": ["/absolute/path/to/godot-mcp/build/index.js"],
"env": {
"DEBUG": "true" // Enable detailed logging
}
}
}
}
步骤3:可选环境变量
您可以用这些环境变量自定义服务器行为 :
GODOT_PATH: Godot 可执行文件的路径( 自动检测)DEBUG: 设定为“ true ” 以启用详细的服务器侧调试日志
示例提示
配置后, 您的AI助手会在需要时自动运行 MCP 服务器 。 您可以使用下列提示:
"Launch the Godot editor for my project at /path/to/project"
"Run my Godot project and show me any errors"
"Get information about my Godot project structure"
"Analyze my Godot project structure and suggest improvements"
"Help me debug this error in my Godot project: [paste error]"
"Write a GDScript for a character controller with double jump and wall sliding"
"Create a new scene with a Player node in my Godot project"
"Add a Sprite2D node to my player scene and load the character texture"
"Export my 3D models as a MeshLibrary for use with GridMap"
"Create a UI scene with buttons and labels for my game's main menu"
"Get the UID for a specific script file in my Godot 4.4 project"
"Update UID references in my Godot project after upgrading to 4.4"
执行细节
建筑
Godot MCP服务器对复杂的操作使用捆绑的GDScript方法:
- 直接命令:简单的操作,如启动编辑器或获取项目信息,直接使用Godot的内置CLI命令.
- 捆绑操作脚本: 创建场景或添加节点等复杂操作使用单一,全面的GDScript文件(
godot_operations.gd),负责所有操作.
这一架构提供若干好处:
- 没有临时文件: 消除对临时脚本文件的需要, 保持系统清洁
- 简化代码库: 将所有 Godot 操作集中在一个( 某些) 有组织的文件中
- 更好地维持: 方便添加新操作或修改已存在的操作
- 改进了错误处理: 为所有业务提供一致的错误报告
- 减少间接费用: 将文件 I/O 操作最小化,以便更好的性能
被捆绑的脚本接受操作类型和参数为JSON,允许灵活而动态的操作执行而无需为每次操作生成临时文件.
解决问题
- 找不到哥多特语: 将 GODOT PATH 环境变量设定为您的 Godot 可执行文件
- 连接问题: 确保服务器运行并重新启动您的 AI 助手
- 无效的工程路径:确保路径指向包含一个工程的目录. 干道文件
- 构建问题:确保通过运行安装所有依赖
npm install - 特定光标数字 :
- 确保 MCP 服务器在 Cursor 设置中显示并启用( Settings > MCP)
- MCP工具只能使用代理聊天配置文件( Cursor Pro 或 Business 订阅) 运行
- 使用“ Yolo 模式” 自动运行 MCP 工具请求
许可证
这个项目根据麻省理工学院许可证颁发——见 自由主义 详细文件.
