A Unity Package Manager (UPM) package that enables Claude Code to directly control Unity Editor through the Model Context Protocol (MCP).
- Direct Unity Control: Claude Code can manipulate GameObjects, components, and scene hierarchy
- Console Integration: Send and retrieve Unity console logs
- Hot Reload: Trigger script compilation and asset refresh
- Real-time Monitoring: Get compilation status and error information
- Menu Automation: Execute Unity menu items programmatically
- Package Management: Add packages through Package Manager
- Scene Management: Read and modify scene hierarchy
- Unity 2021.3 or later
- Node.js 16+ (for MCP server)
- Claude Code with MCP support
- Open Unity Package Manager (
Window > Package Manager) - Click
+and selectAdd package from git URL... - Enter:
https://github.com/aiacats/unity-mcp.git?path=Packages/com.aiacats.unity-mcp
Add to your Packages/manifest.json:
{
"dependencies": {
"com.aiacats.unity-mcp": "https://github.com/aiacats/unity-mcp.git?path=Packages/com.aiacats.unity-mcp"
}
}If you prefer to manage the package as a Git submodule:
# Add as submodule
git submodule add https://github.com/aiacats/unity-mcp.git
# Initialize submodules (for cloned projects)
git submodule update --init --recursive- Clone or download this repository
- Copy the package folder to your project's
Packages/directory - Unity will automatically detect and import the package
Navigate to the Server~ directory and install dependencies:
cd Packages/com.aiacats.unity-mcp/Server~
npm installThe MCP server starts automatically when Unity Editor launches. No additional configuration required!
If you need custom settings:
- Open
Tools > Claude Code MCP > Control Panel - Configure server settings as needed
- Test connection with built-in test tools
Create a .mcp.json file in your project root:
{
"mcpServers": {
"claude-code-mcp-unity": {
"command": "node",
"args": ["Packages/com.aiacats.unity-mcp/Server~/index.js"],
"env": {
"MCP_UNITY_HTTP_URL": "http://localhost:8090"
}
}
}
}Once installed, Claude Code can control Unity using natural language:
- "Create a new GameObject named 'Player' in the scene"
- "Add a Rigidbody component to the selected GameObject"
- "Show me the current scene hierarchy"
- "Check for compilation errors"
- "Trigger a hot reload"
- select_gameobject: Select objects in hierarchy
- get_gameobject_info: Get detailed GameObject info (Transform, components, hierarchy)
- update_gameobject: Modify GameObject properties (or create new)
- delete_gameobject: Delete a GameObject from the scene
- update_component: Add/modify components
- get_component_properties: Read all serialized properties of a component
- remove_component: Remove a component from a GameObject
- save_scene: Save the active scene
- open_scene: Open a scene by path (single or additive)
- find_assets: Search AssetDatabase with filter, type, and folder
- add_asset_to_scene: Instantiate prefabs and assets
- create_material: Create Material assets with shader and color
- get_material_properties: Get all shader properties of a material with current values
- set_material_property: Set shader properties (Float, Int, Color, Vector, Texture, Range, Keyword)
- execute_menu_item: Run Unity menu commands
- add_package: Install packages via Package Manager
- hot_reload: Trigger script recompilation
- force_compilation: Force full compilation
- screenshot: Capture entire Unity Editor window screenshot (Windows API)
- send_console_log: Send messages to Unity Console
- get_console_logs: Retrieve console messages
- check_compilation_status: Get real-time compilation status
- get_compilation_errors: Get build errors and warnings
- run_tests: Run Unity Test Runner tests
- Scene Hierarchy Resource: Access complete scene structure
When Claude Code implements code in a Unity project with this package, the following automated flow should be used:
- Implement code — Edit C# scripts via file operations
- Compile — Call
hot_reload(orforce_compilationfor full rebuild) - Wait for compilation — Poll
check_compilation_statusuntil complete (timeout: 5 minutes) - Check errors — Call
get_compilation_errors. If errors exist, fix and go back to step 1 - Run tests — Call
run_testswith the appropriatetestMode(EditMode / PlayMode) - Wait for results — Poll
run_testswithqueryOnly: trueuntil complete (timeout: 5 minutes) - Check results — If tests fail, fix and go back to step 1
Note: Test code should be provided by the consuming project, not this package. The project should have its own test assemblies under
Assets/Tests/(or similar) with appropriate.asmdeffiles referencingUnityEngine.TestRunnerandUnityEditor.TestRunner.
Access the control panel via Tools > Claude Code MCP > Control Panel:
- Server Status: Monitor connection and port status
- Server Controls: Start/stop/restart MCP server
- Testing Tools: Built-in connection and functionality tests
- Configuration: Copy .mcp.json configuration to clipboard
Editor/
├── Core/
│ ├── MCPHttpServer.cs # HTTP server lifecycle & request routing
│ ├── MCPTestRunCallback.cs # Unity Test Framework callback
│ └── Handlers/
│ ├── IMCPHandler.cs # Handler interface
│ ├── HandlerBase.cs # Shared utilities (GameObject lookup, response helpers)
│ ├── GameObjectHandler.cs
│ ├── ComponentHandler.cs
│ ├── SceneHandler.cs
│ ├── CompilationHandler.cs
│ ├── ConsoleHandler.cs
│ └── EditorHandler.cs
├── UI/
│ ├── ClaudeCodeMCPWindow.cs # Editor control panel window
│ └── ClaudeCodeMCPStatusBar.cs # Scene view status overlay
├── MCPServerSetup.cs # Menu items for setup & control
└── ClaudeCodeMCPEditor.asmdef # Assembly definition
Server~/
└── index.js # Node.js MCP server (hidden from Unity)
This project is licensed under the MIT License.
- Built on the Model Context Protocol standard
- Powered by Claude Code AI assistant