A Model Context Protocol (MCP) server for Unity Editor, enabling AI assistants like Claude to interact with Unity projects.
- 71 Tools for manipulating scenes, GameObjects, components, prefabs, transforms, reflection, capture, and more
- MCP Resources for live access to console logs, scene hierarchy, test results, and project files
- Auto-start Node.js server - no manual setup required
- Editor Window for monitoring and configuration
- Full test coverage with unit and integration tests
- Unity 2022.3 LTS or later (Unity 6 recommended)
- Node.js 18 or later
cd YOUR_PROJECT/Packages
git clone https://github.com/Singtaa/UnityMCP.git com.singtaa.unity-mcp- Open Window > Package Manager
- Click the + button > Add package from git URL
- Enter:
https://github.com/Singtaa/UnityMCP.git
git submodule add https://github.com/Singtaa/UnityMCP.git Packages/com.singtaa.unity-mcp- Install the package
- Open Window > Unity MCP Server
- The server starts automatically when Unity opens
- Configure your AI assistant to connect to
http://127.0.0.1:5173/mcp
Settings are stored in ProjectSettings/McpSettings.json:
| Setting | Default | Description |
|---|---|---|
| HTTP Port | 5173 | Port for MCP HTTP server |
| IPC Port | 52100 | Port for Unity-Node TCP bridge |
| Auto Start | true | Start server on Unity launch |
| Auth Enabled | true | Require bearer token authentication |
The McpSettings.json ports are the team-preferred defaults (the file is meant to be committed). If they're taken when the server starts (typically by another Unity project's MCP server), a free port pair is allocated automatically and stored per-machine in UserSettings/McpPortOverride.json (gitignored), so one machine's port shuffle never gets committed to the team. Changing ports manually in the MCP Server window updates the shared settings and clears the local override. The window always shows the project's current endpoint URL.
Each open project runs its own server on its own port pair, so multiple Editors can be used side by side, each with its own MCP endpoint:
- The first project gets the default ports (HTTP 5173 / IPC 52100)
- The next project detects the ports are taken, asks the running server which project it belongs to (
bridge.identify), and auto-allocates the next free pair (e.g. 5174/52101) - Allocated ports are persisted per-machine, so endpoints stay stable across sessions
Point each AI assistant at the project's own endpoint (shown in Window > Unity MCP Server) with that project's own auth token. The server also validates project identity on every bridge connection, so an Editor can never take over a server belonging to a different project - even with misconfigured ports.
If you start the Node server manually (node src/server.js), set MCP_PROJECT_ROOT to the project path so Editors can identify it; without it, the server accepts whichever project connects first.
unity_scene_list- List all loaded scenesunity_scene_load- Load a sceneunity_scene_save- Save scene(s)unity_scene_new- Create a new sceneunity_scene_close- Close a scene
unity_gameobject_create- Create GameObjects (with optional primitives)unity_gameobject_find- Find GameObjects by name, tag, or pathunity_gameobject_delete- Delete GameObjectsunity_gameobject_set_active- Enable/disable GameObjectsunity_gameobject_set_parent- Reparent GameObjectsunity_gameobject_rename- Rename GameObjectsunity_gameobject_duplicate- Duplicate GameObjects
unity_component_list- List components on a GameObjectunity_component_add- Add componentsunity_component_remove- Remove componentsunity_component_set_enabled- Enable/disable componentsunity_component_get_properties- Get component propertiesunity_component_set_property- Set component properties
unity_transform_get- Get position/rotation/scaleunity_transform_set- Set position/rotation/scaleunity_transform_translate- Move by deltaunity_transform_rotate- Rotate by euler anglesunity_transform_look_at- Orient toward targetunity_transform_reset- Reset to identity
unity_selection_get/set/focus- Editor selectionunity_editor_execute_menu_item- Execute menu commandsunity_editor_notification- Show notificationsunity_editor_log- Log to consoleunity_editor_get_state- Get editor stateunity_editor_pause/step- Playmode controlunity_undo_*- Undo/redo operations
unity_prefab_load- Load a prefab asset for inspection/editingunity_prefab_save- Save changes to a prefabunity_prefab_get_hierarchy- Get full prefab hierarchyunity_prefab_find_component- Find component within prefab by path
unity_test_list- List available tests (returns structured JSON withstatusfield)unity_test_run- Run tests asynchronously, returnsrunIdfor pollingunity_test_run_sync- Start EditMode tests (not truly sync; pollget_results)unity_test_get_results- Get test results byrunId
Note: After domain reload (script recompilation), wait ~1 second before calling test tools. If
unity_test_listreturnsstatus: "not_ready", you can still run tests directly withunity_test_run(without filter) and see all tests in the results.
unity_capture_panel- Render a UI ToolkitPanelSettingsto a PNG (returned as an MCPimagecontent block). Renders to an off-screenRenderTextureso the output has no Scene chrome. Auto-detects the active panel viaUIDocuments in loaded scenes ifpanelPathis omitted.unity_capture_game_view- Capture the Game view to a PNG. UsesScreenCapture.CaptureScreenshotAsTexturein play mode.
Note:
unity_capture_panelcurrently produces a blank image in edit mode (offscreen render doesn't fire on the first frame aftertargetTextureis reassigned). Use play mode for reliable panel captures until this is resolved.unity_capture_game_viewonly works in play mode in Unity 6.3+ (PlayModeView.targetTextureis not exposed via reflection in edit mode).
unity_project_list_files- List project filesunity_project_read_text- Read text filesunity_project_write_text- Write text filesunity_assets_refresh- Refresh AssetDatabaseunity_assets_import- Import specific assets
unity_reflection_search_types- Search for types by name pattern across all assembliesunity_reflection_get_type_info- Get detailed structured JSON data about a type's membersunity_reflection_get_method_info- Get method overloads with full parameter detailsunity_reflection_get_public_api- Get concise C# interface stub (best for quick API overview)unity_reflection_get_assemblies- List all loaded assembliesunity_reflection_decompile- Decompile type/method to C# source codeunity_reflection_invoke_static- Invoke parameterless static methods/properties
| Resource URI | Description |
|---|---|
unity://console/logs |
Live console output |
unity://hierarchy |
Scene hierarchy |
unity://hierarchy/{scene} |
Specific scene hierarchy |
unity://tests/results |
Latest test results |
unity://project/files |
Project file tree |
┌─────────────────────────────────────────────────────────────┐
│ AI Assistant │
├─────────────────────────────────────────────────────────────┤
│ HTTP JSON-RPC (Port 5173) │
├─────────────────────────────────────────────────────────────┤
│ Node.js MCP Server (Server~/) │
├─────────────────────────────────────────────────────────────┤
│ TCP NDJSON (Port 52100) │
├─────────────────────────────────────────────────────────────┤
│ Unity Editor C# Bridge │
│ (McpBridge → ToolRegistry → MainThreadDispatcher) │
├─────────────────────────────────────────────────────────────┤
│ Unity APIs │
└─────────────────────────────────────────────────────────────┘
Open Window > General > Test Runner and run:
- EditMode tests for unit and integration tests
- PlayMode tests for runtime behavior
The Node.js server is in Server~/. Dependencies are installed automatically on first run.
MIT License - see LICENSE for details.
Contributions are welcome! Please read our contributing guidelines and submit PRs to the main branch.