AI游戏开发工具

Godot MCP Pro 是一个为Godot 4编辑器提供的AI辅助插件,包含168种工具,支持通过自然语言进行游戏开发。

  • by farrasfadhils
  • GDScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 Farraskuy/Godot-MCP

使用说明

Godot MCP Pro

Godot 4编辑器的168个AI驱动工具 --将您的AI助手(Claude、Cursor、Cline、Copilot)连接到Godot,并使用自然语言构建游戏。

168 Tools · 25 Categories · Undo/Redo on all mutations · 5-minute setup

运作原理

在5分钟内将您的AI助手连接到Godot。

1.安装插件

复制 addons/godot_mcp/ 在您的Godot项目中。在中启用它 项目>项目设置>插件该插件会自动启动编辑器内的WebSocket服务器。

2.构建MCP服务器

cd server
npm install && npm run build

这将编译TypeScript MCP服务器,该服务器将您的AI客户端连接到Godot插件。

3.开始用AI构建

将服务器添加到AI客户端的MCP配置中。打开Godot,您的AI助手现在可以实时访问168个工具——创建场景、编辑脚本、模拟输入和分析您正在运行的游戏。

MCP客户端配置

克劳德代码/克劳德桌面

添加 .claude/mcp.json:

{
  "mcpServers": {
    "godot": {
      "command": "node",
      "args": ["/absolute/path/to/server/dist/index.js"]
    }
  }
}

VS代码/光标

添加 .vscode/mcp.json:

{
  "servers": {
    "godot": {
      "command": "node",
      "args": ["./server/dist/index.js"]
    }
  }
}

任何stdio MCP客户端

node server/dist/index.js

服务器使用MCP协议通过stdio(stdin/stdout)进行通信。

自动设置(推荐)

cd server
npm run run

这将自动:

  • 构建MCP服务器
  • 检测 project.godot 在父文件夹中(或 GODOT_PROJECT_PATH)
  • 将插件同步到 addons/godot_mcp
  • 在中启用插件 project.godot
  • 创建MCP配置文件
  • 同步AI上下文文件

工具类别

# 类别 工具 亮点
1 项目 7 设置读/写、UID转换
2 场景 9 创建、打开、播放、停止、实例化、保存
3 节点 14 使用UndoRedo、信号、组添加/删除/重命名/移动
4 脚本 8 CRUD、附加、验证、用行号搜索
5 编辑 10 截图、执行GDScript、错误日志、重新加载
6 输入 7 键盘、鼠标、动作模拟、序列
7 运行时 19 游戏检查、帧捕获、录制/回放、UI
8 动画 6 CRUD、轨迹、关键帧
9 动画树 8 状态机、转换、混合树
10 TileMap 6 单元操作(Godot 4.3+的TileMapLayer)
11 三维场景 6 网格图元、.glb导入、照明预设、PBR
12 物理学 6 自动2D/3D碰撞、光线投射、图层
13 粒子 5 GPU粒子+火/烟/雨/雪/火花预设
14 导航 6 区域、代理、烘焙、寻路
15 音频 6 播放器(自动2D/3D),总线效果链
16 主题/UI 6 StyleBoxFlat,颜色/常量/字体覆盖
17 着色器 6 模板(canvas_item、空间、粒子、天空)
18 资源 6 .tres CRUD,自动加载管理
19 批次 8 按类型、批量集、依赖性分析查找
20 测试 6 自动化场景、断言、压力测试
21 分析 4 场景复杂性、信号流、未使用的资源
22 分析 2 FPS、内存、物理、渲染监视器
23 出口 3 预设列表、构建命令
总计 168 +4个核心连接工具

主要特点

🧠 智能类型解析

无需手动构造复杂的对象。属性值自动转换:

"Vector2(100, 200)"  → Vector2(100, 200)
"Color(1, 0, 0)"    → Color(1, 0, 0)
"#ff0000"            → Color(1, 0, 0)
"Color.RED"          → Color(1, 0, 0)
"true"               → true
"42"                 → 42

♻️ 撤销/恢复所有突变

每 add_node, delete_node, update_property, rename_node,以及 move_node 通过Godot的UndoRedo系统。您的用户可以 CTRL+Z键 任何AI操作。

