Unity MCP Server

Unity MCP servers enable AI models to interact with the Unity Editor, providing capabilities for scene manipulation, asset management, script editing, and game development automation.

GitHub starsnpm versionnpm downloads

Overview

The MCP Unity Server bridges AI and the Unity Editor, allowing language models (LLMs) to directly interact with Unity projects. It's part of the Model Context Protocol (MCP) system, providing a safe and standard way to connect AI with game development workflows. Other notable implementations include CoplayDev/unity-mcp (Python) and IvanMurzak/Unity-MCP (Docker).

Developed by:

Primary implementation by CoderGamester

Key Features

🎮

Scene \u0026 GameObject Management

Create, modify, and delete GameObjects, components, and scenes

📦

Asset \u0026 Project Control

Import, create, modify, and delete assets; manage packages and project settings

✍️

Scripting \u0026 Code Assistance

Edit C# scripts, validate code, and automate script-related tasks

⚙️

Editor Automation \u0026 Testing

Automate repetitive editor workflows and run tests within the Unity Test Runner

Available Tools

Quick Reference

ToolPurposeCategory
execute_menu_itemExecutes Unity menu itemsEditor
select_gameobjectSelects GameObjects in hierarchyScene
update_gameobjectUpdates or creates GameObjectsScene
update_componentUpdates or adds components to GameObjectsScene
add_packageInstalls new Unity packagesProject
run_testsRuns Unity Test Runner testsTesting
send_console_logSends a log message to Unity consoleDebugging
add_asset_to_sceneAdds an asset to the current sceneScene
create_prefabCreates a prefabAssets

Detailed Usage

execute_menu_item

Executes Unity menu items (functions tagged with the MenuItem attribute).

use_mcp_tool({
  server_name: "unity",
  tool_name: "execute_menu_item",
  arguments: {
    menu_item_path: "GameObject/Create Empty"
  }
});
select_gameobject

Selects game objects in the Unity hierarchy by path or instance ID.

use_mcp_tool({
  server_name: "unity",
  tool_name: "select_gameobject",
  arguments: {
    path: "Main Camera"
  }
});
update_gameobject

Updates a GameObject's core properties (name, tag, layer, active/static state), or creates the GameObject if it does not exist.

use_mcp_tool({
  server_name: "unity",
  tool_name: "update_gameobject",
  arguments: {
    name: "Player",
    tag: "Enemy",
    is_active: false
  }
});
update_component

Updates component fields on a GameObject or adds it to the GameObject if it does not contain the component.

use_mcp_tool({
  server_name: "unity",
  tool_name: "update_component",
  arguments: {
    game_object_name: "Player",
    component_type: "Rigidbody",
    properties: {
      mass: 5
    }
  }
});
add_package

Installs new packages in the Unity Package Manager.

use_mcp_tool({
  server_name: "unity",
  tool_name: "add_package",
  arguments: {
    package_name: "com.unity.textmeshpro"
  }
});
run_tests

Runs tests using the Unity Test Runner.

use_mcp_tool({
  server_name: "unity",
  tool_name: "run_tests",
  arguments: {
    test_mode: "EditMode"
  }
});
send_console_log

Sends a console log to Unity.

use_mcp_tool({
  server_name: "unity",
  tool_name: "send_console_log",
  arguments: {
    message: "Hello from MCP!"
  }
});
add_asset_to_scene

Adds an asset from the AssetDatabase to the Unity scene.

use_mcp_tool({
  server_name: "unity",
  tool_name: "add_asset_to_scene",
  arguments: {
    asset_path: "Assets/Prefabs/Player.prefab"
  }
});
create_prefab

Creates a prefab with optional MonoBehaviour script and serialized fields.

use_mcp_tool({
  server_name: "unity",
  tool_name: "create_prefab",
  arguments: {
    name: "NewCubePrefab",
    path: "Assets/Prefabs",
    game_object_name: "Cube",
    component_type: "MeshRenderer"
  }
});

Installation

{
  "mcpServers": {
    "unity": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "mcp-unity"
      ],
      "env": {
        "UNITY_PROJECT_PATH": "/path/to/your/unity/project"
      }
    }
  }
}

Sources