2025-03-18 19:21:33 +08:00
# Unity MCP Package
2025-03-18 19:00:50 +08:00
2025-03-18 19:21:33 +08:00
A Unity package that enables seamless communication between Unity and Large Language Models (LLMs) like Claude Desktop via the **Model Context Protocol (MCP)** . This server acts as a bridge, allowing Unity to send commands to and receive responses from MCP-compliant tools, empowering developers to automate workflows, manipulate assets, and control the Unity Editor programmatically.
2025-03-23 06:22:03 +08:00
Welcome to the initial release of this open-source project! Whether you're looking to integrate LLMs into your Unity workflow or contribute to an exciting new tool, I appreciate you taking the time to check it out!
2025-03-18 19:00:50 +08:00
## Overview
2025-03-18 19:21:33 +08:00
The Unity MCP Server provides a bidirectional communication channel between Unity (via C#) and a Python server, enabling:
2025-03-18 19:00:50 +08:00
2025-03-18 19:21:33 +08:00
- **Asset Management**: Create, import, and manipulate Unity assets programmatically.
- **Scene Control**: Manage scenes, objects, and their properties.
- **Material Editing**: Modify materials and their properties.
- **Script Integration**: View, create, and update Unity scripts.
- **Editor Automation**: Control Unity Editor functions like undo, redo, play, and build.
2025-03-18 19:00:50 +08:00
2025-03-18 19:21:33 +08:00
This project is perfect for developers who want to leverage LLMs to enhance their Unity projects or automate repetitive tasks.
2025-03-18 19:00:50 +08:00
2025-03-18 19:21:33 +08:00
## Installation
2025-03-18 19:00:50 +08:00
2025-03-23 06:22:03 +08:00
To use the Unity MCP Package, ensure you have the following installed:
2025-03-19 04:06:28 +08:00
2025-03-23 06:22:03 +08:00
- **Unity 2020.3 LTS or newer** (⚠️ Currently only works in URP projects)
- **Python 3.12 or newer**
- **uv package manager**
2025-03-19 04:06:28 +08:00
2025-03-23 06:22:03 +08:00
### Step 1: Install Python
2025-03-19 04:06:28 +08:00
2025-03-23 06:22:03 +08:00
Download and install Python 3.12 or newer from [python.org ](https://www.python.org/downloads/ ). Make sure to add Python to your system’ s PATH during installation.
2025-03-19 04:06:28 +08:00
2025-03-23 06:22:03 +08:00
### Step 2: Install uv
2025-03-19 04:06:28 +08:00
2025-03-23 06:22:03 +08:00
uv is a Python package manager that simplifies dependency management. Install it using the command below based on your operating system:
2025-03-19 04:06:28 +08:00
2025-03-23 06:22:03 +08:00
- **Mac**:
2025-03-19 04:06:28 +08:00
2025-03-23 06:22:03 +08:00
```bash
brew install uv
```
2025-03-19 04:06:28 +08:00
2025-03-23 06:22:03 +08:00
- **Windows**:
2025-03-19 04:06:28 +08:00
2025-03-23 06:22:03 +08:00
```bash
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
```
2025-03-19 04:06:28 +08:00
2025-03-23 06:22:03 +08:00
Then, add uv to your PATH:
2025-03-19 04:06:28 +08:00
2025-03-23 06:22:03 +08:00
```bash
set Path=%USERPROFILE%\.local\bin;%Path%
```
2025-03-19 04:06:28 +08:00
2025-03-23 06:22:03 +08:00
- **Linux**:
2025-03-18 19:00:50 +08:00
2025-03-23 06:22:03 +08:00
```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
```
2025-03-18 19:00:50 +08:00
2025-03-23 06:22:03 +08:00
For alternative installation methods, see the [uv installation guide ](https://docs.astral.sh/uv/getting-started/installation/ ).
2025-03-18 19:00:50 +08:00
2025-03-23 06:22:03 +08:00
**Important**: Do not proceed without installing uv.
2025-03-18 19:00:50 +08:00
2025-03-23 06:22:03 +08:00
### Step 3: Install the Unity Package
2025-03-19 04:06:28 +08:00
2025-03-23 06:22:03 +08:00
1. Open Unity and go to `Window > Package Manager` .
2. Click the `+` button and select `Add package from git URL` .
3. Enter: `https://github.com/justinpbarnett/unity-mcp.git`
2025-03-19 04:06:28 +08:00
2025-03-23 06:22:03 +08:00
Once installed, the Unity MCP Package will be available in your Unity project. The server will start automatically when used with an MCP client like Claude Desktop or Cursor.
2025-03-18 19:21:33 +08:00
## Features
- **Bidirectional Communication**: Seamlessly send and receive data between Unity and LLMs.
- **Asset Management**: Import assets, instantiate prefabs, and create new prefabs programmatically.
- **Scene Control**: Open, save, and modify scenes, plus create and manipulate game objects.
- **Material Editing**: Apply and modify materials with ease.
- **Script Integration**: Create, view, and update C# scripts within Unity.
- **Editor Automation**: Automate Unity Editor tasks like building projects or entering play mode.
## Contributing
2025-03-23 06:22:03 +08:00
I’ d love your help to make the Unity MCP Server even better! Here’ s how to contribute:
2025-03-18 19:21:33 +08:00
1. **Fork the Repository**
Fork [github.com/justinpbarnett/unity-mcp ](https://github.com/justinpbarnett/unity-mcp ) to your GitHub account.
2025-03-19 01:24:17 +08:00
2. **Create a Branch**
2025-03-18 19:21:33 +08:00
```bash
git checkout -b feature/your-feature-name
```
2025-03-23 06:22:03 +08:00
or
2025-03-20 19:24:31 +08:00
```bash
git checkout -b bugfix/your-bugfix-name
```
2025-03-18 19:21:33 +08:00
3. **Make Changes**
2025-03-20 19:24:31 +08:00
Implement your feature or fix.
2025-03-18 19:21:33 +08:00
4. **Commit and Push**
Use clear, descriptive commit messages:
2025-03-19 01:24:17 +08:00
2025-03-18 19:21:33 +08:00
```bash
git commit -m "Add feature: your feature description"
git push origin feature/your-feature-name
```
5. **Submit a Pull Request**
2025-03-23 06:22:03 +08:00
Open a pull request to the `master` branch with a description of your changes.
2025-03-18 19:21:33 +08:00
## License
This project is licensed under the **MIT License** . Feel free to use, modify, and distribute it as you see fit. See the full license [here ](https://github.com/justinpbarnett/unity-mcp/blob/master/LICENSE ).
2025-03-19 01:24:17 +08:00
2025-03-18 19:00:50 +08:00
## Troubleshooting
2025-03-23 06:22:03 +08:00
Encountering issues? Try these fixes:
2025-03-18 19:21:33 +08:00
- **Unity Bridge Not Running**
Ensure the Unity Editor is open and the MCP window is active. Restart Unity if needed.
2025-03-23 06:22:03 +08:00
- **Python Server Not Connected**
Verify that Python and uv are correctly installed and that the Unity MCP package is properly set up.
2025-03-18 19:21:33 +08:00
- **Configuration Issues with Claude Desktop or Cursor**
2025-03-23 06:22:03 +08:00
Ensure your MCP client is configured to communicate with the Unity MCP server.
2025-03-18 19:21:33 +08:00
2025-03-23 06:22:03 +08:00
For more help, visit the [issue tracker ](https://github.com/justinpbarnett/unity-mcp/issues ) or file a new issue.
2025-03-18 19:21:33 +08:00
## Contact
Have questions or want to chat about the project? Reach out!
2025-03-18 21:45:22 +08:00
- **X**: [@justinpbarnett ](https://x.com/justinpbarnett )
2025-03-18 19:21:33 +08:00
## Acknowledgments
2025-03-23 06:22:03 +08:00
A huge thanks to everyone who’ s supported this project’ s initial release. Special shoutout to Unity Technologies for their excellent Editor API.
2025-03-18 19:21:33 +08:00
Happy coding, and enjoy integrating LLMs with Unity!