Skip to main content
Glama
yangfch3

Unity MCP Server

by yangfch3

Unity MCP Server

中文 | English

Unity Editorプラグインであり、MCP (Model Context Protocol) を通じてUnity Editorの機能を外部AIエージェントに公開します。

エージェント(Kiro、Cursor、Claude Codeなど)は、標準のMCPプロトコルを介してUnity Editorに接続し、エディタ機能を呼び出すことができます。

理念

本プラグインは、AIエージェントの Unity認識レイヤー + 診断ツールチェーン として位置付けられています:

  • 認識優先 — 「シーン状態の読み取り、コンテキストの取得、診断支援」などの高頻度なシナリオを優先的にカバーし、エージェントが現在のプロジェクト状態を十分に理解し、開発の意思決定を支援できるようにします。

  • 構造化された書き込み — 安全で監査可能な書き込み操作機能(プロパティの変更、ノードの追加・削除など)を提供しますが、Unity Editor GUIのすべての操作をカバーすることは目指していません。

  • エディタの代替ではない — エンジニアとエージェントのコラボレーション効率を高めることを目的としており、エディタのすべての操作をダイアログボックスに移すことではありません。

Related MCP server: MCP Unity

特性

  • Streamable HTTP転送 — MCP 2025-03-26仕様に基づいた単一のHTTPエンドポイント

  • プロセス内実行 — 外部のNode.js/Pythonプロセスは不要で、エディタ内で直接起動

  • 拡張可能なツールシステム — IMcpTool インターフェースを実装するだけで新しいツールを登録可能、コアコードの変更は不要

  • Domain Reload自動復旧 — PlayModeへの移行/終了後にサービスが自動的に再起動

内蔵ツール

完全なパラメータ説明と使用例については、ツール詳細ドキュメントを参照してください。

Debugツール

ツール

機能

console_getLogs

Unity Consoleログの取得(フィルタリング対応)

console_clearLogs

ログバッファのクリア

debug_getStackTrace

最近のError/Exceptionの完全なスタックトレースを取得

debug_getPerformanceStats

FPS、DrawCall、メモリなどのパフォーマンス指標を取得

debug_screenshot

Game/Sceneビューのスクリーンショットを撮影

Editorツール

Query(クエリ)

ツール

機能

editor_getHierarchy

GameObjectツリー構造の取得

editor_getInspector

Inspectorのシリアライズされたフィールド値の取得

editor_getSelection

現在選択されているオブジェクト情報の取得

editor_findGameObjects

名前/コンポーネントによるGameObjectの検索

editor_getProjectPath

プロジェクトルートディレクトリパスの取得

editor_getProjectStructure

Assetsディレクトリ構造の取得

Mutation(変更)

ツール

機能

editor_addGameObject

GameObjectの追加

editor_deleteGameObject

GameObjectの削除

editor_setField

シリアライズされたフィールド値の変更

editor_setTransform

Transformプロパティの変更

editor_setActive

アクティブ状態の変更

editor_reparentGameObject

親ノードの変更

editor_addComponent

コンポーネントの追加

editor_removeComponent

コンポーネントの削除

editor_setComponentEnabled

コンポーネントの有効/無効化

editor_selectGameObject

指定したGameObjectの選択

Project(プロジェクト)

ツール

機能

menu_execute

パスによるUnityメニュー項目の実行

playmode_control

PlayMode状態の制御

Asset(アセット)

ツール

機能

asset_deleteFolder

Assetsサブディレクトリの削除

Buildツール

ツール

機能

build_compile

スクリプトコンパイルのトリガー

build_getCompileErrors

コンパイルエラーリストの取得

build_runTests

Test Runnerテストの実行

Codeツール(実験的、Unity 2022 Monoのみ)

ツール

機能

code_executeImmediate

C#コードの動的コンパイルと実行(メインスレッド/バックグラウンドのデュアルモード対応)

Window → MCP Serverパネルで手動で有効にする必要があります。詳細はツール詳細ドキュメントを参照してください。

