Skip to main content
Glama
yangfch3

Unity MCP Server

by yangfch3

Unity MCP Server

中文 | English

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

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

特徴

  • ストリーミング可能なHTTP転送 — MCP 2025-03-26仕様に基づいた単一のHTTPエンドポイント

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

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

  • ドメインリロード時の自動復旧 — PlayModeへの移行/終了後にサービスが自動的に再起動

内蔵ツール

ツール

カテゴリ

機能

console_getLogs

debug

Unityコンソールの最新N件のログを取得

debug_getStackTrace

debug

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

debug_getPerformanceStats

debug

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

debug_screenshot

debug

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

menu_execute

editor

パスを指定してUnityメニュー項目を実行

playmode_control

editor

PlayModeの状態の移行/終了/クエリ

editor_getSelection

editor

現在選択されているGameObjectとAsset情報を取得

editor_getHierarchy

editor

シーンのGameObjectツリー構造を取得(深さ制限可能)

editor_getProjectStructure

editor

Assetsディレクトリ構造を取得(深さ制限可能)

editor_getInspector

editor

選択したオブジェクトのInspectorシリアライズフィールド値を取得

build_compile

build

スクリプトコンパイルをトリガーし、結果を返す

build_getCompileErrors

build

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

build_runTests

build

Unity Test Runnerのテストを実行し、結果を返す

インストール

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タグを追加できます:

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

Packages/manifest.json の設定例:

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

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

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

バージョンを更新する際は、manifest.json 内の #tag サフィックスを新しいバージョン番号に変更するか、UPM GUIで再度 Add package from git URL を行い、新しいタグの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 を参照してください。

ライセンス

MIT

-
security - not tested
A
license - permissive license
-
quality - not tested

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yangfch3/Unity-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server