unity-mcp
A Unity MCP server that allows MCP clients like Claude Desktop or Cursor to perform Unity Editor actions.
GitHub Stars
3,102
User Rating
Not Rated
Favorites
0
Views
83
Forks
407
Issues
26
Installation
Difficulty
IntermediateEstimated Time
10-20 minutes
Requirements
Git CLI: Required for cloning the repository.Python: Version 3.12 or newer.+2 more
Installation
Installation
Prerequisites
Please specify required software and versions:Git CLI: Required for cloning the repository. [Download Git](https://git-scm.com/downloads)
Python: Version 3.12 or newer is required. [Download Python](https://www.python.org/downloads/)
Unity Hub & Editor: Version 2020.3 LTS or newer is required. [Download Unity](https://unity.com/download)
uv (Python package manager):
bash
pip install uv
An MCP Client: Required.
Installation Steps
1. Clone Repository
bash
git clone https://github.com/justinpbarnett/unity-mcp
cd unity-mcp
2. Install Dependencies
bash
pip install -r requirements.txt
3. Start Server
bash
python server.py
Troubleshooting
Common Issues
Issue: Server won't start Solution: Check your Python version and reinstall dependencies. Issue: Unity Editor cannot connect Solution: Ensure the Unity MCP Bridge is installed correctly.Configuration
Configuration
Basic Configuration
Set up the MCP Bridge within the Unity Editor. Install it via the Package Manager.Advanced Configuration
Environment Variables
Set the following environment variable as needed:bash
export MCP_SERVER_URL="http://localhost:3000"
Configuration Example
json
{
"mcpServers": {
"unity-mcp": {
"command": "python",
"args": ["server.py"],
"env": {
"MCP_SERVER_URL": "http://localhost:3000"
}
}
}
}
Examples
Examples
Basic Usage
Using in the Unity Editor
1Verify MCP Server Startup
Open the Unity Editor and confirm that the MCP Bridge is functioning correctly.
2Execute Basic Commands
Available tools from this MCP server:
- read_console: Retrieve console messages
- manage_scene: Manage scenes
Programmatic Usage
csharp
// C# example
using System;
using UnityEngine;
public class MCPExample : MonoBehaviour {
void Start() {
// Call a tool using the MCP client
CallMCPTool("manage_scene", new { action = "load", sceneName = "MainScene" });
}
}
Use Cases
Automatically import assets in the Unity Editor using an AI assistant.
Issue commands in natural language to load or save scenes.
Automatically generate scripts and edit them directly within the editor.
Bulk create or delete multiple GameObjects.
Retrieve or clear console messages from the editor.
Additional Resources
Author Information
111
Followers
22
Repositories
1
Gists
0
Total Contributions