Skip to content

Commit 44530de

Browse files
committed
2 parents 5bd447b + 41f0a57 commit 44530de

28 files changed

+3058
-296
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ CONTRIBUTING.md.meta
3131
.idea/
3232
.vscode/
3333
.aider*
34+
.DS_Store*

README.md

Lines changed: 102 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
# Unity MCP ✨
22

3-
**Connect your Unity Editor to LLMs using the Model Context Protocol.**
3+
4+
[![](https://img.shields.io/badge/Unity-000000?style=flat&logo=unity&logoColor=blue 'Unity')](https://unity.com/releases/editor/archive)
5+
[![python](https://img.shields.io/badge/Python-3.12-3776AB.svg?style=flat&logo=python&logoColor=white)](https://www.python.org)
6+
[![](https://badge.mcpx.dev?status=on 'MCP Enabled')](https://modelcontextprotocol.io/introduction)
7+
![GitHub commit activity](https://img.shields.io/github/commit-activity/w/justinpbarnett/unity-mcp)
8+
![GitHub Issues or Pull Requests](https://img.shields.io/github/issues/justinpbarnett/unity-mcp)
9+
[![](https://img.shields.io/badge/License-MIT-red.svg 'MIT License')](https://opensource.org/licenses/MIT)
10+
11+
12+
13+
14+
**Create your Unity apps with LLMs!**
415

516
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.
617

718
---
819

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>
1020

1121
## Key Features 🚀
1222

@@ -15,8 +25,8 @@ Unity MCP acts as a bridge, allowing AI assistants (like Claude, Cursor) to inte
1525
* **🤖 Automation:** Automate repetitive Unity workflows.
1626
* **🧩 Extensible:** Designed to work with various MCP Clients.
1727

18-
<details>
19-
<summary><strong>Expand for Available Tools...</strong></summary>
28+
<details open>
29+
<summary><strong> Available Tools </strong></summary>
2030

2131
Your LLM can use functions like:
2232

@@ -25,6 +35,7 @@ Unity MCP acts as a bridge, allowing AI assistants (like Claude, Cursor) to inte
2535
* `manage_editor`: Controls and queries the editor's state and settings.
2636
* `manage_scene`: Manages scenes (load, save, create, get hierarchy, etc.).
2737
* `manage_asset`: Performs asset operations (import, create, modify, delete, etc.).
38+
* `manage_shader`: Performs shader CRUD operations (create, read, modify, delete).
2839
* `manage_gameobject`: Manages GameObjects: create, modify, delete, find, and component operations.
2940
* `execute_menu_item`: Executes a menu item via its path (e.g., "File/Save Project").
3041
</details>
@@ -48,8 +59,6 @@ Unity MCP connects your tools using two components:
4859
4960
### Prerequisites
5061

51-
<details>
52-
<summary><strong>Click to view required software...</strong></summary>
5362

5463
* **Git CLI:** For cloning the server code. [Download Git](https://git-scm.com/downloads)
5564
* **Python:** Version 3.12 or newer. [Download Python](https://www.python.org/downloads/)
@@ -61,9 +70,31 @@ Unity MCP connects your tools using two components:
6170
```
6271
* **An MCP Client:**
6372
* [Claude Desktop](https://claude.ai/download)
73+
* [Claude Code](https://github.com/anthropics/claude-code)
6474
* [Cursor](https://www.cursor.com/en/downloads)
75+
* [Visual Studio Code Copilot](https://code.visualstudio.com/docs/copilot/overview)
6576
* *(Others may work with manual config)*
66-
</details>
77+
* <details> <summary><strong>[Optional] Roslyn for Advanced Script Validation</strong></summary>
78+
79+
For **Strict** validation level that catches undefined namespaces, types, and methods:
80+
81+
**Method 1: NuGet for Unity (Recommended)**
82+
1. Install [NuGetForUnity](https://github.com/GlitchEnzo/NuGetForUnity)
83+
2. Go to `Window > NuGet Package Manager`
84+
3. Search for `Microsoft.CodeAnalysis.CSharp` and install the package
85+
5. Go to `Player Settings > Scripting Define Symbols`
86+
6. Add `USE_ROSLYN`
87+
7. Restart Unity
88+
89+
**Method 2: Manual DLL Installation**
90+
1. Download Microsoft.CodeAnalysis.CSharp.dll and dependencies from [NuGet](https://www.nuget.org/packages/Microsoft.CodeAnalysis.CSharp/)
91+
2. Place DLLs in `Assets/Plugins/` folder
92+
3. Ensure .NET compatibility settings are correct
93+
4. Add `USE_ROSLYN` to Scripting Define Symbols
94+
5. Restart Unity
95+
96+
**Note:** Without Roslyn, script validation falls back to basic structural checks. Roslyn enables full C# compiler diagnostics with precise error reporting.</details>
97+
6798

6899
### Step 1: Install the Unity Package (Bridge)
69100

@@ -81,10 +112,12 @@ Unity MCP connects your tools using two components:
81112

82113
Connect your MCP Client (Claude, Cursor, etc.) to the Python server you installed in Step 1.
83114

84-
**Option A: Auto-Configure (Recommended for Claude/Cursor)**
115+
<img width="609" alt="image" src="https://github.com/user-attachments/assets/cef3a639-4677-4fd8-84e7-2d82a04d55bb" />
116+
117+
**Option A: Auto-Configure (Recommended for Claude/Cursor/VSC Copilot)**
85118

86119
1. In Unity, go to `Window > Unity MCP`.
87-
2. Click `Auto Configure Claude` or `Auto Configure Cursor`.
120+
2. Click `Auto Configure` on the IDE you uses.
88121
3. Look for a green status indicator 🟢 and "Connected". *(This attempts to modify the MCP Client's config file automatically)*.
89122
90123
**Option B: Manual Configuration**
@@ -163,6 +196,20 @@ If Auto-Configure fails or you use a different client:
163196

164197
</details>
165198

199+
**Option C: Claude Code Registration**
200+
201+
If you're using Claude Code, you can register the MCP server using these commands:
202+
203+
**macOS:**
204+
```bash
205+
claude mcp add UnityMCP -- uv --directory /[PATH_TO]/UnityMCP/UnityMcpServer/src run server.py
206+
```
207+
208+
**Windows:**
209+
```bash
210+
claude mcp add UnityMCP -- "C:/Users/USERNAME/AppData/Roaming/Python/Python313/Scripts/uv.exe" --directory "C:/Users/USERNAME/AppData/Local/Programs/UnityMCP/UnityMcpServer/src" run server.py
211+
```
212+
166213
---
167214
168215
## Usage ▶️
@@ -173,8 +220,41 @@ If Auto-Configure fails or you use a different client:
173220
174221
3. **Interact!** Unity tools should now be available in your MCP Client.
175222
176-
Example Prompt: `Create a 3D player controller.`
223+
Example Prompt: `Create a 3D player controller`, `Create a yellow and bridge sun`, `Create a cool shader and apply it on a cube`.
177224
225+
---
226+
227+
## Future Dev Plans (Besides PR) 📝
228+
229+
### 🔴 High Priority
230+
- [ ] **Asset Generation Improvements** - Enhanced server request handling and asset pipeline optimization
231+
- [ ] **Code Generation Enhancements** - Improved generated code quality and error handling
232+
- [ ] **Robust Error Handling** - Comprehensive error messages, recovery mechanisms, and graceful degradation
233+
- [ ] **Remote Connection Support** - Enable seamless remote connection between Unity host and MCP server
234+
- [ ] **Documentation Expansion** - Complete tutorials for custom tool creation and API reference
235+
236+
### 🟡 Medium Priority
237+
- [ ] **Custom Tool Creation GUI** - Visual interface for users to create and configure their own MCP tools
238+
- [ ] **Advanced Logging System** - Logging with filtering, export, and debugging capabilities
239+
240+
### 🟢 Low Priority
241+
- [ ] **Mobile Platform Support** - Extended toolset for mobile development workflows and platform-specific features
242+
- [ ] **Easier Tool Setup**
243+
- [ ] **Plugin Marketplace** - Community-driven tool sharing and distribution platform
244+
245+
<details open>
246+
<summary><strong>✅ Completed Features<strong></summary>
247+
248+
- [x] **Shader Generation** - Generate shaders using CGProgram template
249+
- [x] **Advanced Script Validation** - Multi-level validation with semantic analysis, namespace/type checking, and Unity best practices (Will need Roslyn Installed, see [Prerequisite](#prerequisites)).
250+
</details>
251+
252+
### 🔬 Research & Exploration
253+
- [ ] **AI-Powered Asset Generation** - Integration with AI tools for automatic 3D models, textures, and animations
254+
- [ ] **Real-time Collaboration** - Live editing sessions between multiple developers *(Currently in progress)*
255+
- [ ] **Analytics Dashboard** - Usage analytics, project insights, and performance metrics
256+
- [ ] **Voice Commands** - Voice-controlled Unity operations for accessibility
257+
- [ ] **AR/VR Tool Integration** - Extended support for immersive development workflows
178258
179259
---
180260
@@ -227,23 +307,29 @@ Help make Unity MCP better!
227307
228308
</details>
229309
230-
Still stuck? [Open an Issue](https://www.google.com/url?sa=E&q=https%3A%2F%2Fgithub.com%2Fjustinpbarnett%2Funity-mcp%2Fissues).
310+
Still stuck? [Open an Issue](https://www.google.com/url?sa=E&q=https%3A%2F%2Fgithub.com%2Fjustinpbarnett%2Funity-mcp%2Fissues) or [Join the Discord](https://discord.gg/vhTUxXaqYr)!
231311
232312
---
233313
234-
## License 📜
314+
## Contact 👋
235315
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.
316+
- **justinpbarnett:** [X/Twitter](https://www.google.com/url?sa=E&q=https%3A%2F%2Fx.com%2Fjustinpbarnett)
317+
- **scriptwonder**: [Email](mailto:[email protected]), [LinkedIn](https://www.linkedin.com/in/shutong-wu-214043172/)
318+
237319
238320
---
239321
240-
## Contact 👋
322+
## License 📜
241323
242-
- **X/Twitter:** [@justinpbarnett](https://www.google.com/url?sa=E&q=https%3A%2F%2Fx.com%2Fjustinpbarnett)
243-
324+
MIT License. See [LICENSE](https://www.google.com/url?sa=E&q=https%3A%2F%2Fgithub.com%2Fjustinpbarnett%2Funity-mcp%2Fblob%2Fmaster%2FLICENSE) file.
244325
245326
---
246327
247328
## Acknowledgments 🙏
248329
249330
Thanks to the contributors and the Unity team.
331+
332+
333+
## Star History
334+
335+
[![Star History Chart](https://api.star-history.com/svg?repos=justinpbarnett/unity-mcp&type=Date)](https://www.star-history.com/#justinpbarnett/unity-mcp&Date)

UnityMcpBridge/Editor/Data/McpClients.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ public class McpClients
2828
configStatus = "Not Configured",
2929
},
3030
new()
31+
{
32+
name = "Claude Code",
33+
windowsConfigPath = Path.Combine(
34+
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
35+
".claude.json"
36+
),
37+
linuxConfigPath = Path.Combine(
38+
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
39+
".claude.json"
40+
),
41+
mcpType = McpTypes.ClaudeCode,
42+
configStatus = "Not Configured",
43+
},
44+
new()
3145
{
3246
name = "Cursor",
3347
windowsConfigPath = Path.Combine(
@@ -43,6 +57,26 @@ public class McpClients
4357
mcpType = McpTypes.Cursor,
4458
configStatus = "Not Configured",
4559
},
60+
new()
61+
{
62+
name = "VSCode GitHub Copilot",
63+
windowsConfigPath = Path.Combine(
64+
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
65+
"Code",
66+
"User",
67+
"settings.json"
68+
),
69+
linuxConfigPath = Path.Combine(
70+
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
71+
"Library",
72+
"Application Support",
73+
"Code",
74+
"User",
75+
"settings.json"
76+
),
77+
mcpType = McpTypes.VSCode,
78+
configStatus = "Not Configured",
79+
},
4680
};
4781

4882
// Initialize status enums after construction

UnityMcpBridge/Editor/Helpers/GameObjectSerializer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace UnityMcpBridge.Editor.Helpers
1313
/// <summary>
1414
/// Handles serialization of GameObjects and Components for MCP responses.
1515
/// Includes reflection helpers and caching for performance.
16-
/// </summary> tew
16+
/// </summary>
1717
public static class GameObjectSerializer
1818
{
1919
// --- Data Serialization ---
@@ -422,7 +422,7 @@ private static void AddSerializableValue(Dictionary<string, object> dict, string
422422
catch (Exception e)
423423
{
424424
// Catch potential errors during JToken conversion or addition to dictionary
425-
// Debug.LogWarning($"[AddSerializableValue] Error processing value for '{name}' (Type: {type.FullName}): {e.Message}. Skipping.");
425+
Debug.LogWarning($"[AddSerializableValue] Error processing value for '{name}' (Type: {type.FullName}): {e.Message}. Skipping.");
426426
}
427427
}
428428

@@ -505,7 +505,7 @@ private static object ConvertJTokenToPlainObject(JToken token)
505505
// Helper to create JToken using the output serializer
506506
private static JToken CreateTokenFromValue(object value, Type type)
507507
{
508-
if (value == null) return JValue.CreateNull();
508+
if (value == null) return JValue.CreateNull();
509509

510510
try
511511
{
@@ -514,12 +514,12 @@ private static JToken CreateTokenFromValue(object value, Type type)
514514
}
515515
catch (JsonSerializationException e)
516516
{
517-
// Debug.LogWarning($"[GameObjectSerializer] Newtonsoft.Json Error serializing value of type {type.FullName}: {e.Message}. Skipping property/field.");
518-
return null; // Indicate serialization failure
517+
Debug.LogWarning($"[GameObjectSerializer] Newtonsoft.Json Error serializing value of type {type.FullName}: {e.Message}. Skipping property/field.");
518+
return null; // Indicate serialization failure
519519
}
520520
catch (Exception e) // Catch other unexpected errors
521521
{
522-
// Debug.LogWarning($"[GameObjectSerializer] Unexpected error serializing value of type {type.FullName}: {e}. Skipping property/field.");
522+
Debug.LogWarning($"[GameObjectSerializer] Unexpected error serializing value of type {type.FullName}: {e}. Skipping property/field.");
523523
return null; // Indicate serialization failure
524524
}
525525
}

0 commit comments

Comments
 (0)