インストール

Git URLインストール(推奨)

  1. Unity Editor → Window → Package Manager → + → Add package from git URL

  2. 以下のURLを入力:

https://github.com/yangfch3/Unity-MCP-Server.git

または、ホストプロジェクトの Packages/manifest.json を直接編集:

{
  "dependencies": {
    "com.yangfch3.unity-mcp": "https://github.com/yangfch3/Unity-MCP-Server.git"
  }
}

ローカルパスインストール

  1. 本リポジトリをクローン

  2. Unity Editor → Window → Package Manager → + → Add package from disk

  3. 本リポジトリルートの package.json を選択

または Packages/manifest.json に以下を追加:

{
  "dependencies": {
    "com.yangfch3.unity-mcp": "file:../../path/to/unity-mcp"
  }
}

バージョン更新

UPMでGit URLからインストールすると、ホストプロジェクトの packages-lock.json に現在のコミットハッシュがロックされます。その後、自動的には更新されません。

特定のバージョンをロックしたい場合は、URLの末尾にGit Tagを追加できます:

https://github.com/yangfch3/Unity-MCP-Server.git#v0.3.0

対応する Packages/manifest.json の設定:

{
  "dependencies": {
    "com.yangfch3.unity-mcp": "https://github.com/yangfch3/Unity-MCP-Server.git#v0.3.0"
  }
}

Tagを指定しない場合は、デフォルトブランチの最新コミットを追跡します:

{
  "dependencies": {
    "com.yangfch3.unity-mcp": "https://github.com/yangfch3/Unity-MCP-Server.git"
  }
}

バージョンを更新する際は、manifest.json 内の #tag サフィックスを新しいバージョン番号に変更するか、UPM GUIで再度Add package from git URLを行い、新しいTagのURLを入力してください。

使用方法

サービスの起動

  1. Unity Editor → Window → MCP Server

  2. ポートを設定(デフォルト8090)し、Startをクリック

  3. パネル内の設定JSONをコピー

エージェントの設定

以下の内容をエージェントのMCP設定ファイル(mcp.jsonなど)に追加します:

{
  "mcpServers": {
    "unity-mcp": {
      "url": "http://localhost:8090/"
    }
  }
}

拡張:カスタムツールの追加

IMcpTool インターフェースを実装し、任意のEditorアセンブリに配置すると、サービス起動時に自動的に検出・登録されます:

using System.Collections.Generic;
using System.Threading.Tasks;
using UnityMcp.Editor;

public class MyCustomTool : IMcpTool
{
    public string Name => "my_custom_tool";
    public string Category => "custom";
    public string Description => "我的自定义工具";
    public string InputSchema => "{\"type\":\"object\",\"properties\":{}}";

    public Task<ToolResult> Execute(Dictionary<string, object> parameters)
    {
        return Task.FromResult(ToolResult.Success("Hello from custom tool!"));
    }
}

要件

  • Unity 2022.3+

  • Editor環境のみ、ランタイムビルドには影響しません

貢献

本プロジェクトの開発への参加を歓迎します。詳細は CONTRIBUTING.md を参照してください。

License

MIT

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    A
    maintenance
    A bridge enabling seamless communication between Unity and Large Language Models via the Model Context Protocol, allowing developers to automate workflows, manipulate assets, and control the Unity Editor programmatically.
    14,777
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Implementation of the Model Context Protocol for Unity Editor, allowing AI assistants to interact with Unity projects through a Node.js server bridge.
    10 npm
    2
    MIT
  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    Enables AI assistants to interact with Unity Editor through the Model Context Protocol, allowing natural language control of Unity projects including scene manipulation, GameObject creation, component updates, package management, and test execution.
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server that integrates AI assistants like Claude and Cursor directly into the Unity Editor to automate game development workflows. It provides over 40 built-in tools for scene manipulation and project management, while offering a simple C# API for creating custom extensions.
    9
    GPL 3.0