Unity Code MCP Server 标志

Unity Code MCP Server

组织
Signal-Loop

Unity Code MCP Server is a powerful tool for the Unity Editor that gives AI Agents ability to perform any action using Unity Editor API. This includes scripts, scenes, prefabs, assets, configuration changes, and more.

发布者Signal-Loop
代码仓库UnityCodeMCPServer
语言C#
复刻数
5
星标数
19
可用工具
0
传输类型stdio
分类
许可协议MIT
链接
  • 将工具接入 AI 工作流

    Unity Code MCP Server 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 0 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 19 个 Star 和 5 个 Fork。

Unity Code MCP Server

Search the live Unity project

Inspect active scenes, components, assets, console output, settings, Play Mode state, and runtime values from an MCP client.

Execute directly inside the Editor

Create and modify GameObjects, prefabs, ScriptableObjects, import settings, and other Unity assets by executing C# in the Editor.

Verify with runtime feedback

Run Edit Mode and Play Mode tests, enter Play Mode, simulate player input, capture screenshots, read Unity console logs, and inspect live game state after actions.

Example agent workflow: Play Pong in a closed loop by using enter_play_mode, execute_csharp_script_in_unity_editor, play_unity_game, and read_unity_console_logs to search runtime state, execute input actions, verify the result, and adapt the next move. Play Pong game example

Real workflow example

See the full cities workflow example and transcript.

Table of contents

Tools

execute_csharp_script_in_unity_editor

Perform any task by executing generated C# scripts in Unity Editor context. Full access to UnityEngine, UnityEditor APIs, and reflection. Automatically captures logs, errors, and return values.

read_unity_console_logs

Read Unity Editor Console logs with configurable entry limits (1-1000, default 200)

run_unity_tests

Run Unity tests via TestRunnerApi. Supports EditMode, PlayMode, or both. Can run all tests or filter by fully qualified test names.

enter_play_mode

Enter Unity Play Mode, pause time and return immediately after triggering the transition. Intended to be used before gameplay automation tools.

play_unity_game

Temporarily unpause time, simulate configured Input System actions, collect logs, and pause again when finished.

get_unity_game_view_window_screenshot

Capture the current Unity Game View as an image without routing screenshot capture through gameplay input calls.

exit_play_mode

Exit Unity Play Mode, unpause time, and return immediately after triggering the transition.

get_unity_info

Returns information about the current Unity Editor project and the UnityCodeMcpServer settings.

Security considerations

This package executes LLM-generated C# code (including reflection code) with the same privileges as the Unity Editor process. You are responsible for securing your environment and for any changes or data loss caused by executed scripts.

Architecture

diagram Architecture diagram: The Unity Code MCP Server package runs inside the Unity Editor and communicates with an external MCP client (like an LLM agent) through a file-backed STDIO bridge.

STDIO Transport

Quick start

Requirements

  • Unity 2022.3 LTS or higher (tested on 2022.3.62f3 and 6000.2.7f2)
  • uv (Python package manager) for the bundled STDIO bridge: https://docs.astral.sh/uv/.

Installation

  1. Install uv:

  2. Install Unity Code MCP Server from Unity Package Manager. Open Window > Package Manager, click the + button, select Add package from git URL..., and enter:

https://github.com/Signal-Loop/UnityCodeMCPServer.git?path=Assets/Plugins/UnityCodeMcpServer
  1. Configure the skill install location. Open Tools/UnityCodeMcpServer/Show or Create Settings, scroll to the Skills section, and confirm or change the install directory. By default, first-time installs target .agents/skills/. Skills are installed and updated automatically when the package is installed or updated.

First Run

MCP client configuration

  1. Open your Unity project. Unity auto-starts the file-backed transport and watches .unityCodeMcpServer/messages in the project root.
  2. Configure your MCP client to run the bundled STDIO bridge.

STDIO

Example configuration (using uv to run the bridge):

The unity-code-mcp-stdio bridge forwards STDIO traffic to Unity through .unityCodeMcpServer/messages.

json
{
  "mcpServers": {
    "unity-code-mcp-stdio": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "C:/path/to/UnityProject/Assets/Plugins/UnityCodeMcpServer/Editor/STDIO~",
        "unity-code-mcp-stdio"
      ]
    }
  }
}

Server configuration (Unity)

  1. Access the settings via Tools/UnityCodeMcpServer/Show or Create Settings.
  2. Configure Verbose Logging for detailed diagnostics and optionally set Input Actions Asset for play_unity_game.

The file-backed transport exchanges request and response files through .unityCodeMcpServer/messages in the Unity project root.

Menu commands

General

  • Tools/UnityCodeMcpServer/Show or Create Settings — Open the server settings asset in the inspector

Agent skills

