tea-x-random/unity-game-skills/unity-mcp-bridge
Claude Code and agent skill by tea-x-random/unity-game-skills
- community
Checking that the SKILL.md file is still in the repository.
Drive a live Unity Editor through CoplayDev MCP for Unity from GPT/Codex, Claude Code, or another MCP client. Use for real Editor actions: scenes, GameObjects, components, prefabs, materials, scripts, Play Mode, tests, console, asset import and builds. Covers HTTP setup, tool groups, editor readiness, domain-reload reconnects, no_unity_session recovery, headless iOS builds, and device-only debug HUDs. This is the execution layer beneath unity-game-director and other unity skills; use the documented headless CLI fallback when MCP is unavailable.
Install
npx vskill@latest install tea-x-random/unity-game-skills/unity-mcp-bridgeSKILL.md
The same SKILL.md was published earlier as tea-x-random/unity-game-skills/unity-mcp-bridge.
Unity MCP Bridge
This skill is how every other unity-* skill changes the project. It wraps MCP for Unity (CoplayDev, package com.coplaydev.unity-mcp): agent host → MCP (HTTP/stdio) → Python FastMCP server → WebSocket → Unity C# Editor package → Editor API. It controls a live, open Editor — not files on disk.
Prerequisites
- Unity Editor open and running with the package installed. Minimum Unity 2021.3 LTS; iOS Build Profiles (the build
profileparam) need Unity 6+. - Python 3.10+ with
uv/uvx. - The MCP status panel (
Window → MCP for Unity) must read Connected.
Setup for the active agent host (do once per project)
- Install the Unity package — Package Manager → + → Add package from git URL:
https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#main (or openupm add com.coplaydev.unity-mcp).
- Run the setup wizard that auto-opens after import; confirm Python +
uvare detected (green). - Register the active client. In Unity, use
Window → MCP for Unity → Configure All Detected Clients, or configurehttp://localhost:8080/mcpin the host's MCP settings. Claude Code also supports:
``bash claude mcp add --scope local --transport http UnityMCP http://localhost:8080/mcp `` Verify the Unity status panel says Connected.
Transport: prefer HTTP. stdio is single-agent only (new connections stomp old ones) and does not sync tool-group visibility or custom tools reliably.
Availability check & troubleshooting (do this FIRST, every session)
Before assuming you can drive the Editor, confirm the MCP is actually reachable — registration is not connection:
Also use the active host's tool/resource discovery. manage_scene, read_console, and mcpforunity://editor/state must be visible; a CLI registration list is secondary evidence.
If the Unity MCP tools (manage_scene, read_console, …) don't appear in tool search, they are not connected — do not pretend to use them. Diagnose in order:
- "✘ Failed to connect" / nothing on :8080 → the Unity-side server isn't running. In Unity open Window → MCP for Unity, wait for any compile/domain reload to finish, and Start/Connect the server; the panel must read Connected. The HTTP server hosts
:8080— if it won't start, checkuv/uvx(3.10+ Python) are installed and on PATH. - Not registered at all → use Unity's "Configure All Detected Clients" or add
http://127.0.0.1:8080/mcpin the active host's MCP settings. - Registered + server up but tools still absent in this session → the server probably started after the agent session. Restart the active host/session so MCP tools register at startup, then confirm them through tool/resource discovery. Start Unity MCP first, then the agent host.
- Editor closed → MCP can't work (it drives a live Editor). Either open it, or use the no-MCP fallback below.
No-MCP fallback (fully supported): when MCP can't connect and you must make progress, drive Unity headlessly via the CLI instead — author C# + an Editor [MenuItem], then Unity -batchmode -runTests / -executeMethod and grep the logs (see unity-qa-release › Headless batchmode verification). Always say which path you used; never claim live-Editor actions that did not happen.
Readiness check — do this before every batch of commands
Read mcpforunity://editor/state and proceed only when: ready_for_tools == true, is_compiling == false, is_domain_reload_pending == false.
Also read mcpforunity://project/info once up front to branch correctly: renderPipeline (shader names differ URP vs Built-in), activeInputHandler (Input System vs legacy), and the UI stack flags (UI Toolkit vs uGUI/TMP).
Tool groups — only core is enabled by default
Non-core tools do not exist until you enable their group. Enable what the phase needs:
core already includes scene, gameobject, component, asset, prefab, material, editor, console, build, packages, camera, physics, graphics, and all script tools. manage_tools, batch_execute, set_active_instance, manage_script, apply_text_edits, find_in_file are always on.
Full parameter reference: load references/tools-reference.md. Read-only resources: references/resources-reference.md. Upstream task recipes: references/upstream-workflows.md. ProBuilder: references/probuilder-guide.md. The hard-won reliability rules: load `references/reliability.md` before any script/compile/build sequence.
The golden command patterns
Create/edit a C# script (auto-imports + compiles — do NOT also call refresh_unity):
Use validate_script (Roslyn) before compiling and get_sha + precondition_sha256 to avoid clobbering.
Anti-hallucination for any C#/shader/UI you generate: call unity_reflect (live reflection over Unity/package/project APIs) or unity_docs first. Trust order: reflection > project assets > docs > memory. Mandatory on Unity 6.x.
Bulk scene/object building: batch_execute(commands=[...]) — up to 25 per call (100 max). NOT transactional; set fail_fast=true for dependent steps.
See what you built: manage_scene(action="screenshot", batch="surround", include_image=true, max_resolution=512) so the agent can visually iterate.
Import a generated GLB/FBX (from unity-3d-generator): write the file directly into Assets/... on disk (you have filesystem access), then refresh_unity(scope="assets", wait_for_ready=true). manage_asset(action="import") only reimports and cannot set import settings — configure scale/rig/materials/compression via execute_code driving ModelImporter. Instantiate with manage_gameobject(action="create", prefab_path=...).
Play-mode check: manage_editor(action="play") → read_console → screenshot → manage_editor(action="stop"). For real tests: run_tests(mode="PlayMode") → poll get_test_job(job_id, wait_timeout=...).
`execute_code` is a C# 6 method body via CodeDom (the tool's compiler:"auto" falls back to CodeDom unless Microsoft.CodeAnalysis/Roslyn is installed). It is real C#, not the JS sandbox — System.DateTime.Now etc. are fine. But the CodeDom path means: NO `using` directives, NO local functions, NO C#7+ syntax (e.g. some tuple forms). Write flat method-body code with fully-qualified type names (UnityEditor.EditorApplication.isCompiling), build multi-line output with System.Text.StringBuilder, and return a value to read it back. Pass compiler:"roslyn" only if Roslyn is actually installed.
After any C# edit, gate on a clean compile before using the new type: refresh_unity(mode="force", scope="scripts", compile="request", wait_for_ready=true), then poll UnityEditor.EditorApplication.isCompiling via execute_code (or read_console(types=["error"])) until clear. Using a freshly-added type before compile finishes silently fails or throws.
Portrait iPhone screenshot recipe (no MCP param exists for this). manage_camera/manage_scene screenshot captures at the Game view's current size, so for true portrait phone framing of Screen-Space-Overlay UI you must add and select a portrait FixedResolution size yourself, via execute_code + reflection:
- Get the
GameViewSizesScriptableSingleton (UnityEditor.GameViewSizes.instance) →GetGroup(currentGroupType), then find-or-AddCustomSize(new GameViewSize(GameViewSizeType.FixedResolution, w, h, baseText))(all underUnityEditor, accessed by reflection — these types are internal). - Select it on the
UnityEditor.GameViewwindow via the privateSizeSelectionCallback(index, null), set the internalselectedSizeIndex, thenRepaint(). The window'stargetSizeproperty is the authoritative render size (correctly reads e.g.(1242,2688)) — read it back to confirm, don't trustScreen.width/height. - Capture overlay UI with `UnityEngine.ScreenCapture.CaptureScreenshot(path)` (writes at end of frame at the Game View's target render size).
manage_camera(action="screenshot")with no `camera` arg also routes to this ScreenCapture path; do NOT pass acamera— a camera-render path excludes Screen-Space-Overlay canvases, so you capture only the camera background (a blank/incorrect image).
Common portrait sizes: 1242x2688 (iPhone XS Max/11 Pro Max), 1170x2532 (iPhone 12/13/14), 1080x1920.
`Screen.width/height` is unreliable inside `execute_code` — it returns the editor window / last-active-view pixels (e.g. 1739x1036), NOT the Game View's fixed render target, because the code doesn't run in the Game View's render context. Don't gate layout/capture logic on it. Read the real render size from the GameView targetSize property, or the laid-out UI size from the Canvas RectTransform.rect (the CanvasScaler lays out to the actual render target). (This supersedes the older "thin-strip Screen" note: the issue is the render context, not a strip.)
Throttled editor → stale Game View captures. An unfocused / background-throttled Editor doesn't repaint the Game View, so ScreenCapture.CaptureScreenshot can write the last rendered frame rather than the current state (e.g. a UI panel you just hid still appears). Mitigate by keeping the Editor focused during capture, or force a render right before capturing: EditorApplication.QueuePlayerLoopUpdate() + Canvas.ForceUpdateCanvases() + the GameView window's .Repaint() — or capture on-device. Always verify the screenshot's content, not just its pixel dimensions.
Capturing a transient VFX before the screenshot fires. A one-shot effect shorter than the MCP round-trip (e.g. a <2.5s confetti burst) is already gone by the time screenshot runs. Immediately after spawning it, set UnityEditor.EditorApplication.isPaused = true via execute_code — coroutine-driven animation freezes at its first-frame layout so the screenshot captures it; restore isPaused = false after. The spawned objects must start on-screen or the frozen frame is empty.
iOS build sequence: manage_build(action="platform", target="ios") → manage_build(action="settings", property="bundle_id"|"product_name"|"company_name"|"version") → set scripting_backend="il2cpp" (iOS requires it) → manage_build(action="scenes", ...) → manage_build(action="build", target="ios", output_path="Builds/iOS/<name>") → poll action="status". Output is an Xcode project folder, not an .ipa — signing/archive happens outside MCP via xcodebuild on macOS.
Headless iOS build via MCP + on-device diagnostics
The Editor manage_build(action="build") flow above works for routine builds, but for a CI-shaped, fully-scripted iOS build — and for diagnosing things that only break on the device — drive a static build method and a runtime debug HUD instead. Full walkthrough + copy-paste code: load `references/ios-build-and-device-diagnostics.md`. The load-bearing facts:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/unity-mcp-bridge/SKILL.md
Popularity
- Repository stars
- 3
- 7-day trend score
- 7
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/tea-x-random/unity-game-skills/unity-mcp-bridge)