unity-mcp
CLAUDE.md15k starsChanged 11 months agoMITView on GitHub
MCP for Unity is a bridge that lets AI assistants (Claude, Cursor, Windsurf, etc.) control the Unity Editor through the Model Context Protocol (MCP). It enables AI-driven game development workflows - creating GameObjects, editing scripts, managing assets, running tests, and more. Two codebases, one system: - Server/ - Python MCP server using FastMCP - MCPForUnity/ - Unity C# Editor package The Python server has three distinct layers. These are not auto-generated from each other: MCP tools call Unity via WebSocket…
Trending
Less talk lately.about the whole repository
Who's talking about CoplayDev/unity-mcp
- A Hacker News story“Show HN: Open-source Unity MCP for game developers”Hacker News · Oct 8, 2025 · 2 points
- @epicvibecoder.bsky.social“unity mcp bridges your ai and the unity editor: spawn objects, edit c# scripts, run tests and build scenes, …”Bluesky · Jul 6, 2026 · 1 likes
- @karashiiro.moe“Actually there are a few Unity MCP servers so this is the specific one I used: github.com/CoplayDev/un...”Bluesky · May 21, 2026 · 1 likes
- dsarno/unity-mcp“Harden HTTP defaults and improve stop-server fallback”GitHub · Feb 13, 2026 · 1 reactions
- dsarno/unity-mcp“fix: parse and validate read_console types”GitHub · Jan 15, 2026 · 1 reactions
The biggest 5 of 24 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 24
Talked about on GitHub, Bluesky and Hacker News (24 times).
On GitHub · 21
- Feb 13, 2026Harden HTTP defaults and improve stop-server fallback — dsarno/unity-mcp1 reaction · 4 comments
- Jan 15, 2026fix: parse and validate read_console types — dsarno/unity-mcp1 reaction · 4 comments
- Oct 4, 2026agent-skills.github.coplaydev.unity-mcp: 10.2.0 → 10.3.0 — sudosubin/agents.nix0 reactions
- Sep 26, 2026agent-skills.github.coplaydev.unity-mcp: init at 10.2.0 — sudosubin/agents.nix0 reactions
- Aug 24, 2026Unity project under version control and the MCP for Unity bridge — entewurzelauskuh/Lucid0 reactions · 1 comment
16 more on GitHub
- Aug 16, 2026[Failure KB 4/9] GitHub issues / changelogsから2026実エラーを収集する — KAFKA2306/unity-mcp0 reactions · 1 comment
- Aug 16, 2026[Failure KB 1/9] FailureRecord schemaと2026年seed 10件を固定する — KAFKA2306/unity-mcp0 reactions · 1 comment
- Aug 16, 2026[Epic] 2026 VRChat / Unity failure knowledge baseを構築する — KAFKA2306/unity-mcp0 reactions · 1 comment
- Jul 27, 2026Set up official Unity MCP bridge — rschroed/BoardRacing0 reactions · 1 comment
- Jul 6, 2026📱 SNS 콘텐츠 - 2026-07-06 19:22 KST — leaf468/autothreads0 reactions
- Jul 6, 2026🤖 AI 트렌드 리포트 - 2026-07-06 19:22 KST — leaf468/autothreads0 reactions
- Jul 5, 2026📱 SNS 콘텐츠 - 2026-07-05 12:28 KST — leaf468/autothreads0 reactions
- Jul 5, 2026🤖 AI 트렌드 리포트 - 2026-07-05 12:28 KST — leaf468/autothreads0 reactions
- Jun 6, 2026content(mcp): add Unity MCP Server — JSONbored/awesome-claude0 reactions · 3 comments
- May 19, 2026[Wishlist] Unity — HKUDS/CLI-Anything0 reactions
- Jan 25, 2026MCP로 UITK 기반 로그인 화면 디자인 제작 테스트 — XRWhale/Unity-AI-Playground0 reactions
- Jan 18, 2026Claiming namespace Coplay — EclipseFdn/open-vsx.org0 reactions
- Jan 10, 2026feat: add unity-mcp server for Unity Editor integration — docker/mcp-registry0 reactions
- Nov 23, 2025MCP Connection Failed in Google Antigravity — ahujasid/mcp-for-blender0 reactions · 4 comments
- Nov 21, 2025KiCad MCP Connection Issue: Initialize EOF Error in Google Antigravity — mixelpixx/KiCAD-MCP-Server0 reactions · 2 comments
- Sep 12, 2025Open Source Friday - Unity MCP - 03-27-2026 — githubevents/open-source-friday0 reactions · 17 comments
On Bluesky · 2
- Jul 6, 2026unity mcp bridges your ai and the unity editor: spawn objects, edit c# scripts, run tests and build scenes, all in plain language. works… — @epicvibecoder.bsky.social1 likes and repost
- May 21, 2026Actually there are a few Unity MCP servers so this is the specific one I used: github.com/CoplayDev/un... — @karashiiro.moe1 likes and repost · 1 reply
On Hacker News · 1
- Oct 8, 2025Show HN: Open-source Unity MCP for game developers2 points
In this repository4 other files it gives its agents.
- blender-to-unitySkill
- mcp-sourceSkill
- unity-mcp-orchestratorSkill
- unity-mcp-orchestratorSkill
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
21 rules. About 0 are common, 9 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 50
Avoid premature abstraction.
- Very specific: line 53
When removing functionality, delete it completely.
- Distinctive: line 56
Every new feature needs tests.
- Distinctive: line 62
Keep them smart and focused rather than "read everything" type resources.
- Very specific: line 122
Use ToolParams for consistent parameter validation:
- Distinctive: line 133
Always page results that could be large (hierarchies, components, search results):
- Very specific: line 134
Use page_size and cursor parameters
- Very specific: line 138
Use CommandRegistry.InvokeCommandAsync to call other tools from within a handler:
- Very specific: line 148
When you touch a shim or anything else gated by #if UNITY_*_OR_NEWER, run tools/check-unity-versions.sh to compile-check across the CI …
- Very specific: line 190
Use mcp_source.py to switch Unity package sources
- Distinctive: line 191
Test on Windows and Mac if possible, and multiple clients (Claude Desktop and Claude Code are tricky for configuration as of this writing)
- Very specific: line 194
Add Python MCP tool in Server/src/services/tools/manage_<domain>.py using @mcp_for_unity_tool
- Very specific: line 195
Add Python CLI commands in Server/src/cli/commands/<domain>.py using Click
- Very specific: line 196
Add C# implementation in MCPForUnity/Editor/Tools/Manage<Domain>.cs with [McpForUnityTool]
- Very specific: line 197
Add Python tests in Server/tests/test_manage_<domain>.py
- Very specific: line 198
Add Unity tests in TestProjects/UnityMCPTests/Assets/Tests/
- Distinctive: line 202
Don't add features without tests
- Distinctive: line 203
Don't create helper functions for one-time operations
- Distinctive: line 204
Don't add error handling for scenarios that can't happen
- Very specific: line 205
Don't commit to main directly - branch off beta for PRs
- Distinctive: line 206
Don't add docstrings/comments to code you didn't change
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
What This Project Is
MCP for Unity is a bridge that lets AI assistants (Claude, Cursor, Windsurf, etc.) control the Unity Editor through the Model Context Protocol (MCP). It enables AI-driven game development workflows - creating GameObjects, editing scripts, managing assets, running tests, and more.
Architecture
AI Assistant (Claude/Cursor)
↓ MCP Protocol (stdio/HTTP)
Python Server (Server/src/)
↓ WebSocket + HTTP
Unity Editor Plugin (MCPForUnity/)
↓ Unity Editor API
Scene, Assets, ScriptsTwo codebases, one system:
Server/- Python MCP server using FastMCPMCPForUnity/- Unity C# Editor package
Three Layers on the Python Side
The Python server has three distinct layers. These are not auto-generated from each other:
| Layer | Location | Framework | Purpose |
| MCP Tools | Server/src/services/tools/ | FastMCP (@mcp_for_unity_tool) | Exposed to AI assistants via MCP protocol |
| CLI Commands | Server/src/cli/commands/ | Click (@click.command) | Terminal interface for developers |
| Resources | Server/src/services/resources/ | FastMCP (@mcp_for_unity_resource) | Read-only state exposed to AI assistants |
MCP tools call Unity via WebSocket (send_with_unity_instance). CLI commands call Unity via HTTP (run_command). Both route to the same C# HandleCommand methods.
Transport Modes
- Stdio: Single-agent only. Separate Python process per client. Legacy TCP bridge to Unity. New connections stomp old ones.
- HTTP: Multi-agent ready. Single shared Python server. WebSocket hub at
/hub/plugin. Session isolation viaclient_id.
Code Philosophy
1. Domain Symmetry
Python MCP tools mirror C# Editor tools. Each domain exists in both:
Server/src/services/tools/manage_material.py↔MCPForUnity/Editor/Tools/ManageMaterial.cs- CLI commands (
Server/src/cli/commands/) also mirror these but are a separate implementation.
2. Minimal Abstraction
Avoid premature abstraction. Three similar lines of code is better than a helper that's used once. Only abstract when you have 3+ genuine use cases.
3. Delete Rather Than Deprecate
When removing functionality, delete it completely. No _unused renames, no // removed comments, no backwards-compatibility shims for internal code.
4. Test Coverage Required
Every new feature needs tests. Run them before PRs.
5. Keep Tools Focused
Each MCP tool does one thing well. Resist the urge to add "convenient" parameters that bloat the API surface.
6. Use Resources for Reading
Keep them smart and focused rather than "read everything" type resources. Resources should be quick and LLM-friendly.
Key Patterns
Python MCP Tool Registration
Tools in Server/src/services/tools/ are auto-discovered. Use the @mcp_for_unity_tool decorator:
from services.registry import mcp_for_unity_tool
@mcp_for_unity_tool(
description="Does something in Unity.",
group="core", # core (default), vfx, animation, ui, scripting_ext, testing, probuilder, profiling, docs, asset_gen
)
async def manage_something(
ctx: Context,
action: Annotated[Literal["create", "delete"], "Action to perform"],
) -> dict[str, Any]:
unity_instance = await get_unity_instance_from_context(ctx)
params = {"action": action}
response = await send_with_unity_instance(async_send_command_with_retry, unity_instance, "manage_something", params)
return responseThe group parameter controls tool visibility. Only "core" is enabled by default. Non-core groups (vfx, animation, etc.) start disabled and are toggled via manage_tools.
Python CLI Error Handling
CLI commands (not MCP tools) use the @handle_unity_errors decorator:
@handle_unity_errors
async def my_command(ctx, ...):
result = await call_unity_tool(...)C# Tool Registration
Tools are auto-discovered by CommandRegistry via reflection. Use the [McpForUnityTool] attribute:
[McpForUnityTool("manage_something", AutoRegister = false, Group = "core")]
public static class ManageSomething
{
// Sync handler (most tools):
public static object HandleCommand(JObject @params)
{
var p = new ToolParams(@params);
// ...
return new SuccessResponse("Done.", new { data = result });
}
// OR async handler (for long-running operations like play-test, refresh, batch):
public static async Task<object> HandleCommand(JObject @params)
{
// CommandRegistry detects Task return type automatically
await SomeAsyncOperation();
return new SuccessResponse("Done.");
}
}Async handlers use EditorApplication.update polling with TaskCompletionSource — see RefreshUnity.cs for the canonical pattern.
C# Parameter Handling
Use ToolParams for consistent parameter validation:
var p = new ToolParams(parameters);
var pageSize = p.GetInt("page_size", "pageSize") ?? 50;
var name = p.RequireString("name");C# Resources
Resources use [McpForUnityResource] and follow the same HandleCommand pattern as tools. They provide read-only state to AI assistants.
Paging Large Results
Always page results that could be large (hierarchies, components, search results):
- Use
page_sizeandcursorparameters - Return
next_cursorwhen more results exist
Composing Tools Internally (C#)
Use CommandRegistry.InvokeCommandAsync to call other tools from within a handler:
var result = await CommandRegistry.InvokeCommandAsync("read_console", consoleParams);Unity API Compatibility Shims
We support a wide Unity version range (2021+ → 6.x → CoreCLR 6.8). When an API is renamed, deprecated, or removed across versions, don't sprinkle #if UNITY_x_y_OR_NEWER at every call site — add a shim in MCPForUnity/Runtime/Helpers/Unity*Compat.cs and route every caller through it.
The catalog of active shims, the policy for when to add one, what does NOT belong in a shim, and the reflection-cache pattern all live in MCPForUnity/Runtime/Helpers/UnityCompatShims.cs — the XML doc on that empty marker class is the source of truth and ships inside the UPM package, so end-users can F12/Go-to-definition into it. Sources for current deprecations: Unity 6.x upgrade guides and the CoreCLR 2026 thread.
When you touch a shim or anything else gated by #if UNITY_*_OR_NEWER, run tools/check-unity-versions.sh to compile-check across the CI matrix locally before committing — the matrix lives in tools/unity-versions.json.
Commands
Running Tests
# Python (all tests)
cd Server && uv run pytest tests/ -v
# Python (single test file)
cd Server && uv run pytest tests/test_manage_material.py -v
# Python (single test by name)
cd Server && uv run pytest tests/ -k "test_create_material" -v
# Unity - open TestProjects/UnityMCPTests in Unity, use Test Runner window
# Local multi-version compile check (parity with CI matrix, see tools/unity-versions.json)
tools/check-unity-versions.sh # compile-only across installed Unity Hub editors
tools/check-unity-versions.sh --full # full EditMode test run
# License-free Roslyn compile of MCPForUnity, the same gate compile-check.yml runs on every PR.
# No Editor launch, ~1 min per version. EXTRA_REFS must hold Newtonsoft.Json.dll and
# nunit.framework.dll (copy them from TestProjects/UnityMCPTests/Library/PackageCache);
# the script header has the full recipe, including the Windows/Git Bash form.
UNITY_DATA=/path/to/Editor/Data UNITY_VERSION=2021.3.45f2 EXTRA_REFS=/path/to/refs tools/compile-check.shLocal headless test harness
One command boots a headless Hub-licensed Editor against TestProjects/UnityMCPTests and runs the smoke + EditMode + PlayMode legs over the bridge — the same entrypoint CI uses (.github/workflows/e2e-bridge.yml):
python tools/local_harness.pyKey flags: --legs smoke,editmode,playmode (subset to run), --project-path (target project, default TestProjects/UnityMCPTests), --reuse (attach to an already-resident bridge instead of booting one), --keep-alive (leave the Editor running after the legs), --no-warmup (skip the warm-up import phase).
Exit codes: 0 pass, 1 blocking-leg regression, 2 bridge unreachable / setup failure, 3 project does not compile, 4 no Unity license / Hub seat, 5 Editor binary/version not found. Requires a Hub-activated Editor locally (no ULF/serial).
Local Development
- Set Server Source Override in MCP for Unity Advanced Settings to your local
Server/path - Enable Dev Mode checkbox to force fresh installs
- Use
mcp_source.pyto switch Unity package sources - Test on Windows and Mac if possible, and multiple clients (Claude Desktop and Claude Code are tricky for configuration as of this writing)
Adding a New Tool
- Add Python MCP tool in
Server/src/services/tools/manage_<domain>.pyusing@mcp_for_unity_tool - Add Python CLI commands in
Server/src/cli/commands/<domain>.pyusing Click - Add C# implementation in
MCPForUnity/Editor/Tools/Manage<Domain>.cswith[McpForUnityTool] - Add Python tests in
Server/tests/test_manage_<domain>.py - Add Unity tests in
TestProjects/UnityMCPTests/Assets/Tests/
What Not To Do
- Don't add features without tests
- Don't create helper functions for one-time operations
- Don't add error handling for scenarios that can't happen
- Don't commit to
maindirectly - branch offbetafor PRs - Don't add docstrings/comments to code you didn't change
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

