Unity-MCP
Unity MCP(服务器 + 插件)
Unity版本 | 编辑模式 | 播放模式 | 独立 |
2022.3.61f1 | |||
2023.2.20f1 | |||
6000.0.46f1 |
**Unity-MCP**是 LLM 和 Unity 之间的桥梁。它向 LLM 展示并解释 Unity 的工具。LLM 能够理解界面并按照用户要求的方式使用这些工具。
使用集成的AI Connector窗口将**Unity-MCP**连接到 LLM 客户端(例如Claude或Cursor) 。同时支持自定义客户端。
该项目旨在让开发者能够尽快添加自定义工具。之后,我们的下一个目标是在玩家构建中启用相同的功能。目前,此功能仅在 Unity 编辑器中有效。
该系统具有可扩展性:您可以直接在 Unity 项目代码库中定义自定义tool ,从而向 AI 或自动化客户端开放新功能。这使得 Unity-MCP 成为构建高级工作流程、快速原型设计或将 AI 驱动功能集成到开发流程中的灵活基础。
人工智能工具
游戏对象
✅ 创建
✅ 摧毁
✅ 查找
✅ 修改(标签、图层、名称、静态)
✅ 设置父级
✅ 重复
游戏对象.组件
✅ 添加组件
✅ 获取组件
✅ 修改组件
✅
Field设置值
✅
Property设置值
✅
Reference链接集
✅ 销毁组件
🔲 删除缺失的组件
编辑
✅ 状态(播放模式)
✅ 获取
✅ 设置
✅ 获取 Windows
✅ 层
✅ 全部获取
✅ 添加
✅ 删除
✅ 标签
✅ 全部获取
✅ 添加
✅ 删除
✅ 执行
MenuItem🔲 运行测试
编辑精选
✅ 获得选择
✅ 设置选择
预制件
✅ 实例化
🔲 创建
✅ 开放
✅ 修改 (GameObject.Modify)
✅ 保存
✅ 关闭
包裹
🔲 安装
🔲 安装
🔲 删除
🔲 更新
资产
✅ 创建
✅ 查找
✅ 刷新
✅ 阅读
✅ 修改
✅ 重命名
✅ 删除
✅ 移动
✅ 创建文件夹
场景
✅ 创建
✅ 保存
✅ 加载
✅ 卸载
✅ 装载
✅ 获取层次结构
🔲 搜索(编辑器)
🔲 射线投射(了解体积)
材料
✅ 创建
✅ 修改 (Assets.Modify)
✅ 读取(Assets.Read)
✅ 分配给 GameObject 上的组件
着色器
✅ 列出全部
脚本
✅ 阅读
✅ 更新或创建
✅ 删除
可编写脚本的对象
🔲 创建
🔲 阅读
🔲 修改
🔲 删除
调试
🔲 读取日志(控制台)
成分
✅ 全部获取
图例: ✅ = 已实施且可用,🔲 = 计划中 / 尚未实施
安装
在 Unity 项目文件夹中打开命令行
运行命令
openupm add com.ivanmurzak.unity.mcp用法
确保您的项目路径没有空格符号“ ”。
✅
C:/MyProjects/Project❌
C:/My Projects/Project
打开 Unity 项目,转到 👉
Window/AI Connector (Unity-MCP)。
安装 MCP 客户端
登录 MCP 客户端
单击 MCP 客户端上的
Configure。
重新启动您的 MCP 客户端。
重启后,请确保
AI Connector处于“已连接”或“正在连接...”状态。在客户端(Cursor、Claude Desktop)中测试AI连接。在聊天中输入任何问题或任务。例如:
Explain my scene hierarchy添加自定义tool
⚠️ 它仅适用于支持动态工具列表更新的 MCP 客户端。
Unity-MCP 旨在支持项目所有者开发自定义tool 。MCP 服务器从 Unity 插件获取数据并将其公开给客户端。因此,MCP 通信链中的任何人都可以收到有关新tool的信息。LLM 可能会在某个时刻决定调用哪个工具。
要添加自定义tool ,您需要:
拥有一个具有属性
McpPluginToolType类。在类中有一个带有属性
McpPluginTool方法。[可选] 为每个方法参数添加
Description属性,以便 LLM 理解它。[可选] 使用带有 ? 和默认值的 string
?``string? optional = null属性将其标记为 LLM 的optional。
看一下
MainThread.Run(() =>这一行,它允许在主线程中运行与 Unity API 交互所需的代码。如果您不需要它并且在后台线程中运行该工具就可以了,那么出于效率目的,请不要使用主线程。
[McpPluginToolType]
public class Tool_GameObject
{
[McpPluginTool
(
"MyCustomTask",
Title = "Create a new GameObject"
)]
[Description("Explain here to LLM what is this, when it should be called.")]
public string CustomTask
(
[Description("Explain to LLM what is this.")]
string inputData
)
{
// do anything in background thread
return MainThread.Run(() =>
{
// do something in main thread if needed
return $"[Success] Operation completed.";
});
}
}添加自定义游戏内tool
⚠️ 尚不支持。支持工作正在进行中
贡献
请随意将新tool添加到项目中。
分叉该项目。
在您分叉的存储库中实现新
tool。在原始Unity-MCP存储库中创建 Pull 请求。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to control Unreal E…
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
MCP server for AI dialogue using various LLM models via AceDataCloud
MCP Server for Slima - AI Writing IDE for Novel Authors with AI Beta Reader.
Related MCP Servers
- AlicenseBqualityBmaintenanceMCP Unity Server to integrate Unity Editor game engine with different AI Model clients (e.g. Claude Desktop, Windsurf, Cursor)52,019MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that bridges Unity with AI agents, enabling scene inspection, C# code execution, and screenshot capture via WebSocket communication.MIT
- FlicenseNot gradedqualityDmaintenanceA native C# MCP server that gives AI agents real-time control and visual analysis of the Unity Editor, enabling dynamic code execution, scene manipulation, and debugging without external dependencies.8-
- AlicenseNot gradedqualityDmaintenanceUnity MCP Server enables LLM-based clients to automate the Unity Editor, including scene manipulation, UI testing, input simulation, and code editing.33MIT