Install
openclaw skills install godot-mcpGodot MCP (Model Context Protocol) integration enabling AI assistants to directly interact with Godot Editor. Use when working with Godot projects through AI...
openclaw skills install godot-mcpGodot MCP Server 是一个强大的插件,让 AI 助手能够直接与 Godot 编辑器交互,实现 AI 驱动的游戏开发。
# 克隆仓库
git clone https://github.com/DaxianLee/godot-mcp.git
# 复制到项目
cp -r godot-mcp/addons/godot_mcp /path/to/your/project/addons/
在 Godot 编辑器中:
项目 -> 项目设置 -> 插件默认配置:
http://127.0.0.1:3000/mcp在 GodotMCP 面板中可以:
# 配置文件位置
# macOS: ~/Library/Application Support/Trae CN/User/mcp.json
# Windows: %APPDATA%\Trae CN\User\mcp.json
# Linux: ~/.config/Trae CN/User/mcp.json
# 在 GodotMCP 面板中点击「一键配置」即可
# 配置文件位置
~/.cursor/mcp.json
# 在 GodotMCP 面板中点击「一键配置」即可
# 配置文件位置
~/.codeium/windsurf/mcp_config.json
# 在 GodotMCP 面板中点击「一键配置」即可
# 用户级配置(全局)
claude mcp add --scope user --transport http godot-mcp http://127.0.0.1:3000/mcp
# 项目级配置(当前项目)
claude mcp add --scope project --transport http godot-mcp http://127.0.0.1:3000/mcp
# 用户级
codex mcp add --scope user --transport http godot-mcp http://127.0.0.1:3000/mcp
# 项目级
codex mcp add --scope project --transport http godot-mcp http://127.0.0.1:3000/mcp
# 用户级
gemini mcp add --scope user --transport http godot-mcp http://127.0.0.1:3000/mcp
# 项目级
gemini mcp add --scope project --transport http godot-mcp http://127.0.0.1:3000/mcp
scene_create - 创建新场景
scene_open - 打开指定场景
scene_save - 保存当前场景
scene_get_tree - 获取场景树结构
scene_get_current - 获取当前场景信息
使用示例:
用户: 创建一个新场景,命名为 "Level1"
AI: [调用 scene_create {"name": "Level1"}]
已创建场景 Level1
用户: 添加一个 Sprite2D 节点
AI: [调用 node_add {"type": "Sprite2D", "name": "Player"}]
已添加 Sprite2D 节点到场景
node_add - 添加新节点
node_delete - 删除节点
node_get - 获取节点信息
node_set_property - 设置节点属性
node_get_property - 获取节点属性
node_move - 移动节点位置
node_rename - 重命名节点
node_duplicate - 复制节点
node_find - 查找节点
使用示例:
用户: 将 Player 节点的位置设置为 (100, 200)
AI: [调用 node_set_property {
"node": "Player",
"property": "position",
"value": {"x": 100, "y": 200}
}]
已设置 Player 位置为 (100, 200)
script_create - 创建新脚本
script_read - 读取脚本内容
script_write - 写入脚本内容
script_attach - 附加脚本到节点
使用示例:
用户: 为 Player 节点创建一个脚本
AI: [调用 script_create {
"name": "player.gd",
"template": "CharacterBody2D"
}]
[调用 script_attach {
"node": "Player",
"script": "res://scripts/player.gd"
}]
已创建并附加脚本
resource_load - 加载资源
resource_create - 创建资源
resource_save - 保存资源
filesystem_list - 列出目录内容
filesystem_read - 读取文件
filesystem_write - 写入文件
filesystem_delete - 删除文件
project_get_info - 获取项目信息
project_get_settings - 获取项目设置
editor_get_selection - 获取当前选中
editor_select_node - 选中指定节点
editor_undo_redo - 撤销/重做操作
debug_get_logs - 获取调试日志
material - 创建和配置材质
使用示例:
用户: 创建一个发光材质
AI: [调用 material {
"type": "StandardMaterial3D",
"emission": {"enabled": true, "color": "#00FF00"}
}]
已创建发光材质
shader - 着色器参数管理
lighting - 场景灯光配置
particle - 粒子效果创建
tilemap - TileMap 编辑
使用示例:
用户: 创建一个 TileMap 并设置瓷砖
AI: [调用 node_add {"type": "TileMap", "name": "Ground"}]
[调用 tilemap {
"action": "set_cell",
"coords": [(0, 0), (1, 0), (2, 0)],
"tile_id": 1
}]
已创建 TileMap 并铺设瓷砖
geometry - 2D 几何图形
physics - 物理体和碰撞配置
使用示例:
用户: 为 Player 添加碰撞形状
AI: [调用 node_add {
"type": "CollisionShape2D",
"parent": "Player"
}]
[调用 physics {
"node": "Player/CollisionShape2D",
"shape": "CapsuleShape2D",
"radius": 10,
"height": 20
}]
已添加碰撞形状
navigation - 导航网格和寻路
audio - 音频播放和配置
ui - 用户界面组件
signal - 信号连接管理
group - 节点分组管理
用户: 创建一个包含玩家、敌人和地形的场景
AI 执行步骤:
1. [scene_create {"name": "GameScene"}]
2. [node_add {"type": "Node2D", "name": "Entities"}]
3. [node_add {"type": "CharacterBody2D", "name": "Player", "parent": "Entities"}]
4. [node_add {"type": "Sprite2D", "name": "Sprite", "parent": "Player"}]
5. [script_create {"name": "player.gd"}]
6. [script_attach {"node": "Player", "script": "res://player.gd"}]
7. [node_add {"type": "CharacterBody2D", "name": "Enemy", "parent": "Entities"}]
8. [node_add {"type": "TileMap", "name": "Ground"}]
9. [scene_save]
完成!已创建包含玩家、敌人和地形的场景。
用户: 为玩家添加物理和碰撞检测
AI 执行步骤:
1. [node_add {"type": "CollisionShape2D", "parent": "Player"}]
2. [physics {
"node": "Player/CollisionShape2D",
"shape": "CapsuleShape2D",
"radius": 10,
"height": 30
}]
3. [script_write {
"path": "res://player.gd",
"content": "extends CharacterBody2D\n\nconst SPEED = 300.0\nconst JUMP_VELOCITY = -400.0\n\nvar gravity = ProjectSettings.get_setting(\"physics/2d/default_gravity\")\n\nfunc _physics_process(delta):\n # Add the gravity.\n if not is_on_floor():\n velocity.y += gravity * delta\n \n # Handle Jump.\n if Input.is_action_just_pressed(\"ui_accept\") and is_on_floor():\n velocity.y = JUMP_VELOCITY\n \n # Get the input direction and handle the movement/deceleration.\n var direction = Input.get_axis(\"ui_left\", \"ui_right\")\n if direction:\n velocity.x = direction * SPEED\n else:\n velocity.x = move_toward(velocity.x, 0, SPEED)\n \n move_and_slide()"
}]
完成!已为玩家配置物理系统。
用户: 在场景中放置 5 个敌人
AI 执行步骤:
1. [scene_open {"path": "res://scenes/game.tscn"}]
2. [node_add {"type": "Node2D", "name": "Enemies"}]
3. [node_duplicate {"node": "Enemy", "count": 4}]
4. [node_set_property {"node": "Enemy2", "property": "position", "value": {"x": 200, "y": 0}}]
5. [node_set_property {"node": "Enemy3", "property": "position", "value": {"x": 400, "y": 0}}]
6. [node_set_property {"node": "Enemy4", "property": "position", "value": {"x": 600, "y": 0}}]
7. [node_set_property {"node": "Enemy5", "property": "position", "value": {"x": 800, "y": 0}}]
8. [scene_save]
完成!已创建 5 个敌人并放置在场景中。
# 创建测试场景
用户: 创建一个测试场景,包含多个物理对象
AI: [创建场景和物理对象]
[配置物理参数]
[添加调试可视化]
测试场景已就绪
# 批量处理资源
用户: 将所有纹理的 filter 模式改为 Nearest
AI: [filesystem_list {"path": "res://textures"}]
[循环每个纹理]
[resource_load]
[修改 filter_mode]
[resource_save]
已更新所有纹理设置
# 生成游戏代码
用户: 为所有敌人节点生成 AI 脚本
AI: [node_find {"pattern": "Enemy*"}]
[为每个敌人创建脚本]
[根据类型生成 AI 逻辑]
[附加脚本]
已生成所有 AI 脚本
检查:
1. 端口 3000 是否被占用
2. 防火墙是否阻止
3. Godot 版本是否兼容
解决:
- 更改端口号
- 关闭防火墙或添加例外
- 升级到 Godot 4.x
检查:
1. MCP 服务器是否运行(绿色状态)
2. 配置文件中的端口号是否正确
3. AI 客户端是否重启
解决:
- 重启 MCP 服务器
- 检查配置文件
- 重启 AI 客户端
检查:
1. 节点路径是否正确
2. 属性名是否正确
3. 参数类型是否匹配
解决:
- 使用 scene_get_tree 查看场景结构
- 使用 node_get 查看可用属性
- 检查文档中的参数格式
推荐结构:
Scene
├── Entities
│ ├── Player
│ └── Enemies
├── Environment
│ ├── TileMaps
│ └── Props
└── UI
└── HUD
- 节点名: PascalCase (Player, Enemy)
- 脚本名: snake_case (player.gd, enemy_ai.gd)
- 场景名: snake_case (level_1.tscn, main_menu.tscn)
优先使用批量工具:
- node_duplicate (批量复制)
- tilemap (批量铺设)
- filesystem_list (批量文件操作)
始终检查操作结果:
1. scene_get_tree (验证场景结构)
2. node_get (验证节点存在)
3. debug_get_logs (查看错误日志)
插件支持 9 种语言:
在 GodotMCP 面板的「服务器」标签中切换语言。
非商业使用许可证
允许:
禁止:
商业使用请联系作者: LIDAXIAN (微信: lidaxian-AI)
欢迎提交 Issue 和 Pull Request!