unity-mcp
by: justinpbarnett
A Unity MCP server that allows MCP clients like Claude Desktop or Cursor to perform Unity Editor actions.
π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:
- Unity MCP Bridge: A Unity package running inside the Editor. (Installed via Package Manager).
- 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:
Step 1: Install the Unity Package (Bridge)
- Open your Unity project.
- Go to
Window > Package Manager
. - Click
+
->Add package from git URL...
. - Enter:
https://github.com/justinpbarnett/unity-mcp.git?path=/UnityMcpBridge
- Click
Add
. - 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)
- In Unity, go to
Window > Unity MCP
. - Click
Auto Configure Claude
orAuto Configure Cursor
. - 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:
- 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
- Claude Example (macOS):
- 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 βΆοΈ
- Open your Unity Project. The Unity MCP Bridge (package) should connect automatically. Check status via Window > Unity MCP.
- Start your MCP Client (Claude, Cursor, etc.). It should automatically launch the Unity MCP Server (Python) using the configured setup.
- Interact! Unity tools should now be available in your MCP Client.
Example Prompt: Create a 3D player controller.
Contributing π€
Help make Unity MCP better!
- Fork the main repository.
- Create a branch (
feature/your-idea
orbugfix/your-fix
). - Make changes.
- Commit (e.g., feat: Add cool new feature).
- Push your branch.
- 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.