Unity Code MCP Server ships a set of AI agent skill files (Markdown documents that teach your agent how to use the server's tools effectively). These skills are installed automatically into the configured target directory whenever the package is installed or updated.

Installing skills

  1. Open the server settings: Tools/UnityCodeMcpServer/Show or Create Settings.
  2. Scroll to the Skills section.
  3. Choose the install directory from the dropdown:
  • GitHub targets .github/skills/
  • Claude targets .claude/skills/
  • Agents targets .agents/skills/
  • Custom shows a folder picker so you can select any directory
  1. The inspector shows the currently selected target directory label so you can verify exactly where skills will be copied.
  2. Package install and update runs copy the skills automatically.

Only new or changed .md files are copied. Files that are already up to date (matching content hash) are skipped.

Included skills

SkillDescription
executing-csharp-scripts-in-unity-editorTeaches the agent when and how to use execute_csharp_script_in_unity_editor, read_unity_console_logs, and run_unity_tests together as a reliable pipeline. Covers forbidden patterns, debugging loops, and common scripting patterns.
unity-game-playerTeaches the agent how to play and test Unity games in a closed loop using enter_play_mode, play_unity_game, execute_csharp_script_in_unity_editor, read_unity_console_logs, and exit_play_mode. Covers scene discovery, math-based action timing, and adaptive re-sensing.

Extending (adding tools)

Add Tools, Prompts, Resources, or Async Tools by implementing the relevant interfaces (ITool, IToolAsync, IPrompt, IResource) anywhere in your codebase. The server will automatically detect and register them.

Synchronous tool

csharp
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using UnityCodeMcpServer.Interfaces;
using UnityCodeMcpServer.Protocol;

public class EchoTool : ITool
{
    public string Name => "echo";

    public string Description => "Echoes the input text back to the caller";

    public JToken InputSchema => JsonHelper.ParseElement(@"{
            ""type"": ""object"",
            ""properties"": {
                ""text"": {
                    ""type"": ""string"",
                    ""description"": ""The text to echo""
                }
            },
            ""required"": [""text""]
        }");

    public ToolsCallResult Execute(JToken arguments)
    {
        var text = arguments.GetStringOrDefault("text", "");

        return ToolsCallResult.TextResult($"Echo: {text}");
    }
}

Asynchronous tool

csharp
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using UnityCodeMcpServer.Interfaces;
using UnityCodeMcpServer.Protocol;
using System.Threading.Tasks;

public class DelayedEchoTool : IToolAsync
{
    public string Name => "delayed_echo";

    public string Description => "Echoes the input text after a specified delay (demonstrates async tool)";

    public JToken InputSchema => JsonHelper.ParseElement(@"{
            ""type"": ""object"",
            ""properties"": {
                ""text"": {
                    ""type"": ""string"",
                    ""description"": ""The text to echo""
                },
                ""delayMs"": {
                    ""type"": ""integer"",
                    ""description"": ""Delay in milliseconds before echoing"",
                    ""default"": 1000
                }
            },
            ""required"": [""text""]
        }");

    public async Task<ToolsCallResult> ExecuteAsync(JToken arguments)
    {
        var text = arguments.GetStringOrDefault("text", "");
        var delayMs = arguments.GetIntOrDefault("delayMs", 1000);

        await Task.Delay(delayMs);

        return ToolsCallResult.TextResult($"Delayed Echo (after {delayMs}ms): {text}");
    }
}

Script execution context

By default, script execution context includes following assemblies:

  • Assembly-CSharp
  • Assembly-CSharp-Editor
  • System.Core
  • UnityEngine.CoreModule
  • UnityEditor.CoreModule

Unity Code MCP Server settings (Assets/Plugins/UnityCodeMcpServer/Editor/Resources/UnityCodeMcpServerSettings.asset) allow configuring additional assemblies to include in the script execution context. This is useful if your project has assemblies that your generated scripts need to reference.

To add additional assemblies use settings 'Additional Assemblies' section.

Additional Assemblies

STDIO bridge

See the bridge docs at README_STDIO.md.

Testing

Unity tests are in Assets/Tests/ and can be run via the Unity Test Runner.

Known Issues

GUID conflicts with existing dll files in the project

  • Unity Code MCP Server includes dll files in its package. If those files are already present in your project, you may see GUID conflicts. In our test cases it does not cause any issues, but if you encounter problems, please fill issue: Issues. Removing duplicate dlls from your project may resolve the conflicts.
GUID [eb9c83041c7a89c46bb6e20eab4484df] for asset 'Packages/com.signal-loop.unitycodemcpserver/Editor/Bin/Microsoft.CodeAnalysis.CSharp.dll' conflicts with:
  '[Path to dll file in your project]/Microsoft.CodeAnalysis.CSharp.dll' (current owner)
We can't assign a new GUID because the asset is in an immutable folder. The asset will be ignored.

License

MIT

将 Unity Code MCP Server MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 Unity Code MCP Server 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 此 MCP 通过您设备上的 TypingMind MCP 连接器在本地运行。

本地连接器设置指南

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请保持终端窗口及其中的进程运行。
3

将 Unity Code MCP Server 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 Unity Code MCP Server MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "unitycodemcpserver": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 Unity Code MCP Server MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 Unity Code MCP Server MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 Unity Code MCP Server 帮我完成这项任务吗?
Unity Code MCP Server
当然。我已阅读。
以下是我使用 Unity Code MCP Server 得到的结果。

常见问题

Unity Code MCP Server MCP 服务器有什么用途?

Unity Code MCP Server 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 Unity Code MCP Server MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您可以让 Claude、ChatGPT、Gemini 等不同 AI 模型,或您在 TypingMind 中配置的其他模型使用 Unity Code MCP Server,而无需为每个模型单独配置 MCP 服务器。

为什么在 TypingMind 中使用 Unity Code MCP Server MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是优秀的大语言模型聊天前端之一。连接 Unity Code MCP Server 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 Unity Code MCP Server MCP 连接到 TypingMind?

Unity Code MCP Server 通过 TypingMind 本地 MCP 连接器运行。当 MCP 服务器需要访问您计算机上的本地文件、桌面应用、命令行工具或私有资源时,这种方式最合适。

Unity Code MCP Server MCP 在 TypingMind 中提供哪些工具?

Unity Code MCP Server 提供 MCP 功能,您可以在 TypingMind 的插件页面启用这些功能,然后在聊天中使用,或将其分配给 AI 智能体。

使用 Unity Code MCP Server MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行掌控模型提供商、API 密钥、提示词和 MCP 配置。如果 Unity Code MCP Server 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