MCP HubMCP Hub
justinpbarnett

unity-mcp

by: justinpbarnett

A Unity MCP server that allows MCP clients like Claude Desktop or Cursor to perform Unity Editor actions.

1609created 18/03/2025
Visit
Unity
Automation

πŸ“ŒOverview

Purpose: The Unity MCP Package aims to facilitate seamless communication between Unity and Large Language Models (LLMs) to automate workflows and enhance project capabilities.

Overview: The Unity MCP Server establishes a bidirectional communication channel between Unity and a Python server, enabling developers to programmatically manage assets, scenes, materials, and scripts within Unity, thus streamlining the development process.

Key Features:

  • Bidirectional Communication: Enables effortless data exchange between Unity and LLMs, enhancing interactivity.

  • Asset Management: Allows for the programmatic creation, importing, and manipulation of Unity assets, improving efficiency in project management.

  • Scene Control: Provides tools for managing scenes and game objects, simplifying complex scene setups and changes.

  • Material Editing: Facilitates easy modification of materials and their properties, allowing for quick visual adjustments.

  • Script Integration: Supports viewing, creating, and updating C# scripts directly within Unity, promoting a streamlined coding experience.

  • Editor Automation: Automates various Unity Editor functions, reducing repetitive tasks like building projects or testing environments.


Unity MCP ✨

Connect your Unity Editor to LLMs using the Model Context Protocol.

Unity MCP acts as a bridge, allowing AI assistants (like Claude, Cursor) to interact directly with your Unity Editor via a local MCP (Model Context Protocol) Client. Enable your LLM tools to manage assets, control scenes, edit scripts, and automate tasks within Unity.


Key Features πŸš€

  • πŸ—£οΈ Natural Language Control: Instruct your LLM to perform Unity tasks.
  • πŸ› οΈ Powerful Tools: Manage assets, scenes, materials, scripts, and editor functions.
  • πŸ€– Automation: Automate repetitive Unity workflows.
  • 🧩 Extensible: Designed to work with various MCP Clients.
Available Tools

Your LLM can use functions like:

  • read_console: Get messages from or clear the console.
  • manage_script: Manage C# scripts (create, read, update, delete).
  • manage_editor: Control and query the editor's state and settings.
  • manage_scene: Manage scenes (load, save, create, get hierarchy, etc.).
  • manage_asset: Perform asset operations (import, create, modify, delete, etc.).
  • manage_gameobject: Manage GameObjects: create, modify, delete, find, and component operations.
  • execute_menu_item: Execute a menu item via its path (e.g., "File/Save Project").

How It Works πŸ€”

Unity MCP connects your tools using two components:

  1. Unity MCP Bridge: A Unity package running inside the Editor. (Installed via Package Manager).
  2. Unity MCP Server: A Python server that runs locally, communicating between the Unity Bridge and your MCP Client. (Installed manually).

Flow: [Your LLM via MCP Client] <-> [Unity MCP Server (Python)] <-> [Unity MCP Bridge (Unity Editor)]


Installation βš™οΈ

Note: The setup is constantly improving as we update the package. Check back if you run into issues.

Prerequisites

Required Software
  • Git CLI: For cloning the server code. Download Git
  • Python: Version 3.12 or newer. Download Python
  • Unity Hub & Editor: Version 2020.3 LTS or newer. Download Unity
  • uv (Python package manager):
    pip install uv
    
  • An MCP Client:
    • Claude Desktop (Download)
    • Cursor (Download)
    • (Others may work with manual configuration)

Step 1: Install the Unity Package (Bridge)

  1. Open your Unity project.
  2. Go to Window > Package Manager.
  3. Click + -> Add package from git URL....
  4. Enter:
    https://github.com/justinpbarnett/unity-mcp.git?path=/UnityMcpBridge
    
  5. Click Add.
  6. The MCP Server should automatically be installed onto your machine as a result of this process.

Step 2: Configure Your MCP Client

Connect your MCP Client (Claude, Cursor, etc.) to the Python server you installed in Step 1.

Option A: Auto-Configure (Recommended for Claude/Cursor)

  1. In Unity, go to Window > Unity MCP.
  2. Click Auto Configure Claude or Auto Configure Cursor.
  3. Look for a green status indicator 🟒 and "Connected". (This attempts to modify the MCP Client's config file automatically).

Option B: Manual Configuration

If Auto-Configure fails or you use a different client:

  1. Find your MCP Client's configuration file (check client documentation).
    • Claude Example (macOS): ~/Library/Application Support/Claude/claude_desktop_config.json
    • Claude Example (Windows): %APPDATA%\Claude\claude_desktop_config.json
  2. Edit the file to add/update the mcpServers section, using the exact paths from Step 1.
OS-Specific JSON Configuration Snippets

Windows:

{
  "mcpServers": {
    "UnityMCP": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "C:\\Users\\YOUR_USERNAME\\AppData\\Local\\Programs\\UnityMCP\\UnityMcpServer\\src",
        "server.py"
      ]
    }
  }
}

(Replace YOUR_USERNAME and use double backslashes \\)

macOS:

{
  "mcpServers": {
    "UnityMCP": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "/usr/local/bin/UnityMCP/UnityMcpServer/src",
        "server.py"
      ]
    }
  }
}

(Replace paths as needed)

Linux:

{
  "mcpServers": {
    "UnityMCP": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "/home/YOUR_USERNAME/bin/UnityMCP/UnityMcpServer/src",
        "server.py"
      ]
    }
  }
}

(Replace YOUR_USERNAME)


Usage ▢️

  1. Open your Unity Project. The Unity MCP Bridge (package) should connect automatically. Check status via Window > Unity MCP.
  2. Start your MCP Client (Claude, Cursor, etc.). It should automatically launch the Unity MCP Server (Python) using the configured setup.
  3. Interact! Unity tools should now be available in your MCP Client.

Example Prompt: Create a 3D player controller.


Contributing 🀝

Help make Unity MCP better!

  1. Fork the main repository.
  2. Create a branch (feature/your-idea or bugfix/your-fix).
  3. Make changes.
  4. Commit (e.g., feat: Add cool new feature).
  5. Push your branch.
  6. Open a Pull Request against the master branch.

Troubleshooting ❓

Common Issues and Fixes
  • Unity Bridge Not Running/Connecting:

    • Ensure Unity Editor is open.
    • Check the status window: Window > Unity MCP.
    • Restart Unity.
  • MCP Client Not Connecting / Server Not Starting:

    • Verify Server Path matches the exact location of the UnityMCP installation.
    • Verify uv is installed (pip show uv).
    • Run the server manually from terminal:
      cd /path/to/UnityMCP/UnityMcpServer/src
      uv run server.py
      
    • Permissions (macOS/Linux): Ensure you have execute permission; installing in your home directory (~/bin) may help.
  • Auto-Configure Failed:

    • Try Manual Configuration as Auto-Configure may lack permissions to write to config files.

Still stuck? Open an Issue in the project repository.


License πŸ“œ

MIT License. See LICENSE file.


Contact πŸ‘‹

  • X/Twitter: @justinpbarnett

Acknowledgments πŸ™

Thanks to the contributors and the Unity team.