MCP for Unity: AI assistant bridge for Unity Editor
Bridge that connects AI assistants like Claude, Cursor, and VSCode to Unity Editor via Model Context Protocol for AI-driven game development.
- Step 1
What is MCP for Unity?
MCP for Unity is a bridge that connects AI assistants to the Unity Editor through the Model Context Protocol (MCP). It enables AI-driven game development workflows by giving LLMs the ability to directly control and manipulate your Unity projects.
Built and maintained by Coplay and sponsored by Aura, this open-source project (MIT license) allows AI clients like Claude Code, Cursor, VSCode Copilot, and local LLMs to:
- Scene Management: Create, modify, and organize GameObjects in scenes
- Asset Operations: Manage materials, textures, prefabs, and other assets
- Script Editing: Generate and modify C# scripts with Roslyn validation
- Testing: Run Unity Test Framework tests programmatically
- VFX & Animation: Create visual effects and animations
- UI Development: Build UI elements and interfaces
- Profiling: Analyze performance metrics
The architecture uses a dual codebase design:
- Python Server: MCP server using FastMCP that exposes tools to AI assistants via stdio or HTTP transport
- Unity Plugin: C# Editor package that receives commands and executes them in the Unity Editor
Communication happens through WebSocket connections (or legacy TCP bridge in stdio mode), with the Python server acting as an intermediary between AI clients and the Unity Editor.
Architecture Overview: AI Assistant (Claude/Cursor/etc) via MCP Protocol (stdio/HTTP) ↓ Python MCP Server (FastMCP, FastAPI, httpx) - Tool Discovery - Request Routing - Session Management ↓ WebSocket + HTTP ↓ Unity Editor Plugin (C# Editor Package) - Command Executor - Unity API Integration ↓ Unity Editor API ↓ Unity Editor - Scenes, Assets, Scripts - Step 2
Technology stack
MCP for Unity is a polyglot system with both Python and C# codebases:
Python Server:
- Python 3.10+ (supports up to 3.14)
- FastMCP 3.x for MCP protocol implementation
- FastAPI for HTTP transport support
- httpx for async HTTP client operations
- Pydantic 2.x for data validation
- Click for CLI interface
- uv as the recommended package manager
- pytest for testing
Unity C# Package:
- Unity Editor 2021.3 LTS or newer
- C# with Unity API integration
- Newtonsoft.Json for JSON serialization
- Unity Test Framework for testing
- UPM (Unity Package Manager) package format
- WebSocketSharp for WebSocket communication
Architecture Patterns:
- MCP tools in
Server/src/services/tools/using@mcp_for_unity_tooldecorator - CLI commands in
Server/src/cli/commands/using Click - C# tools auto-discovered via reflection with
[McpForUnityTool]attribute - Domain-symmetric design: Python tools mirror C# Editor tools
- Async-first design with support for long-running operations
Transport Modes:
- Stdio: Single-agent, one Python process per MCP client
- HTTP: Multi-agent ready, session isolation via client_id
Python Server Dependencies: - FastMCP (MCP protocol) - FastAPI (HTTP server) - httpx (async HTTP) - Pydantic (validation) - Click (CLI framework) - uv (package manager) Unity Plugin Dependencies: - com.unity.nuget.newtonsoft-json (3.0.2) - com.unity.test-framework (1.1.31) Minimum Requirements: - Python 3.10+ - Unity Editor 2021.3 LTS+ - uv package manager (recommended) - Step 3
Prerequisites
Before setting up MCP for Unity, ensure you have the following:
System Requirements:
- Unity Editor 2021.3 LTS or newer installed
- Python 3.10 or newer (3.11, 3.12, 3.13, 3.14 all supported)
- uv package manager (highly recommended)
- Git installed (for package installation)
AI Client Setup: You'll need an MCP-compatible AI client such as:
- Claude Desktop or Claude Code
- Cursor IDE
- VSCode with Copilot Chat
- Any MCP-compliant client
Optional:
- Docker (for containerized server deployment)
- Unity Hub for managing multiple Unity versions
Verify Python installation:
# Check Python version (3.10+ required) python --version # Should show: Python 3.10.x or higher # Check if uv is installed (recommended) uv --version # If not installed, see installation below # If uv is not available, you can use pip pip --version - Step 4
Install uv package manager
The
uvpackage manager from Astral is the recommended way to install and run MCP for Unity. It's significantly faster than pip and provides reliable installations.macOS/Linux:
# Install uv (macOS/Linux) curl -LsSf https://astral.sh/uv/install.sh | sh # Or with wget wget -qO- https://astral.sh/uv/install.sh | sh # Verify installation uv --version - Step 5
Install uv on Windows
On Windows, use PowerShell or winget to install uv:
PowerShell:
# Install uv on Windows (PowerShell) powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" # Verify installation uv --version - Step 6
Install Unity Package
Install the MCP for Unity package into your Unity project. The package is available via Git URL, Asset Store, or OpenUPM.
Method 1: Git URL (Recommended)
In Unity Editor:
- Go to Window → Package Manager
- Click the + button in the top-left corner
- Select Add package from git URL...
- Paste one of the following URLs:
Stable version (main branch):
https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#main - Step 7
Beta version Git URL
Beta version (beta branch): Use this for the latest features before they hit stable:
https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#beta - Step 8
Configure Unity Package
After installing the package, configure it for your AI client:
- In Unity Editor, go to Window → MCP for Unity → Configure All Detected Clients
- The setup wizard will guide you through:
- Detecting available AI clients on your system
- Configuring MCP server connections
- Setting up automatic server startup
Manual Configuration:
If auto-detection doesn't work, you can manually configure your AI client:
Claude Desktop Configuration (
~/.claude/settings.jsonon macOS/Linux,%APPDATA%\Claude\settings.jsonon Windows):{ "mcpServers": { "UnityMCP": { "command": "uvx", "args": [ "--from", "mcpforunityserver", "mcp-for-unity", "--transport", "stdio" ] } } } - Step 9
Configure for HTTP transport
HTTP Transport (for multi-agent setups):
For scenarios where you need multiple AI clients or remote access, use HTTP transport:
- Start the server:
# Start MCP for Unity server with HTTP transport uvx --from mcpforunityserver mcp-for-unity --transport http --http-url http://localhost:8080 - Step 10
Configure HTTP client
- Configure your MCP client for HTTP:
{ "mcpServers": { "UnityMCP": { "url": "http://localhost:8080/mcp", "headers": { "X-API-Key": "your-api-key-here" } } } } - Step 11
Install from PyPI directly
Alternative: Install from PyPI
If you prefer not to use uvx, you can install the package directly:
# Install using uv uv add mcpforunityserver # Or using pip pip install mcpforunityserver # Run the server mcp-for-unity --transport stdio # Or use the unity-mcp alias unity-mcp --help - Step 12
Install from source (development)
For development/contribution:
Clone the repository and run from source:
# Clone the repository git clone https://github.com/CoplayDev/unity-mcp.git cd unity-mcp/Server # Run with uv uv run src/main.py --transport stdio # Or run with the CLI uv run unity-mcp --help - Step 13
Docker deployment
Docker deployment:
For containerized deployments or testing:
Use pre-built image:
# Pull and run the official image docker run -p 8080:8080 msanatan/mcp-for-unity-server:latest \ --transport http --http-url http://0.0.0.0:8080 - Step 14
Build Docker locally
Build locally:
# Build from source cd Server docker build -t unity-mcp-server . # Run your local build docker run -p 8080:8080 unity-mcp-server \ --transport http --http-url http://0.0.0.0:8080 - Step 15
Test the connection
After setup, test your connection with a simple prompt in your AI client:
Example prompts to try:
# Basic scene manipulation "Create a red, blue, and yellow cube in the current scene." # Asset creation "Add a material with a blue color and smoothness of 0.5" # Script generation "Create a simple player movement script with WASD controls" # Scene queries "List all GameObjects in the current scene" # Prefab operations "Create a prefab from the selected GameObject" - Step 16
Available tool groups
MCP for Unity organizes tools into groups. Only the
coregroup is enabled by default. Other groups can be enabled via themanage_toolscommand.Available tool groups:
| Group | Description | Default | |-------|-------------|---------| | core | Basic Unity operations, scene management | ✅ Enabled | | vfx | Visual effects (ParticleSystems, Shaders) | ❌ Disabled | | animation | Animations, animation controllers | ❌ Disabled | | ui | UI elements (Canvas, Text, Buttons) | ❌ Disabled | | scripting_ext | Script generation with Roslyn | ❌ Disabled | | testing | Test Framework integration | ❌ Disabled | | probuilder | ProBuilder mesh generation | ❌ Disabled | | profiling | Unity profiler integration | ❌ Disabled | | docs | Documentation and help | ✅ Enabled |
Enable additional tool groups:
You can enable tool groups by using the
manage_toolstool in your AI assistant conversation, or through the Unity Editor settings.Tool Groups Overview: Group Features Status core Scene management, GameObjects Enabled docs Help, documentation Enabled vfx ParticleSystems, Shaders Disabled animation Animations, Controllers Disabled ui Canvas, UI elements Disabled scripting_ext C# script generation Disabled testing Test Framework Disabled probuilder 3D modeling in Unity Disabled profiling Performance analysis Disabled To enable: ask your AI assistant to use the manage_tools tool - Step 17
Example: Create objects in scene
Here's a practical example of using MCP for Unity to create objects in your scene:
Basic example - Create cubes:
Prompt to AI assistant: "Create three cubes in the scene: one red at position (0, 1, 0), one blue at (2, 1, 0), and one yellow at (4, 1, 0). Make each cube 1x1x1 units." Expected behavior: 1. AI assistant calls the manage_gameobjects MCP tool 2. MCP server routes the request to Unity 3. Unity creates three GameObjects with Cube meshes 4. Materials are created/assigned for each color 5. Transforms are set to specified positions 6. Response confirms creation with GameObject IDs - Step 18
Example: Script generation
Advanced example - Create scripts with Roslyn validation:
First, enable the
scripting_exttool group, then:Prompt to AI assistant: "Create a C# script called 'PlayerController' that implements: - WASD movement controls - Jump functionality - Speed variable set to 5 - Jump force set to 7 Attach it to the player GameObject in the scene." The scripting_ext tools use Roslyn compiler API to: 1. Validate the generated code before creation 2. Ensure no syntax errors exist 3. Create the script file in the Assets/Scripts folder 4. Attach the script component to the specified GameObject - Step 19
Remote-hosted deployment
Advanced: Remote-hosted server with authentication
For team deployments or Asset Store distribution, you can run the server as a remote service with API key authentication:
Server configuration:
uvx --from mcpforunityserver mcp-for-unity \ --transport http \ --http-host 0.0.0.0 \ --http-port 8080 \ --http-remote-hosted \ --api-key-validation-url https://auth.example.com/api/validate-key \ --api-key-login-url https://app.example.com/api-keys - Step 20
Remote client configuration
Client configuration with API key:
{ "mcpServers": { "UnityMCP": { "url": "https://remote-mcp-server.example.com:8080/mcp", "headers": { "X-API-Key": "your-api-key-here" } } } } - Step 21
Environment variables
MCP for Unity can be configured via environment variables:
Transport and networking:
# Transport mode export UNITY_MCP_TRANSPORT="stdio" # or "http" # HTTP settings export UNITY_MCP_HTTP_URL="http://localhost:8080" export UNITY_MCP_HTTP_HOST="127.0.0.1" export UNITY_MCP_HTTP_PORT="8080" # Remote-hosted mode export UNITY_MCP_HTTP_REMOTE_HOSTED="true" export UNITY_MCP_API_KEY_VALIDATION_URL="https://auth.example.com/validate" export UNITY_MCP_API_KEY_LOGIN_URL="https://app.example.com/keys" # Other options export UNITY_MCP_DEFAULT_INSTANCE="MyProject@hash" export UNITY_MCP_SKIP_STARTUP_CONNECT=1 export UNITY_MCP_LOG_DIR="/custom/log/path" # Disable telemetry export DISABLE_TELEMETRY=1 # or export UNITY_MCP_DISABLE_TELEMETRY=1 - Step 22
Resources for reading Unity state
MCP for Unity provides MCP resources for reading Unity Editor state without modifying it. These are accessed via resource URIs:
Available resources:
| Resource | URI Pattern | Description | |----------|-------------|-------------| | Editor state |
mcpforunity://editor/state| Editor readiness snapshot | | Project tags |mcpforunity://project/tags| All project tags and layers | | GameObject |mcpforunity://scene/gameobject/{id}| GameObject details by instance ID | | Prefab |mcpforunity://prefab/{encoded_path}| Prefab info by asset path | | Scene list |mcpforunity://scene/list| All open scenes | | Console |mcpforunity://editor/console| Editor console messages |Important: Always use
ListMcpResourcesto get the current resource URIs, as the format may change between versions.Resource URI Examples: mcpforunity://editor/state mcpforunity://project/tags mcpforunity://project/layers mcpforunity://scene/list mcpforunity://scene/gameobject/12345 mcpforunity://prefab/Assets_Prefabs_Player.prefab mcpforunity://editor/console mcpforunity://asset/{encoded_path} Note: Resource names use underscores but URIs use slashes/hyphens - Step 23
Troubleshooting
Common issues and solutions:
Issue: Server won't start
- Check Python version:
python --version(must be 3.10+) - Verify uv installation:
uv --version - Check if port 8080 is available (for HTTP mode)
Issue: Unity connection fails
- Ensure Unity Editor is running
- Check that the MCP for Unity package is installed
- Verify the package version matches the server version
- Look at Unity Editor Console for errors
Issue: Tools not available
- Check if the tool group is enabled
- Use
manage_toolsto enable additional groups - Restart your AI client after enabling tools
Issue: HTTP transport issues
- Verify firewall allows localhost:8080
- Check UNITY_MCP_HTTP_ environment variables
- Ensure the URL in client config matches server URL
Logs location:
- Windows:
%LOCALAPPDATA%\UnityMCP\Logs - macOS:
~/Library/Application Support/UnityMCP/Logs - Linux:
$XDG_STATE_HOME/UnityMCP/Logsor~/.local/state/UnityMCP/Logs
# Check Python version python --version # Check uv installation uv --version # Check if port is available (HTTP mode) netstat -an | grep 8080 # macOS/Linux netstat -ano | find "8080" # Windows # View Unity Editor logs (if connection fails) # Open Unity Console window (Window → General → Console) # Check MCP for Unity logs # Windows: %LOCALAPPDATA%\UnityMCP\Logs\*.log # macOS: ~/Library/Application\ Support/UnityMCP/Logs/*.log # Linux: ~/.local/state/UnityMCP/Logs/*.log - Check Python version:
- Step 24
Development and contribution
Setting up for development:
The repository has two codebases to work with:
Server/- Python MCP serverMCPForUnity/- Unity C# Editor package
Python development:
# Clone the repository git clone https://github.com/CoplayDev/unity-mcp.git cd unity-mcp/Server # Run tests uv run pytest tests/ -v # Run a single test file uv run pytest tests/test_manage_material.py -v # Run a specific test uv run pytest tests/ -k "test_create_material" -v # Run the server in development mode uv run src/main.py --transport stdio - Step 25
Unity development testing
Unity testing:
Open the test project in Unity and run the Test Runner:
- Open Unity Editor
- File → Import Package → Custom Package
- Select TestProjects/UnityMCPTests folder from the repository
- Or open TestProjects/UnityMCPTests directly in Unity
- Window → Testing → Test Runner
- Run tests to verify functionality
Local Unity version testing: Use the provided script to test across Unity versions:
tools/check-unity-versions.sh # compile-only tools/check-unity-versions.sh --full # full test runUnity Testing Workflow: 1. Open Unity Editor 2. Import TestProjects/UnityMCPTests package 3. Window → Testing → Test Runner 4. Run all tests Version testing: tools/check-unity-versions.sh # compile-only tools/check-unity-versions.sh --full # full test run - Step 26
Additional resources
Official documentation and community:
- 📖 Documentation
- 💬 Discord Community
- 🐛 Report Issues
- 💡 Discussions
- 📄 Contributing Guide
- 🔒 Security Policy
- 📝 License - MIT
Related projects:
- Aura for Unity - Premium Unity/Unreal AI assistant
- Godot AI - MCP for Godot Engine
Research citation: If MCP for Unity helped your research, please cite it:
@inproceedings{wu2025mcpunity, author = {Wu, Shutong and Barnett, Justin P.}, title = {{MCP-Unity}: {Protocol-Driven} Framework for Interactive {3D} Authoring}, year = {2025}, publisher = {Association for Computing Machinery}, doi = {10.1145/3757376.3771417}, series = {SA Technical Communications '25} }Key Links: Documentation: https://coplaydev.github.io/unity-mcp/ Discord: https://discord.gg/y4p8KfzrN4 GitHub: https://github.com/CoplayDev/unity-mcp Issues: https://github.com/CoplayDev/unity-mcp/issues Website: https://www.coplay.dev/
Feature requests
Sign in to suggest features or vote on existing ones.
No feature requests yet.
Discussion
Sign in to join the discussion.
No comments yet.