Unity MCP 統合フレームワーク

by isuzu-shiranui

139 stars
449 downloads
Not rated
GitHub Website

About

Unity Editor integration with Model Context Protocol (MCP) enabling AI assistants like Claude to interact with Unity projects. Features a TypeScript MCP server and C# Unity plugin with extensible command handler architecture, TCP/IP communication, and dynamic plugin discovery.

Details

Author
isuzu-shiranui
GitHub stars
139
Downloads
449
Categories
Other

- HTTP + UDP auto‑discovery for multiple Unity Editors
- Works with MCP (Claude) and plain HTTP (curl, CI)
- Editor panel screenshot capture (Windows only)
- Built‑in C# code execution via Roslyn
- Extensible plugin architecture with auto‑registration
- Safe/Unsafe idempotency classification to prevent duplicate side effects

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Unity MCP 統合フレームワーク
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install the Unity package via Package Manager (Add package from git URL…). The HTTP server auto-starts on port 27182 (fallback 27182–27199). For Claude Desktop/Code, download the TypeScript MCP client using the built‑in installer and paste the generated config JSON. You can also call endpoints directly with curl. Configure options under Edit > Preferences > Unity MCP.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "unity mcp \u7d71\u5408\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af": {
            "unity-mcp": {
                "command": "node",
                "args": [
                    "/absolute/path/to/unity-mcp-ts/build/index.js"
                ]
            }
        }
    }
}

McpServers

{
    "unity-mcp": {
        "command": "node",
        "args": [
            "/absolute/path/to/unity-mcp-ts/build/index.js"
        ]
    }
}

Unity MCP 統合フレームワーク

License: MIT
Version
Unity
.NET
GitHub Stars

English Version

Unity Editor と Model Context Protocol (MCP) を統合する拡張フレームワークです。Claude などの AI 言語モデル、または CLI (curl) から、HTTP 経由で Unity Editor を直接操作できます。

🌟 特徴 (v2.1)

- HTTP + UDP アーキテクチャ: 各 Unity Editor が HTTP サーバを持ち、UDP ブロードキャストで自動 discovery
- MCP と HTTP の両方をサポート: Claude Desktop / Claude Code からは MCP tool 経由、スクリプト / CI からは curl 直叩き
- マルチ Editor 対応: 複数 Unity Editor を同時起動しても target パラメータ or プロキシで名前指定ルーティング
- ドメインリロード耐性: SessionState で port を永続化し、リロード跨ぎで同 port を自動再バインド
- Editor パネルキャプチャ (Windows): Inspector / Hierarchy / Project / Console などの任意 EditorWindow をスクリーンショット
- built-in コード実行: HTTP /execute_code と MCP tool unity_execute_code が標準装備 (Roslyn 使用)
- 拡張可能なプラグインアーキテクチャ: IMcpCommandHandler / IMcpResourceHandler / BasePromptHandler を実装すればリフレクションで自動登録
- 統一レスポンスエンベロープ: {status, result?, error?, truncated?, next?} で成功/エラー/ページングを一貫した形で返す
- コンテキスト経済: limit / offset / fields / detail パラメータでレスポンスを絞り込み可能
- 冪等性分類: Safe / Unsafe を per-action で宣言し、TS 側が err.cause.code を見て再送可否を制御 (副作用操作の二重実行を構造的に排除)

📋 必要条件

- Unity 2022.3 以上 (Unity 6000 系対応)
- 2022.3.22f1、2023.2.19f1、6000.0.35f1、6000.1.17f1 で動作確認
- .NET / C# 9.0
- Node.js 18.0.0 以上 (TypeScript MCP サーバ用)
- Node.js 公式サイト から入手

🚀 はじめに

インストール方法

Unity パッケージマネージャからインストール:

1. Window > Package Manager を開く
2. 「+」 → 「Add package from git URL...」
3. https://github.com/isuzu-shiranui/UnityMCP.git?path=jp.shiranui-isuzu.unity-mcp を入力

クイックセットアップ

1. Unity Editor を起動すると、McpEditorInitializer が自動的に HTTP サーバを立ち上げます (127.0.0.1:27182、27182-27199 でフォールバック)
2. Edit > Preferences > Unity MCP で設定を確認
3. curl http://127.0.0.1:27182/health で動作確認

Claude Desktop / Claude Code との連携

インストーラーを使う場合

1. Unity Editor で Edit > Preferences > Unity MCP を開く
2. 「Open Installer Window」をクリック
3. インストーラーの指示に従い、Node.js の存在確認後、TypeScript クライアントをダウンロード
4. 「Configuration Preview」セクションの JSON をクリップボードへコピー
5. Claude Desktop の Settings > Developer > Edit Config で貼り付けて保存
6. Claude Desktop を再起動

> 💡 macOS 利用者へ: v2.1 で Homebrew 経由の Node (/opt/homebrew/bin/node/usr/local/bin/node) の検出に対応しました。Finder から起動した Unity が PATH を継承しない環境でも動作します (#7)。

手動でインストールする場合

1. unity-mcp-ts リポジトリをクローン or リリース ZIP を取得
2. npm install && npm run build を実行して build/index.js を生成
3. Claude Desktop の claude_desktop_config.json に追加:

{
  "mcpServers": {
    "unity-mcp": {
      "command": "node",
      "args": ["/absolute/path/to/unity-mcp-ts/build/index.js"]
    }
  }
}

Windows ではパスのバックスラッシュをエスケープ (\\) するか、フォワードスラッシュを使ってください。

CLI (curl) でも使える

TypeScript サーバ不要で、HTTP 直叩きから操作可能:

```bash

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.