English | 中文
- System Overview
- Architecture
- Source Code
- Usage
- Agent Skills Module
- Innovation
- Technical Features
- API Reference
- Troubleshooting
Unity3d MCP — Bridging AI and Unity for intelligent game development
Unity3d MCP (Model Context Protocol) is an AI–Unity integration system that connects AI assistants (e.g. Cursor, Claude, Trae) with the Unity Editor via a built-in MCP server, enabling an AI-driven Unity workflow.
- AI-driven development: Control the Unity Editor with natural language
- Seamless integration: Works with mainstream AI clients without changing your workflow
- Rich tooling: 40+ tools covering the full Unity development pipeline
- High performance: HTTP-based communication
- Extensible: Modular design for easy extension
- Zero config: Built-in MCP server inside Unity, no external dependencies
- Built-in MCP Server (C#): MCP protocol server inside the Unity Editor
- Unity Package (C#): Full Unity Editor plugin
- Tool ecosystem: 40+ Unity development tools
- Protocol: HTTP + JSON-RPC 2.0
Layers (top to bottom):
- AI client layer: Cursor, Claude, Trae, etc.
- MCP protocol layer: Unity built-in MCP server
- Communication layer: HTTP (configurable port, default 8000) + JSON-RPC 2.0
- Unity Editor layer: Unity Editor + Unity API
- Tool layer: 40+ tools + message-queue execution engine
Figure 1: Data flow from AI clients to the Unity Editor
Figure 2: Flow from AI instructions to Unity execution
AI client → FacadeTools → MethodTools → Unity API
- FacadeTools:
async_callandbatch_call - MethodTools: 40+ methods, invoked only via FacadeTools
- State-based routing
- Parameter validation and type conversion
- Unified error handling
- Configurable port (default 8000)
- Message queue processing
- Main-thread–safe execution
unity-package/Editor/Connect/
├── McpService.cs
├── McpServiceStatusWindow.cs
└── McpServiceGUI.cs
- McpService.cs: HTTP listener, MCP request handling
- Message queue: EnqueueTask / ProcessMessageQueue, main-thread execution
- Tool discovery: DiscoverTools, reflection-based registration of async_call / batch_call
- Runtime: StateTreeContext
- Editor/Executer: AsyncCall, BatchCall, ToolsCall, CoroutineRunner, McpTool, StateMethodBase, IToolMethod, etc.
- Editor/StateTree: StateTree, StateTreeBuilder
- Editor/Selector: HierarchySelector, ProjectSelector, IObjectSelector
- Editor/Tools: Hierarchy, ResEdit, Console, RunCode, UI, Storage, etc.
- Editor/GUI: McpServiceGUI, McpDebugWindow
- Hierarchy: hierarchy_create, hierarchy_search, hierarchy_apply
- ResEdit: edit_gameobject, edit_component, edit_material, edit_texture, …
- Project: project_search, project_operate
- UI: ugui_layout, ui_rule_manage, figma_manage
- Console: console_read, console_write
- RunCode: code_runner, python_runner
- Editor: base_editor, manage_package, gameplay, object_delete
- Storage: prefers, source_location
- Network: request_http
- Unity 2020.3+ (recommended 2022.3.61f1c1)
- MCP-capable AI client (Cursor / Claude / Trae)
- Windows / macOS / Linux
No extra Python or external dependencies for the Unity package.
Add to your AI client MCP config (e.g. ~/.cursor/mcp.json, Claude/VS/Trae equivalents):
{
"mcpServers": {
"unity3d-mcp": {
"url": "http://localhost:8000"
}
}
}- MCP Settings (
Edit → Project Settings → MCP): connection toggle, tool list, port (default 8000), log level, UI/Figma settings. - MCP Debug Window (
Window → MCP → Debug Window): call history, re-run, filter, export logs.
To avoid large context from full MCP tool lists and schemas, the project provides an Agent Skills module (see Agent Skills Module). Reference demo/.cursor/skills SKILL.md files in Cursor Rules or Agent config so the agent loads only the needed skill docs and then calls MCP, reducing token usage.
- Import the Unity package and open the project.
- The built-in MCP server starts automatically (default port 8000).
- In the AI client, try: "Create a Cube named Player".
- Create GameObject: "Create a Cube named Player"
- Batch: "Create 5 Enemy objects at (0,0,0), (1,0,0), …"
- Resources: "Download a random image and apply it to an Image component"
- Custom tools: Add classes under
unity-package/Editor/Tools/, inheritStateMethodBaseorIToolMethod, useToolNameAttribute; Unity discovers and registers them. - Batch: Use
batch_callwith an array of{ "func", "args" }for better performance.
The doc in README.zh-CN.md describes extended scenarios (AI texture generation, Poly Haven batch download, project architecture diagrams, performance analysis, test data generation, localization). Use python_runner and code_runner for automation.
The MCP protocol exposes full tool lists and parameter schemas to the AI, which can consume many tokens. The project adds a Skill module (unity-package/Skills/unity3d-skill/) used together with MCP: load skill docs on demand instead of all tool schemas at once.
- Unified skill entry: A single
SKILL.mdprovides a function overview (32 functions across 7 categories: Editor & Preferences, Code Execution, Scene & Hierarchy, GameObject & Component Editing, Project & Asset Management, UI & Layout, Gameplay & Networking). - JSON Schema references: Each function has a dedicated JSON Schema file in
references/<func_name>.json, containing fullargsschema,actionsenum (with conditional params), andresponseformat. - On-demand load: The agent reads the overview in
SKILL.mdto find the right function, then loads the specificreferences/<func_name>.jsonfor detailed parameter info — instead of loading all 32 tool schemas at once.
- MCP handles tool discovery and execution; Skills describe when and how to pass arguments.
- Reference
SKILL.mdin Cursor Rules or Agent config so the agent consults the overview and loads the relevant JSON schema on demand, then calls MCP. - This keeps full MCP capability while reducing tokens by not keeping 32+ tool descriptions in context.
unity-package/Skills/unity3d-skill/
├── SKILL.md # Function overview & category summary
└── references/ # JSON Schema for each function
├── base_editor.json
├── hierarchy_create.json
├── gameplay.json
├── request_http.json
└── ... (32 schemas total)
- FacadeTools (
async_call,batch_call) + 40+ MethodTools invoked only through them.
- State-based routing, parameter validation, unified error handling.
- Configurable port (default 8000), main-thread safety, EditorApplication.update–based queue.
- Async operations (e.g. HTTP, downloads) without blocking the main thread.
- Detect file types; for large content return metadata instead of full data to save memory and bandwidth.
- Communication: HTTP, JSON-RPC 2.0, message queue, batch calls
- Reliability: Configurable port, main-thread safety, error handling, timeouts
- Extensibility: Modular tools, reflection, custom tools, configurable parameters
- DX: Natural language, real-time feedback, logging, documentation
async_call — single call:
{
"func": "async_call",
"args": {
"func": "hierarchy_create",
"args": { "name": "Player", "primitive_type": "Cube", "source": "primitive" }
}
}batch_call — batch:
{
"func": "batch_call",
"args": [
{ "func": "hierarchy_create", "args": { "name": "Player", "primitive_type": "Cube" } },
{ "func": "edit_gameobject", "args": { "path": "Player", "position": [0, 1, 0] } }
]
}- Hierarchy: hierarchy_create, hierarchy_search, hierarchy_apply
- ResEdit: edit_gameobject, edit_component, edit_material, edit_texture
- Project: project_search, project_operate
- Network: request_http, figma_manage
Success: { "success": true, "message": "...", "data": { ... } }
Error: { "success": false, "message": "...", "error": "..." }
- Cannot connect: Ensure Unity is running, port 8000 (or your port) is free, firewall allows it; check Unity console.
- Disconnects: Check network, Unity performance, and timeout settings.
- Call fails: Check parameter format and types, ensure target objects exist, permissions.
- Partial batch failure: Reorder operations, check resource conflicts, try smaller batches.
- Slow response: Improve network, reduce Unity load, simplify operations.
- High memory: Destroy unused objects, release resources, check coroutine lifecycle.
- Enable detailed logs (e.g.
McpLoggerin Unity). - Use MCP Debug Window for history and re-run.
- Use network tools (e.g. Wireshark) if needed for HTTP.
Unity3d MCP connects AI assistants to the Unity Editor via a built-in MCP server, using a two-tier call architecture, message-queue execution, and main-thread safety. It provides 40+ tools across the Unity development pipeline.
- AI-driven: Natural language control of the Editor
- Rich: 40+ tools for the full pipeline
- Performant: HTTP + message queue
- Extensible: Modular, custom tools
- Compatible: Works with major AI clients
- Zero config: No external MCP process
- AI-assisted game development
- Automated resource and batch operations
- Education and training
- More Unity tools, visual tool authoring, performance and monitoring, multi-platform support, better debugging.
Document version: v2.0
Last updated: September 2025
Unity3d MCP Development Team


