Ivan Murzak

by IvanMurzak
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Utilizes .NET 9.0 as the foundation for the server component, enabling communication between the Unity plugin and external AI clients, with support for custom tool development in C#.

  • Acts as an AI-powered gateway between Unity Editor and LLM, allowing manipulation of GameObjects, Components, Assets, and Scenes. Supports creating and managing Unity objects, instantiating prefabs, searching assets, and viewing scene hierarchies with an extensible tool system.

Unity MCP(服务器 + 插件)

Unity版本编辑模式播放模式独立
2022.3.61f1
2023.2.20f1
6000.0.46f1

Unity-MCP 充当 Unity 编辑器和 LLM 之间的 AI 网关,实现 Unity 项目的无缝自动化和智能控制。通过与 MCP 服务器和客户端集成,它允许 AI 代理或外部工具与您的 Unity 环境交互,从而创建、修改和管理游戏对象、组件、资源、场景等。

该系统具有可扩展性:您可以直接在 Unity 项目代码库中定义自定义tool ,从而向 AI 或自动化客户端开放新功能。这使得 Unity-MCP 成为构建高级工作流程、快速原型设计或将 AI 驱动功能集成到开发流程中的灵活基础。

人工智能工具

游戏对象

  • ✅ 创建
  • ✅ 摧毁
  • ✅ 查找
  • 🔲 修改
游戏对象.组件
  • ✅ 添加组件
  • ✅ 销毁组件
  • ✅ 修改组件
    • Field设置值
    • Property设置值
    • Reference链接集

成分

  • ✅ 全部获取

预制件

  • ✅ 实例化
  • 🔲 从场景创建

编辑

  • 🔲 运行测试
  • 🔲 在编辑器中启动/停止播放模式

资产

  • ✅ 搜索
  • ✅ 刷新
  • 🔲 导入
  • 🔲 阅读

场景

  • ✅ 获取层次结构
  • 🔲 创建场景
  • 🔲 保存场景
  • 🔲 开放场景

材料

  • 🔲 创建
  • 🔲 更新
  • ✅ 分配给 GameObject 上的组件

脚本

  • 🔲 创建

图例: ✅ = 已实施且可用 🔲 = 计划中 / 尚未实施

安装

  1. 安装 .NET 9.0
  2. 安装 OpenUPM-CLI
  • 在 Unity 项目文件夹中打开命令行
  • 运行命令
openupm add com.ivanmurzak.unity.mcp

用法

  1. 前往👉 Window/AI Connector (Unity-MCP)
  2. 单击 MCP 客户端上的配置。
  3. 重新启动您的 MCP 客户端。
  4. 重启后,请确保AI Connector处于“已连接”状态。

添加自定义tool

⚠️ 尚不支持。MCP 服务器的csharp-sdk存在阻塞问题。正在等待解决方案。

Unity-MCP 旨在支持项目所有者开发自定义tool 。MCP 服务器从 Unity 插件获取数据并将其公开给客户端。因此,MCP 通信链中的任何人都可以收到有关新tool的信息。LLM 可能会在某个时刻决定调用哪个工具。

要添加自定义tool ,您需要:

  1. 拥有一个具有属性McpPluginToolType类。
  2. 在类中有一个带有属性McpPluginTool方法。
  3. [可选] 为每个方法参数添加Description属性,以便 LLM 理解它。
  4. [可选] 使用带有 ? 和默认值的 string ?``string? optional = null属性将其标记为 LLM 的optional

看一下行=> MainThread.Run(() =>它允许在主线程中运行与 Unity API 交互所需的代码。如果您不需要它并且在后台线程中运行该工具就可以了,请不要出于效率目的使用主线程。

[McpPluginToolType] public class Tool_GameObject { [McpPluginTool ( "GameObject_Create", Title = "Create a new GameObject", Description = "Create a new GameObject." )] public string Create ( [Description("Path to the GameObject (excluding the name of the GameObject).")] string path, [Description("Name of the GameObject.")] string name ) => MainThread.Run(() => { var targetParent = string.IsNullOrEmpty(path) ? null : GameObject.Find(path); if (targetParent == null && !string.IsNullOrEmpty(path)) return $"[Error] Parent GameObject '{path}' not found."; var go = new GameObject(name); go.transform.position = new Vector3(0, 0, 0); go.transform.rotation = Quaternion.identity; go.transform.localScale = new Vector3(1, 1, 1); if (targetParent != null) go.transform.SetParent(targetParent.transform, false); EditorUtility.SetDirty(go); EditorApplication.RepaintHierarchyWindow(); return $"[Success] Created GameObject '{name}' at path '{path}'."; }); }

贡献

请随意将新tool添加到项目中。

  1. 分叉该项目。
  2. 在您分叉的存储库中实现新tool
  3. 在原始Unity-MCP存储库中创建 Pull 请求。
-
security - not tested
A
license - permissive license
-
quality - not tested

对 Unity 项目进行无缝自动化和智能控制。通过与 MCP 服务器和客户端集成,它允许 AI 代理或外部工具与您的 Unity 环境交互,从而创建、修改和管理游戏对象、组件、资源、场景等。

  1. AI Tools
    1. GameObject
    2. Component
    3. Prefabs
    4. Editor
    5. Assets
    6. Scene
    7. Materials
    8. Scripts
  2. Installation
    1. Usage
      1. Add custom tool
        1. Contribution
          ID: 9jn15xt5xm