Unity x Claude MCP Server
An MCP server that provides 20 tools to control the Unity Editor with natural language, including scene management, component manipulation, script generation, asset handling, project settings, builds, and live C# execution.
README
<p align="center"> <img src="https://img.shields.io/badge/Unity-2021.3%2B-black?logo=unity" alt="Unity 2021.3+"/> <img src="https://img.shields.io/badge/License-MIT-green" alt="MIT License"/> <img src="https://img.shields.io/badge/MCP-Compatible-blue" alt="MCP Compatible"/> <img src="https://img.shields.io/badge/C%23_Lines-5.7k-blueviolet" alt="5.7k Lines of C#"/> <img src="https://img.shields.io/badge/CPU_When_Idle-0%25-brightgreen" alt="0% CPU When Idle"/> </p>
<h1 align="center">Unity x Claude</h1>
<p align="center"> <strong>Control the Unity Editor with natural language.</strong><br/> An MCP server that gives Claude 20 tools to create scripts, build scenes, modify components, manage assets, change settings, run builds, and execute C# — all from a conversation. </p>
Features
20 tools covering every part of the Unity Editor:
- Scene control — create, delete, duplicate, and inspect GameObjects. Read the full hierarchy with depth control, filter by tag or component.
- Component system — add, remove, read, and modify any component. Batch-update multiple properties in a single call. Wire object references between components.
- Script generation — create MonoBehaviours, ScriptableObjects, EditorWindows from templates. Modify existing scripts with find/replace, method injection, or full rewrites.
- Asset management — search by name or type, create Materials, Prefabs, ScriptableObjects, Folders. Import and re-import assets.
- Project settings — read and write Physics, Player, Quality, Audio, Time, Graphics, Input, Tags, Editor, and Navigation settings. All changes undoable.
- Build system — build for Windows, macOS, Linux, WebGL, Android, or iOS. Development builds, custom BuildOptions.
- Editor commands — play, pause, stop, step, save, undo, redo, compile, refresh. Run any Unity menu item.
- Live C# execution — run arbitrary C# inside the editor with full access to UnityEngine and UnityEditor APIs. Compiled in-memory — no temp files, no domain reload, instant results.
Built for performance:
- Zero CPU when idle — single background thread blocked on
Socket.Poll. No async, no ThreadPool, no polling loops, no timers. - Survives domain reloads — auto-restarts after script recompilation via
[InitializeOnLoad]. 5-second safety net ensures the server is always running. - Pure C# — no external dependencies, no DLLs, no NuGet packages. Just drop the folder into your project.
Built for safety:
- Everything is undoable — all destructive operations go through Unity's Undo system. Ctrl+Z works on every change Claude makes.
- Dangerous operations blocked —
execute_csharpblocksProcess.Start,Environment.Exit,Registry.*, and other unsafe calls. - Port cleanup — server registers
ProcessExitandDomainUnloadhandlers so the port is always released.
Built for testing:
- Runtime data during Play mode — component queries automatically include live position, rotation, velocity, and sleep state for physics objects.
- Screenshot verification — capture what the camera sees, describe visible objects with screen positions, simulate clicks on objects.
- Smart snapshots — schedule timed screenshots at animation keyframes to verify visual behavior with minimum captures.
Works with:
- Claude Desktop (via stdio bridge)
- Claude Code (direct HTTP)
- Cursor (direct HTTP)
- Any MCP-compatible client
Installation
Step 1 — Add to your Unity project
Clone this repo (or download ZIP) and copy everything into your project's Packages folder:
YourProject/
Packages/
com.claude.unity-mcp/ ← put it here
Editor/
package.json
mcp-bridge.mjs
Open Unity. The console should show:
[MCP] Ready on port 9999
Verify at Window > Claude MCP — shows server status, port, and all available tools.
Step 2 — Connect Claude
Open your Claude config file:
| OS | Path |
|---|---|
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
Add this (create the file if it doesn't exist):
{
"mcpServers": {
"unity": {
"command": "node",
"args": [
"/full/path/to/YourProject/Packages/com.claude.unity-mcp/mcp-bridge.mjs"
]
}
}
}
Shortcut: In Unity, click Window > Claude MCP > Copy Config — it copies the JSON with the correct path. Just paste it into the file.
<details> <summary>Using Claude Code or Cursor instead?</summary>
These support direct HTTP — no bridge needed:
{
"mcpServers": {
"unity": {
"url": "http://localhost:9999/mcp"
}
}
}
</details>
Step 3 — Add the skill files
This is what makes Claude actually good at using the tools. Without these files, Claude can connect but won't know property paths, workarounds, batch patterns, or testing workflows.
Copy SKILL.md and WORKFLOW.md into Claude's skills folder:
# macOS / Linux
mkdir -p ~/.claude/skills/unity-x-claude
cp SKILL.md WORKFLOW.md ~/.claude/skills/unity-x-claude/
# Windows (PowerShell)
mkdir -Force "$env:USERPROFILE\.claude\skills\unity-x-claude"
copy SKILL.md, WORKFLOW.md "$env:USERPROFILE\.claude\skills\unity-x-claude\"
<details> <summary>Using Claude Code or Cursor?</summary>
Put them in your project's .claude/skills/ folder instead:
mkdir -p YourProject/.claude/skills/unity-x-claude
cp SKILL.md WORKFLOW.md YourProject/.claude/skills/unity-x-claude/
</details>
What these files teach Claude:
| File | What Claude learns |
|---|---|
SKILL.md |
All 20 tools with usage patterns, property paths for every common component (Transform, Rigidbody, Collider, Camera, Light, AudioSource), batch operation patterns, depth strategies, settings categories |
WORKFLOW.md |
Architecture, known gotchas with workarounds, runtime data inspection, screenshot testing pipeline, domain reload handling, port conflict recovery, safe C# execution patterns |
Step 4 — Restart and test
Restart Claude Desktop (or start a new chat). Try:
- "What's in my Unity scene?"
- "Create a red cube at position 0, 3, 0 with a Rigidbody"
- "Change the gravity to -20 and set the quality level to Ultra"
If Claude responds with your scene data, you're done.
Tool Reference
| Category | Tools | Examples |
|---|---|---|
| Scene | get_scene, create_gameobject, delete, duplicate |
Read hierarchy, spawn objects with components, clone objects |
| Components | get_components, set_property, add_component, remove_component |
Inspect properties, batch-update 10+ values, wire references |
| Scripts | create_script, modify_script |
Generate MonoBehaviours, find/replace in code, add methods |
| Assets | search_assets, get_asset, create_asset, import_asset |
Find materials, create prefabs, re-import textures |
| Editor | editor_command, get_selection, set_selection, scene_view |
Play/stop, save, undo, frame camera on object |
| Settings | get_settings, set_settings |
Read/write Physics, Player, Quality, Audio, Time, Graphics |
| Build | build, manage_packages, get_console |
Build for any platform, add packages, read errors |
| Code | execute_csharp |
Run any C# with full Unity API access, in-memory compilation |
All tools are prefixed with
unity_(e.g.,unity_get_scene). See SKILL.md for the full reference with property paths and workflow patterns.
Architecture
Claude Desktop / Claude Code / Cursor
|
| stdio (JSON-RPC 2.0)
v
mcp-bridge.mjs Node.js — translates stdio ↔ HTTP
|
| HTTP POST localhost:9999/mcp
v
Unity Editor (MCPServer)
|
├── StreamableHttpServer Raw TcpListener, single thread, Socket.Poll
├── MainThreadDispatcher ConcurrentQueue → EditorApplication.update
├── JsonRpcHandler JSON-RPC 2.0 parsing
├── 8 Tool modules Scene, Component, Asset, Script, Editor, Settings, Build, Execute
└── Serialization GameObject → JSON, Asset → JSON, Property helpers
Why zero CPU when idle
| Component | Idle behavior |
|---|---|
StreamableHttpServer |
Thread blocked on Socket.Poll(1s) — true kernel wait, zero CPU |
MainThreadDispatcher |
ConcurrentQueue.TryDequeue returns false — single boolean check per frame |
MCPServer.Tick() |
One EditorApplication.update callback — nanosecond cost when empty |
| Status Window | No continuous repaint — updates only on interaction |
Compatibility
| Supported | |
|---|---|
| Unity | 2021.3 LTS and newer (tested on Unity 6.0) |
| Render Pipeline | URP, HDRP, Built-in |
| OS | macOS, Windows |
| MCP Clients | Claude Desktop, Claude Code, Cursor, or any MCP-compatible client |
| Node.js | Required for stdio bridge (Claude Desktop). Not needed for direct HTTP clients. |
Troubleshooting
| Problem | Fix |
|---|---|
| Claude can't connect | Make sure Unity is open and Window > Claude MCP shows "Running" |
| Server not starting | Enable the toggle in Window > Claude MCP, or recompile (Ctrl+R) |
| Wrong project path | Use Window > Claude MCP > Copy Config to get the correct path |
| Node.js not found | Install Node.js — the bridge needs it: node --version |
| Port 9999 in use | Change port in Window > Claude MCP > Advanced Settings, update config to match |
| Calls fail after recompile | Normal — server restarts in 2-5 seconds. Just retry. |
Contributing
Pull requests welcome. If you add a new tool, follow the pattern in Editor/Tools/ and update SKILL.md with usage examples.
License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。