🎯 自动2D/3D检测

物理体、碰撞形状、音频播放器、粒子和导航节点会自动检测父对象是2D还是3D——每次都会创建正确的类型。

🔥 内置预设

  • 照明:阳光、室内、戏剧、现场
  • 粒子:火、烟、雨、雪、火花
  • 着色器:canvas_item、空间、粒子、天空模板
  • 音频效果:混响、延迟、压缩器、均衡器、失真、合唱、移相器

快速示例

AI: godot_connect
AI: create_scene path="res://scenes/level.tscn" rootType="Node2D"
AI: add_node type="CharacterBody2D" name="Player" parentPath="."
AI: add_node type="Sprite2D" name="Sprite" parentPath="Player"
AI: update_property path="Player/Sprite" property="texture" value="res://icon.svg"
AI: setup_collision path="Player" shapeType="rectangle" size="Vector2(32, 32)"
AI: create_script path="res://scripts/player.gd" content="extends CharacterBody2D..."
AI: attach_script nodePath="Player" scriptPath="res://scripts/player.gd"
AI: save_scene
AI: play_scene
AI: simulate_key key="Space"
AI: get_game_screenshot
AI: stop_scene

建筑

server/src/
├── index.ts           TypeScript MCP server (stdio transport)
├── toolCatalog.ts     168 tool definitions with input schemas
└── godotBridge.ts     WebSocket client → Godot editor

addons/godot_mcp/
├── plugin.gd          Plugin entry point
├── websocket_server.gd Local WebSocket server (port 6505)
├── command_router.gd  Loads 20 handler modules, dispatches commands
└── commands/
    ├── base_commands.gd        Shared utilities (type parser, undo, I/O)
    ├── type_parser.gd          Smart string→Godot type conversion
    ├── undo_helper.gd          UndoRedo wrapper
    ├── core_commands.gd        Project, scene, node, script, editor (47 handlers)
    ├── editor_commands.gd      Screenshots, execute script (4)
    ├── input_commands.gd       Input simulation (7)
    ├── runtime_commands.gd     Game inspection & UI (15)
    ├── animation_commands.gd   Animation CRUD (6)
    ├── animation_tree_commands.gd  State machine & blend tree (8)
    ├── tilemap_commands.gd     Tile operations (6)
    ├── scene3d_commands.gd     3D scene building (6)
    ├── physics_commands.gd     Physics & collision (6)
    ├── particles_commands.gd   GPU particles + presets (5)
    ├── navigation_commands.gd  Nav regions & pathfinding (6)
    ├── audio_commands.gd       Audio players & bus effects (6)
    ├── theme_commands.gd       Theme & UI styling (6)
    ├── shader_commands.gd      Shader management (4)
    ├── resource_commands.gd    Resource & autoload (6)
    ├── batch_commands.gd       Batch operations (8)
    ├── testing_commands.gd     Testing & QA (5)
    ├── analysis_commands.gd    Code analysis (4)
    ├── profiling_commands.gd   Performance profiling (2)
    └── export_commands.gd      Export management (3)

桥接协议

基于WebSocket的JSON-RPC 2.0(ws://127.0.0.1:6505):

→ { "jsonrpc": "2.0", "id": 1, "method": "add_node", "params": { "type": "Sprite2D", "name": "Player" } }
← { "jsonrpc": "2.0", "id": 1, "result": { "tool": "add_node", "data": { "path": "/root/Main/Player" } } }

覆盖网桥URL: GODOT_WS_URL=ws://127.0.0.1:6505 node server/dist/index.js

需求

  • 戈多4.2+ (建议TileMapLayer使用4.3+)
  • Node.js 18+
  • 任何兼容MCP的AI客户端

AI代理上下文文件

当部署到Godot项目时,这些上下文文件帮助AI助手了解可用的工具:

文件 目的 使用人
addons/godot_mcp/skills.md 完整的168工具参考与工作流 所有AI代理
AGENTS.md 架构+能力总结 Codex、Gemini、代理商
CLAUDE.md 快速参考+构建命令 克劳德代码
.github/copilot-instructions.md Copilot特定说明 GitHub Copilot

参考文献