UEMCP通过两层架构将AI助手与Unreal Engine连接起来,该架构将MCP服务器(Node.js)与Python编辑器插件分离,从而实现Unreal Engine编辑器的远程部署。此实现提供了对常见UE Python API操作的优化封装,减少了高达85%的代码生成。仓库包括AI客户端的自动设置、全面的开发环境以及三个专门的Claude代理以增强UE工作流程。与包管理的MCP服务器不同,此仓库设计为可克隆并可能分叉,以实现最大程度的定制和开发灵活性。
<img src="https://github.com/atomantic/UEMCP/releases/download/v1.0.0/uemcp-demo.gif" alt="UEMCP Demo" width="100%"># 克隆并设置
git clone https://github.com/atomantic/UEMCP.git
cd UEMCP
./setup.sh
# 重启Claude Desktop或Claude Code并测试:
# "列出可用的UEMCP工具"
# "将当前地图中的角色组织成合理的文件夹结构和命名约定"
设置脚本会自动:
脚本会检测您已安装的AI工具,并提供配置选项:
~/.aws/amazonq/agents/default.json支持MCP~/.gemini/settings.json支持MCP~/.codex/config.toml支持可信项目推荐:使用WSL(Windows Subsystem for Linux)
# 如果尚未安装,请安装WSL
wsl --install
# 在WSL/Ubuntu终端中:
git clone https://github.com/atomantic/UEMCP.git
cd UEMCP
./setup.sh
替代方案:Git Bash
./setup.sh注意:设置脚本会在Windows上将插件复制(而不是符号链接)到您的UE项目中,以避免权限问题。
高级选项:
# 指定UE项目(自动通过复制安装插件)
./setup.sh --project "/path/to/project.uproject"
# 使用符号链接安装UEMCP插件进行开发
./setup.sh --project "/path/to/project.uproject" --symlink
# 非交互模式(用于CI/CD)
./setup.sh --project "/path/to/project.uproject" --no-interactive
您可以要求代理执行的任务是无限的。这里有一些按复杂度组织的提示示例:
**python_proxy工具提供了对Unreal Engine Python API的完全无限制访问。**这意味着AI助手可以在UE编辑器内执行任何Python代码——从简单的查询到复杂的自动化脚本。其他所有MCP工具本质上都是围绕可以通过python_proxy完成的常见操作的便利包装器。
actor_spawn或viewport_screenshot是常见任务的优化快捷方式,消除了AI编写大量Python代码的需求。使用方便的viewport_screenshot mcp工具:
// 一行代码,意图明确,自动文件处理
viewport_screenshot({ width: 1920, height: 1080, quality: 80 })
使用python_proxy完成相同任务:
# 更加复杂,需要了解UE Python API
import unreal
import os
import time
# 获取项目路径
project_path = unreal.Paths.project_saved_dir()
screenshot_dir = os.path.join(project_path, "Screenshots", "MacEditor")
# 确保目录存在
if not os.path.exists(screenshot_dir):
os.makedirs(screenshot_dir)
# 生成带时间戳的文件名
timestamp = int(time.time() * 1000)
filename = f"uemcp_screenshot_{timestamp}.png"
filepath = os.path.join(screenshot_dir, filename)
# 使用适当设置截取屏幕截图
unreal.AutomationLibrary.take_high_res_screenshot(
1920, 1080,
filepath,
camera=None,
capture_hdr=False,
comparison_tolerance=unreal.ComparisonTolerance.LOW
)
# 需要额外的错误处理、JPEG转换等
result = f"屏幕截图保存至:{filepath}"
可以这样理解:python_proxy是强大的命令行,而其他工具则是方便的GUI按钮。
📊 详细比较MCP工具与python_proxy →(平均减少80%以上的代码!)
UEMCP提供了7类共36个MCP工具,以实现全面的Unreal Engine控制:
所有角色操作工具(actor_spawn、actor_modify、actor_delete、actor_duplicate)现在支持自动验证,以确保操作按预期成功:
true) - 验证更改是否正确应用于Unreal Enginevalidate: false进入“鲁莽模式”,跳过验证以提高性能带有验证的示例:
// 带有自动验证的生成
actor_spawn({
assetPath: "/Game/Meshes/Wall",
location: [1000, 0, 0],
rotation: [0, 0, 90]
})
// 响应包括:validated: true/false, validation_errors: [...]
// 不带验证的修改以加快执行速度
actor_modify({
actorName: "Wall_01",
location: [2000, 0, 0],
validate: false // 跳过验证检查
})
batch_operations工具允许您在一个HTTP请求中高效地执行多个操作,批量操作的开销减少了80-90%:
// 高效地执行多个操作
batch_operations({
operations: [
{
operation: "actor_spawn",
params: { assetPath: "/Game/Meshes/Wall", location: [0, 0, 0] },
id: "wall_1"
},
{
operation: "actor_spawn",
params: { assetPath: "/Game/Meshes/Wall", location: [300, 0, 0] },
id: "wall_2"
},
{
operation: "viewport_camera",
params: { location: [150, -500, 300], rotation: [0, -30, 0] },
id: "camera_pos"
},
{
operation: "viewport_screenshot",
params: { width: 800, height: 600 },
id: "screenshot"
}
]
})
// 返回每个操作的成功/失败状态及计时信息
优点:
总计:36个MCP工具,分布在7个类别中,通过模型上下文协议接口提供全面的Unreal Engine自动化和控制。
🚀 v2.0.0动态架构:所有工具定义现在都从Python动态加载,消除了代码重复,并确保Python是工具能力的唯一真实来源。这些工具范围从基本的项目查询到高级的蓝图操作,python_proxy工具提供了对Unreal Engine完整Python API的无限访问,以执行未被专用工具覆盖的操作。
help工具是自我文档化的! 从这里开始:
// 第一个要运行的命令 - 显示所有工具和工作流
help({})
// 学习特定工具
help({ tool: "actor_spawn" })
help({ tool: "python_proxy" })
// 按类别探索
help({ category: "level" }) // 所有关卡编辑工具
help({ category: "viewport" }) // 相机和渲染工具
// 1. 列出项目中的现有蓝图
blueprint_list({ path: "/Game/Blueprints" })
// 2. 创建一个新的互动门蓝图
blueprint_create({
className: "BP_InteractiveDoor",
parentClass: "Actor",
components: [
{ name: "DoorMesh", type: "StaticMeshComponent" },
{ name: "ProximityTrigger", type: "BoxComponent" }
],
variables: [
{ name: "IsOpen", type: "bool", defaultValue: false },
{ name: "OpenRotation", type: "rotator", defaultValue: [0, 0, 90] }
]
})
// 3. 分析蓝图结构
blueprint_info({ blueprintPath: "/Game/Blueprints/BP_InteractiveDoor" })
// 4. 编译并检查错误
blueprint_compile({ blueprintPath: "/Game/Blueprints/BP_InteractiveDoor" })
// 5. 生成文档
blueprint_document({
blueprintPath: "/Game/Blueprints/BP_InteractiveDoor",
outputPath: "/Game/Documentation/BP_InteractiveDoor.md"
})
# 使用python_proxy,您可以执行在UE的Python控制台中能做的任何事情:
import unreal
# 批量操作
actors = unreal.EditorLevelLibrary.get_all_level_actors()
for actor in actors:
if "Old" in actor.get_actor_label():
actor.destroy_actor()
# 复杂的资产查询
materials = unreal.EditorAssetLibrary.list_assets("/Game/Materials", recursive=True)
for mat_path in materials:
material = unreal.EditorAssetLibrary.load_asset(mat_path)
# 分析或修改材质属性...
# 编辑器自动化
def auto_layout_actors(spacing=500):
selected = unreal.EditorLevelLibrary.get_selected_level_actors()
for i, actor in enumerate(selected):
actor.set_actor_location(unreal.Vector(i * spacing, 0, 0))
当使用UEMCP与Claude Code时,正确的流程是:
注意:理论上,MCP服务器对UE重启具有弹性——重启Unreal Engine时不需要重启Claude Code。一旦UE再次运行,连接将自动恢复。
AI → 本地MCP服务器(Node.js)→ 云端Unreal Engine(Python监听器)
UEMCP使用两层架构,将MCP协议处理与Unreal Engine集成分离。这使得我们可以独立于与其交互的客户端部署Unreal Engine编辑器,无论是本地还是在云端。
# 本地开发 - 两个层级在同一台机器上
AI客户端 ←→ MCP服务器(localhost:8080)←→ UE Python(localhost:8765)
# 远程UE开发 - UE在云端/服务器上
AI客户端 ←→ MCP服务器(localhost:8080)←→ UE Python(远程服务器:8765)