Union Unity MCP Server
[!IMPORTANT] Union 已弃用。请使用 Unity 官方 MCP 服务器。
Union ♾️ - Unity MCP 服务器
一个用于 Unity 的模型上下文协议 (MCP) 服务器

主要功能
🖼️ 多模态视觉:你的智能体可以看到你所看到的。它可以查看场景、通过任何摄像机观察、监视播放模式以及检查资产缩略图。
🔎 强大的搜索:超越项目面板,同时在层级结构和项目资产中进行搜索。
✔️ 卓越的代码分析:利用 Unity 自身的编译器进行代码分析,比智能体的 linter 更准确。
⏩ 快速启动:通过单个
mcp.json配置文件,在几秒钟内即可运行。🛠️ 可扩展:以最少的样板代码添加你自己的项目特定工具。
📅 始终保持最新:通过 官方 MCP C# SDK 保持与最新的 MCP 协议版本(目前为
2025-06-18)同步。
Related MCP server: Unity MCP Server
兼容性
名称 | 兼容性 | 备注 |
模型 | ||
GPT-4.1 | ✅ | |
Claude 4 Sonnet | ✅ | |
Claude 4 Opus | ✅ | |
Gemini 2.5 Pro | ✅ | |
Gemini 2.5 Flash | ✅ | |
o3 | ✅ | 无图像理解能力 |
o4-mini | ✅ | |
Unity 版本 | ||
Unity 6000.0.x | ✅ | 更高版本应该没问题。更低版本可能有效,但未经测试。 |
智能体 | ||
Cursor | ✅ | |
Rider AI | ✅ | |
Claude Desktop | ✅ | |
Claude Code | ✅ | 终端在 Mac 上需要“屏幕录制”和“系统音频录制”权限 |
操作系统 | ||
Windows | ✅ | |
Mac | ✅ | |
Ubuntu | ❔ | 未经测试 |
设置
1. 安装 node.js
2. 配置 mcp.json
{
"mcpServers": {
"unity": {
"command": "npx",
"args": ["-y", "@nurture-tech/unity-mcp-runner", "-unityPath", "<path to unity editor>", "-projectPath", "<path to unity project>"]
}
}
}这将自动在你的 Unity 项目中安装 is.nurture.mcp 包。请随意将这些更改提交到源代码管理中。
关于工具
认识你的 Unity AI 工具箱。
工具 | 描述 |
资产 | |
| 获取资产或子资产的全部内容。 |
| 将资产复制到新路径。 |
| 将资产从文件系统导入到 Unity 中。 |
| 获取资产的导入器设置。 |
预制体 | |
| 以隔离模式打开 Unity 预制体,以便进行编辑。 |
场景 | |
| 打开场景 |
| 关闭打开的场景 |
| 保存当前场景。如果场景未修改,则此操作无效。 |
| 通过层级路径获取已加载场景或预制体中游戏对象的详细信息。 |
| 通过进入播放模式并运行指定的秒数来测试活动场景。 |
脚本编写 | |
| 在给定路径创建或替换 C# 代码文件。这也会检查脚本是否编译成功。 |
| 在 Unity 编辑器内执行代码。 |
| 获取 Unity 完全限定类型名称(包括程序集)上的公共字段和方法。 |
搜索 | |
| 搜索项目资产和场景对象。 |
编辑器状态 | |
| 获取 Unity 编辑器的状态。 |
| 获取用户当前在编辑器中选中的对象。 |
视觉 | |
| 在场景视图中聚焦于某个游戏对象。 |
| 获取场景视图中聚焦内容的预览。 |
已知问题
在 Windows 上通过 Cursor 启动时,Google External Dependency Manager (EDMU) 会导致 Unity 在启动时无限挂起。此问题正在调查中。
test_active_scene工具偶尔会失败,并显示错误消息Maximum call stack size exceeded.search工具偶尔会失败,并显示错误消息Search index is not ready yet. Please try again later.
添加项目特定工具
Union 使用官方的 C# MCP SDK。
创建一个静态类来存放你的工具。在该类上添加
[McpServerToolType]注解。声明静态方法来实现每个工具。在每个方法上添加
[McpServerTool]注解。参考 Services 目录获取示例。
你可能需要退出 Unity 并重启你的智能体,以便它能识别新工具。
使用技巧
以下是充分利用 Union 的一些技巧:
🚀 通过智能体启动:始终通过 AI 智能体的 MCP 集成来启动 Unity。从 Hub 启动 Unity 将阻止 MCP 服务器连接。
📂 项目级设置:如果你的智能体支持,请在项目级设置中配置 MCP 服务器。这允许你在不同的 Unity 项目之间无缝切换。
⚙️ 命令行参数:你可以为高级场景(如在 CI/CD 流水线中以
-batchmode或-nographics运行)向 Unity 传递额外参数。在 Unity 特定参数前添加--分隔符:{ "mcpServers": { "unity": { "command": "npx", "args": [ "-y", "@nurture-tech/unity-mcp-runner" "-unityPath", "<path to unity editor>", "-projectPath", ".", "--", "-batchmode", "-nographics" ] } } }⚠️ 重要:不要使用
-logFile命令行参数。MCP 服务器依赖 Unity 的标准输出进行通信。🖥️ 分屏以实现视觉功能:对于
screenshot等工具,请确保 Unity 编辑器在屏幕上可见,否则它最终会截取前台窗口的画面。
This server cannot be deployed
Maintenance
Related MCP Connectors
Build, validate, and deploy multi-agent AI solutions from any AI environment.
Make games with AI: one MCP server that connects your agent to Unity, Unreal and Godot editors.
Generate and edit images, video, voice, lip-sync and 3D models from your AI agent.
Video, image and audio generation on top AI models for agents, with an AI director built in.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables AI assistants to interact with Unity Editor projects through 68+ tools for manipulating scenes, GameObjects, components, and assets, plus live access to console logs, hierarchies, and test results.12 npm9MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to query and control the Unity Editor, supporting scene management, GameObject manipulation, asset browsing, play mode control, and real-time editor operations through 52+ tools.1MIT
- AlicenseCqualityBmaintenanceIntegrates AI assistants with the Unity Editor for scene manipulation, asset management, and testing, plus Unity documentation search via RAG.8459 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with Unity Editor, managing scenes, game objects, animations, materials, scripts, and more via natural language commands.2MIT