A community-driven registry for Claude, Cursor, Windsurf, Cline & more. Not affiliated with Anthropic.
Are you the author? Sign in to claim
Unity Editor integration with Model Context Protocol (MCP) enabling AI assistants like Claude to interact with Unity pro
Unity Editor と Model Context Protocol (MCP) を統合する拡張フレームワークです。Claude などの AI 言語モデル、または CLI (curl) から、HTTP 経由で Unity Editor を直接操作できます。
target パラメータ or プロキシで名前指定ルーティングSessionState で port を永続化し、リロード跨ぎで同 port を自動再バインド/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 パッケージマネージャからインストール:
https://github.com/isuzu-shiranui/UnityMCP.git?path=jp.shiranui-isuzu.unity-mcp を入力McpEditorInitializer が自動的に HTTP サーバを立ち上げます (127.0.0.1:27182、27182-27199 でフォールバック)curl http://127.0.0.1:27182/health で動作確認💡 macOS 利用者へ: v2.1 で Homebrew 経由の Node (
/opt/homebrew/bin/node、/usr/local/bin/node) の検出に対応しました。Finder から起動した Unity が PATH を継承しない環境でも動作します (#7)。
unity-mcp-ts リポジトリをクローン or リリース ZIP を取得npm install && npm run build を実行して build/index.js を生成claude_desktop_config.json に追加:{
"mcpServers": {
"unity-mcp": {
"command": "node",
"args": ["/absolute/path/to/unity-mcp-ts/build/index.js"]
}
}
}
Windows ではパスのバックスラッシュをエスケープ (\\) するか、フォワードスラッシュを使ってください。
TypeScript サーバ不要で、HTTP 直叩きから操作可能:
# ヘルスチェック
curl http://127.0.0.1:27182/health
# C# コード実行
curl -X POST http://127.0.0.1:27182/execute_code \
-H "Content-Type: application/json" \
-d '{"code":"return GameObject.FindObjectsByType<Transform>(FindObjectsSortMode.None).Length;"}'
# Inspector のスクショ (Windows)
curl -X POST http://127.0.0.1:27182/capture_screenshot \
-H "Content-Type: application/json" \
-d '{"view":"inspector","maxSize":1024}'
マルチ Editor 用にプロキシ経由の例:
# 複数 Unity が起動中なら TS サーバの :27180 で discover
curl http://127.0.0.1:27180/projects
# プロジェクト名指定でリクエスト転送
curl -X POST http://127.0.0.1:27180/proxy/MyProject/health
Skill として ~/.claude/skills/unity-mcp/ に curl ワークフロー集を同梱しています。
MCP client (Claude)
│ stdio (MCP protocol)
▼
unity-mcp-ts (Node)
├── HandlerAdapter / HandlerDiscovery (MCP tools / prompts / resources)
├── UnityConnection (HTTP fetch + retryableFetch)
│ ├── sendRequest(cmd, params) → POST /command
│ └── sendToEndpoint(path, body) → POST <path> (e.g. /execute_code)
├── ProjectRegistry (UDP :27183, state machine)
└── ProjectApi :27180-27189 (/projects, /proxy/:name/*)
│ HTTP
▼
Unity Editor(s) — McpHttpServer :27182-27199
├── HttpListener + main-thread execution queue
├── Built-in shortcuts + plugin handlers
└── UDP broadcast (27183) every 30s
Safe / Unsafe enumlimit / offset / fields を処理する共通ユーティリティInitializeOnLoad + AssemblyReloadEvents で SessionState 経由 port 復元src/handlers/ を走査して ICommandHandler / IPromptHandler / IResourceHandler を自動登録/projects + /proxy/:name/*err.cause.code ベースで Unsafe は pre-handshake のみリトライ| 種別 | 用途 | MCP 制御 | 実装インターフェース |
|---|---|---|---|
| Tools (Command) | アクション実行 | モデル制御 | IMcpCommandHandler (C#) / BaseCommandHandler (TS) |
| Resources | データ提供 | アプリ制御 | IMcpResourceHandler (C#) / BaseResourceHandler (TS) |
| Prompts | テンプレ / ワークフロー | ユーザ制御 | BasePromptHandler (TS のみ) |
| Endpoint | Idempotency | 概要 |
|---|---|---|
GET /health | Safe | バージョン、ハンドラー一覧、稼働時間 |
POST /execute_code | Unsafe | Roslyn で C# を動的コンパイル・実行 |
POST /browse_hierarchy | Safe | シーン階層をフィルタ付きで取得 (limit/offset/fields 対応) |
POST /inspect | read/list: Safe、write: Unsafe | GameObject / Component のプロパティ読み書き |
POST /capture_screenshot | Safe | Game / Scene / Editor パネル (inspector / hierarchy / project / console / window:<title>) のキャプチャ |
POST /read_logs | Safe | Console ログを取得 (limit/offset/fields/type) |
POST /play_mode | status: Safe、他: Unsafe | Play Mode 制御 (status/play/stop/pause/unpause/step) |
GET /resource | Safe | assemblies / packages 情報 |
POST /command | per-command | プラグイン系 (menu.execute、console.*) |
unity_listClients、unity_setActiveClient、unity_connectToProject、unity_getActiveClient、unity_execute_code、console_getLogs、console_getCount、console_clear、console_setFilter、menu_execute
code_execute: unity_execute_code 用の C# コードテンプレートすべての tool / endpoint は任意で target パラメータ (projectName or clientId) を受け、複数 Editor 環境でルーティングを明示できます。
using Newtonsoft.Json.Linq;
using UnityMCP.Editor.Core;
namespace YourNamespace.Handlers
{
internal sealed class YourCommandHandler : IMcpCommandHandler
{
public string CommandPrefix => "yourprefix";
public string Description => "ハンドラーの説明";
public McpIdempotency Idempotency => McpIdempotency.Safe; // Unsafe なら明示
public JObject Execute(string action, JObject parameters)
{
if (action == "yourAction")
{
return new JObject { ["result"] = "..." };
}
// エンベロープ側で自動的に error envelope に promote される
return new JObject { ["error"] = $"Unknown action: {action}" };
}
}
}
import { BaseCommandHandler } from "../core/BaseCommandHandler.js";
import { IMcpToolDefinition } from "../core/interfaces/ICommandHandler.js";
import { JObject } from "../types/index.js";
import { z } from "zod";
export class YourCommandHandler extends BaseCommandHandler {
public get commandPrefix(): string { return "yourprefix"; }
public get description(): string { return "ハンドラーの説明"; }
public getToolDefinitions(): Map<string, IMcpToolDefinition> {
const tools = new Map();
tools.set("yourprefix_yourAction", {
description: "アクションの説明",
parameterSchema: { param1: z.string() }
});
return tools;
}
protected async executeCommand(action: string, parameters: JObject): Promise<JObject> {
return this.sendUnityRequest(`${this.commandPrefix}.${action}`, parameters);
}
}
import { BasePromptHandler } from "../core/BasePromptHandler.js";
import { IMcpPromptDefinition } from "../core/interfaces/IPromptHandler.js";
export class YourPromptHandler extends BasePromptHandler {
public get promptName(): string { return "yourprompt"; }
public get description(): string { return "プロンプトの説明"; }
public getPromptDefinitions(): Map<string, IMcpPromptDefinition> {
const prompts = new Map();
prompts.set("your-template", {
description: "テンプレートの説明",
template: "以下のコードを分析してください:\n{code}"
});
return prompts;
}
}
💡 C# ハンドラーはプロジェクト内のどこに置いても
McpHandlerDiscoveryが自動検出します。TS はunity-mcp-ts/src/handlers/に置けばHandlerDiscoveryが自動登録します。
Edit > Preferences > Unity MCP:
⚠️ v2.1 で
Auto-restart on Play Mode Changeを削除しました。Play Mode 遷移はドメインリロードを伴う場合のみ server を Stop/Start し、AssemblyReloadEvents経由で自動復元します。
| Variable | 既定 | 説明 |
|---|---|---|
MCP_RELOAD_RETRY_MAX_MS | 15000 | ドメインリロード中の再試行時間上限 (ms) |
MCP_UNHEALTHY_COOLDOWN_MS | 60000 | reloading → unhealthy への昇格までの猶予 |
MCP_PROJECT_API_PORT | 27180 | ProjectApi 開始ポート (27180-27189 フォールバック) |
MCP_UDP_PORT | 27183 | UDP announce 受信ポート |
MCP_HEALTH_INTERVAL | 10000 | ヘルスポーリング間隔 (ms) |
Editor/Tests/ — 23 ケース (ListResponseBuilder / Envelope / Idempotency / ScreenshotCapture)unity-mcp-ts/src/__tests__/ — 68 ケース (UnityConnection / ProjectRegistry / ProjectApi / retry / cache)cd unity-mcp-ts
npm test # Jest 68/68 pass 期待
| 症状 | 対応 |
|---|---|
/health に接続できない | Unity Editor が起動しているか、MCP パッケージが import されているか、27182-27199 のいずれかが listen しているか確認 |
target_required エラー | 複数 Unity 起動中 + target 未指定。unity_setActiveClient か target パラメータで明示 |
| ドメインリロード後に切れる | v2.1 では自動再バインド。SessionState が機能していない場合は Unity ログ確認 |
| C# ハンドラーが登録されない | Editor アセンブリで internal/public、IMcpCommandHandler 実装、コンパイルエラー無しを確認 |
| Node が検出されない (Mac) | v2.1 で Homebrew パスにフォールバック対応。最新版を利用 (#7) |
詳細なエラーコードは unity-mcp-ts/README.md または Skill api-reference.md 参照。
/execute_code は任意の C# を実行できます。不特定多数がアクセスできる環境では McpSettings から無効化するか、listener を loopback のみに制限してください (v2.x は既定で 127.0.0.1 のみ bind)。MIT License — 詳細はリポジトリのライセンスファイルを参照。
Shiranui-Isuzu いすず
MCP server integration for DaVinci Resolve Studio
Run Claude Code as an MCP server so any agent can delegate coding tasks to it
Browser automation using accessibility snapshots instead of screenshots
A Jetbrains IDE IntelliJ plugin aimed to provide coding agents the ability to leverage intelliJ's indexing of the codeba