Skip to content

Commit 9f855d6

Browse files
Merge pull request #83 from justinpbarnett/update-readme
Update README.md
2 parents 5d98764 + 2fb6be0 commit 9f855d6

File tree

1 file changed

+226
-119
lines changed

1 file changed

+226
-119
lines changed

README.md

Lines changed: 226 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,249 @@
1-
# Unity MCP Package
1+
# Unity MCP
22

3-
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.
3+
**Connect your Unity Editor to LLMs using the Model Context Protocol.**
44

5-
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!
5+
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**. Give your LLM tools to manage assets, control scenes, edit scripts, and automate tasks within Unity.
66

7-
## Overview
7+
---
88

9-
The Unity MCP Server provides a bidirectional communication channel between Unity (via C#) and a Python server, enabling:
9+
## <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.com/justinpbarnett/unity-mcp/assets/11047284/c279675a-dd58-406b-9613-5b16b5c6bb63"><source media="(prefers-color-scheme: light)" srcset="https://github.com/justinpbarnett/unity-mcp/assets/11047284/b54f891d-961b-4048-a9c4-3af46e2a52fc"><img alt="UnityMCP Workflow" width="100%" style="max-width: 600px; display: block; margin-left: auto; margin-right: auto;"></picture>
1010

11-
- **Asset Management**: Create, import, and manipulate Unity assets programmatically.
12-
- **Scene Control**: Manage scenes, objects, and their properties.
13-
- **Material Editing**: Modify materials and their properties.
14-
- **Script Integration**: View, create, and update Unity scripts.
15-
- **Editor Automation**: Control Unity Editor functions like undo, redo, play, and build.
11+
## Key Features 🚀
1612

17-
This project is perfect for developers who want to leverage LLMs to enhance their Unity projects or automate repetitive tasks.
13+
* **🗣️ Natural Language Control:** Instruct your LLM to perform Unity tasks.
14+
* **🛠️ Powerful Tools:** Manage assets, scenes, materials, scripts, and editor functions.
15+
* **🤖 Automation:** Automate repetitive Unity workflows.
16+
* **🧩 Extensible:** Designed to work with various MCP Clients.
1817

19-
## Installation
18+
<details>
19+
<summary><strong>Expand for Available Tools...</strong></summary>
2020

21-
To use the Unity MCP Package, ensure you have the following installed:
21+
Your LLM can use functions like:
2222

23-
- **Unity 2020.3 LTS or newer** (⚠️ Currently only works in URP projects)
24-
- **Python 3.12 or newer**
25-
- **uv package manager**
23+
* `read_console`: Gets messages from or clears the console.
24+
* `manage_script`: Manages C# scripts (create, read, update, delete).
25+
* `manage_editor`: Controls and queries the editor's state and settings.
26+
* `manage_scene`: Manages scenes (load, save, create, get hierarchy, etc.).
27+
* `manage_asset`: Performs asset operations (import, create, modify, delete, etc.).
28+
* `manage_gameobject`: Manages GameObjects: create, modify, delete, find, and component operations.
29+
* `execute_menu_item`: Executes a menu item via its path (e.g., "File/Save Project").
30+
</details>
2631

27-
### Step 1: Install Python
32+
---
2833

29-
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.
34+
## How It Works 🤔
3035

31-
### Step 2: Install uv
36+
Unity MCP connects your tools using two components:
3237

33-
uv is a Python package manager that simplifies dependency management. Install it using the command below based on your operating system:
38+
1. **Unity MCP Bridge:** A Unity package running inside the Editor. (Installed via Package Manager).
39+
2. **Unity MCP Server:** A Python server that runs locally, communicating between the Unity Bridge and your MCP Client. (Installed manually).
3440

35-
- **Mac**:
41+
**Flow:** `[Your LLM via MCP Client] <-> [Unity MCP Server (Python)] <-> [Unity MCP Bridge (Unity Editor)]`
3642

37-
```bash
38-
brew install uv
39-
```
43+
---
4044

41-
- **Windows**:
45+
## Installation ⚙️
4246

43-
```bash
44-
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
45-
```
47+
> **Note:** The setup is constantly improving as we update the package. Check back if you randomly start to run into issues.
4648
47-
Then, add uv to your PATH:
49+
### Prerequisites
4850

49-
```bash
50-
set Path=%USERPROFILE%\.local\bin;%Path%
51-
```
51+
<details>
52+
<summary><strong>Click to view required software...</strong></summary>
53+
54+
* **Git CLI:** For cloning the server code. [Download Git](https://git-scm.com/downloads)
55+
* **Python:** Version 3.12 or newer. [Download Python](https://www.python.org/downloads/)
56+
* **Unity Hub & Editor:** Version 2020.3 LTS or newer. [Download Unity](https://unity.com/download)
57+
* **uv (Python package manager):**
58+
```bash
59+
pip install uv
60+
# Or see: https://docs.astral.sh/uv/getting-started/installation/
61+
```
62+
* **An MCP Client:**
63+
* [Claude Desktop](https://claude.ai/download)
64+
* [Cursor](https://www.cursor.com/en/downloads)
65+
* *(Others may work with manual config)*
66+
</details>
5267

53-
- **Linux**:
68+
### Step 1: Install the Unity Package (Bridge)
5469

55-
```bash
56-
curl -LsSf https://astral.sh/uv/install.sh | sh
57-
```
70+
1. Open your Unity project.
71+
2. Go to `Window > Package Manager`.
72+
3. Click `+` -> `Add package from git URL...`.
73+
4. Enter:
74+
```
75+
https://github.com/justinpbarnett/unity-mcp.git?path=/UnityMcpBridge
76+
```
77+
5. Click `Add`.
78+
6. The MCP Server should automatically be installed onto your machine as a result of this process.
79+
80+
### Step 2: Configure Your MCP Client
81+
82+
Connect your MCP Client (Claude, Cursor, etc.) to the Python server you installed in Step 1.
5883

59-
For alternative installation methods, see the [uv installation guide](https://docs.astral.sh/uv/getting-started/installation/).
84+
**Option A: Auto-Configure (Recommended for Claude/Cursor)**
6085

61-
**Important**: Do not proceed without installing uv.
62-
63-
### Step 3: Install the Unity Package
64-
65-
1. Open Unity and go to `Window > Package Manager`.
66-
2. Click the `+` button and select `Add package from git URL`.
67-
3. Enter: `https://github.com/justinpbarnett/unity-mcp.git`
68-
69-
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.
70-
71-
## Features
72-
73-
- **Bidirectional Communication**: Seamlessly send and receive data between Unity and LLMs.
74-
- **Asset Management**: Import assets, instantiate prefabs, and create new prefabs programmatically.
75-
- **Scene Control**: Open, save, and modify scenes, plus create and manipulate game objects.
76-
- **Material Editing**: Apply and modify materials with ease.
77-
- **Script Integration**: Create, view, and update C# scripts within Unity.
78-
- **Editor Automation**: Automate Unity Editor tasks like building projects or entering play mode.
79-
80-
## Contributing
81-
82-
I’d love your help to make the Unity MCP Server even better! Here’s how to contribute:
83-
84-
1. **Fork the Repository**
85-
Fork [github.com/justinpbarnett/unity-mcp](https://github.com/justinpbarnett/unity-mcp) to your GitHub account.
86-
87-
2. **Create a Branch**
88-
89-
```bash
90-
git checkout -b feature/your-feature-name
91-
```
92-
93-
or
94-
95-
```bash
96-
git checkout -b bugfix/your-bugfix-name
97-
```
98-
99-
3. **Make Changes**
100-
Implement your feature or fix.
101-
102-
4. **Commit and Push**
103-
Use clear, descriptive commit messages:
104-
105-
```bash
106-
git commit -m "Add feature: your feature description"
107-
git push origin feature/your-feature-name
108-
```
109-
110-
5. **Submit a Pull Request**
111-
Open a pull request to the `master` branch with a description of your changes.
112-
113-
## License
114-
115-
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).
116-
117-
## Troubleshooting
118-
119-
Encountering issues? Try these fixes:
120-
121-
- **Unity Bridge Not Running**
122-
Ensure the Unity Editor is open and the MCP window is active. Restart Unity if needed.
123-
124-
- **Python Server Not Connected**
125-
Verify that Python and uv are correctly installed and that the Unity MCP package is properly set up.
126-
127-
- **Configuration Issues with Claude Desktop or Cursor**
128-
Ensure your MCP client is configured to communicate with the Unity MCP server.
129-
130-
For more help, visit the [issue tracker](https://github.com/justinpbarnett/unity-mcp/issues) or file a new issue.
131-
132-
## Contact
133-
134-
Have questions or want to chat about the project? Reach out!
135-
136-
- **X**: [@justinpbarnett](https://x.com/justinpbarnett)
137-
138-
## Acknowledgments
139-
140-
A huge thanks to everyone who’s supported this project’s initial release. Special shoutout to Unity Technologies for their excellent Editor API.
141-
142-
Happy coding, and enjoy integrating LLMs with Unity!
86+
1. In Unity, go to `Window > Unity MCP`.
87+
2. Click `Auto Configure Claude` or `Auto Configure Cursor`.
88+
3. Look for a green status indicator 🟢 and "Connected". *(This attempts to modify the MCP Client's config file automatically)*.
89+
90+
**Option B: Manual Configuration**
91+
92+
If Auto-Configure fails or you use a different client:
93+
94+
1. **Find your MCP Client's configuration file.** (Check client documentation).
95+
* *Claude Example (macOS):* `~/Library/Application Support/Claude/claude_desktop_config.json`
96+
* *Claude Example (Windows):* `%APPDATA%\Claude\claude_desktop_config.json`
97+
2. **Edit the file** to add/update the `mcpServers` section, using the *exact* paths from Step 1.
98+
99+
<details>
100+
<summary><strong>Click for OS-Specific JSON Configuration Snippets...</strong></summary>
101+
102+
**Windows:**
103+
104+
```json
105+
{
106+
"mcpServers": {
107+
"UnityMCP": {
108+
"command": "uv",
109+
"args": [
110+
"run",
111+
"--directory",
112+
"C:\\Users\\YOUR_USERNAME\\AppData\\Local\\Programs\\UnityMCP\\UnityMcpServer\\src",
113+
"server.py"
114+
]
115+
}
116+
// ... other servers might be here ...
117+
}
118+
}
119+
```
120+
121+
(Remember to replace YOUR_USERNAME and use double backslashes \\)
122+
123+
**macOS:**
124+
125+
```json
126+
{
127+
"mcpServers": {
128+
"UnityMCP": {
129+
"command": "uv",
130+
"args": [
131+
"run",
132+
"--directory",
133+
"/usr/local/bin/UnityMCP/UnityMcpServer/src",
134+
"server.py"
135+
]
136+
}
137+
// ... other servers might be here ...
138+
}
139+
}
140+
```
141+
(Replace YOUR_USERNAME if using ~/bin)
142+
143+
**Linux:**
144+
145+
```json
146+
{
147+
"mcpServers": {
148+
"UnityMCP": {
149+
"command": "uv",
150+
"args": [
151+
"run",
152+
"--directory",
153+
"/home/YOUR_USERNAME/bin/UnityMCP/UnityMcpServer/src",
154+
"server.py"
155+
]
156+
}
157+
// ... other servers might be here ...
158+
}
159+
}
160+
```
161+
162+
(Replace YOUR_USERNAME)
163+
164+
</details>
165+
166+
---
167+
168+
## Usage ▶️
169+
170+
1. **Open your Unity Project.** The Unity MCP Bridge (package) should connect automatically. Check status via Window > Unity MCP.
171+
172+
2. **Start your MCP Client** (Claude, Cursor, etc.). It should automatically launch the Unity MCP Server (Python) using the configuration from Installation Step 3.
173+
174+
3. **Interact!** Unity tools should now be available in your MCP Client.
175+
176+
Example Prompt: `Create a 3D player controller.`
177+
178+
179+
---
180+
181+
## Contributing 🤝
182+
183+
Help make Unity MCP better!
184+
185+
1. **Fork** the main repository.
186+
187+
2. **Create a branch** (`feature/your-idea` or `bugfix/your-fix`).
188+
189+
3. **Make changes.**
190+
191+
4. **Commit** (feat: Add cool new feature).
192+
193+
5. **Push** your branch.
194+
195+
6. **Open a Pull Request** against the master branch.
196+
197+
198+
---
199+
200+
## Troubleshooting ❓
201+
202+
<details>
203+
<summary><strong>Click to view common issues and fixes...</strong></summary>
204+
205+
- **Unity Bridge Not Running/Connecting:**
206+
207+
- Ensure Unity Editor is open.
208+
209+
- Check the status window: Window > Unity MCP.
210+
211+
- Restart Unity.
212+
213+
- **MCP Client Not Connecting / Server Not Starting:**
214+
215+
- **Verify Server Path:** Double-check the --directory path in your MCP Client's JSON config. It must exactly match the location where you cloned the UnityMCP repository in Installation Step 1 (e.g., .../Programs/UnityMCP/UnityMcpServer/src).
216+
217+
- **Verify uv:** Make sure uv is installed and working (pip show uv).
218+
219+
- **Run Manually:** Try running the server directly from the terminal to see errors: `# Navigate to the src directory first! cd /path/to/your/UnityMCP/UnityMcpServer/src uv run server.py`
220+
221+
- **Permissions (macOS/Linux):** If you installed the server in a system location like /usr/local/bin, ensure the user running the MCP client has permission to execute uv and access files there. Installing in ~/bin might be easier.
222+
223+
- **Auto-Configure Failed:**
224+
225+
- Use the Manual Configuration steps. Auto-configure might lack permissions to write to the MCP client's config file.
226+
227+
228+
</details>
229+
230+
Still stuck? [Open an Issue](https://www.google.com/url?sa=E&q=https%3A%2F%2Fgithub.com%2Fjustinpbarnett%2Funity-mcp%2Fissues).
231+
232+
---
233+
234+
## License 📜
235+
236+
MIT License. See [LICENSE](https://www.google.com/url?sa=E&q=https%3A%2F%2Fgithub.com%2Fjustinpbarnett%2Funity-mcp%2Fblob%2Fmaster%2FLICENSE) file.
237+
238+
---
239+
240+
## Contact 👋
241+
242+
- **X/Twitter:** [@justinpbarnett](https://www.google.com/url?sa=E&q=https%3A%2F%2Fx.com%2Fjustinpbarnett)
243+
244+
245+
---
246+
247+
## Acknowledgments 🙏
248+
249+
Thanks to the contributors and the Unity team.

0 commit comments

Comments
 (0)