Skip to content

Commit bbbc26a

Browse files
authored
Merge pull request #192 from dsarno/feat/bridge-stability
Harden MCP Bridge: reliable reloads, sticky port, embedded server, cleaner Auto‑Setup UI
2 parents 22ca5a7 + 1938756 commit bbbc26a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2345
-661
lines changed

README-DEV.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,23 @@ Restores original files from backup.
4646

4747
## Finding Unity Package Cache Path
4848

49-
Unity package cache is typically located at:
49+
Unity stores Git packages under a version-or-hash folder. Expect something like:
5050
```
51-
X:\UnityProject\Library\PackageCache\com.coplaydev.unity-mcp@1.0.0
51+
X:\UnityProject\Library\PackageCache\com.coplaydev.unity-mcp@<version-or-hash>
52+
```
53+
Example (hash):
54+
```
55+
X:\UnityProject\Library\PackageCache\com.coplaydev.unity-mcp@272123cfd97e
56+
5257
```
5358

54-
To find it:
59+
To find it reliably:
5560
1. Open Unity Package Manager
5661
2. Select "Unity MCP" package
57-
3. Right click on the package and "Show in Explorer"
58-
4. Navigate to the path above with your username and version
62+
3. Right click the package and choose "Show in Explorer"
63+
4. That opens the exact cache folder Unity is using for your project
64+
65+
Note: In recent builds, the Python server sources are also bundled inside the package under `UnityMcpServer~/src`. This is handy for local testing or pointing MCP clients directly at the packaged server.
5966

6067
## Workflow
6168

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,18 @@ Unity MCP connects your tools using two components:
118118
119119
Connect your MCP Client (Claude, Cursor, etc.) to the Python server you installed in Step 1.
120120
121-
<img width="609" alt="image" src="https://github.com/user-attachments/assets/cef3a639-4677-4fd8-84e7-2d82a04d55bb" />
121+
<img width="648" height="599" alt="UnityMCP-Readme-Image" src="https://github.com/user-attachments/assets/b4a725da-5c43-4bd6-80d6-ee2e3cca9596" />
122122
123-
**Option A: Auto-Configure (Recommended for Claude/Cursor/VSC Copilot)**
123+
**Option A: Auto-Setup (Recommended for Claude/Cursor/VSC Copilot)**
124124
125125
1. In Unity, go to `Window > Unity MCP`.
126-
2. Click `Auto Configure` on the IDE you uses.
127-
3. Look for a green status indicator 🟢 and "Connected". *(This attempts to modify the MCP Client\'s config file automatically)*.
126+
2. Click `Auto-Setup`.
127+
3. Look for a green status indicator 🟢 and "Connected ✓". *(This attempts to modify the MCP Client\'s config file automatically)*.
128+
128129

129130
**Option B: Manual Configuration**
130131

131-
If Auto-Configure fails or you use a different client:
132+
If Auto-Setup fails or you use a different client:
132133

133134
1. **Find your MCP Client\'s configuration file.** (Check client documentation).
134135
* *Claude Example (macOS):* `~/Library/Application Support/Claude/claude_desktop_config.json`

UnityMcpBridge/Editor/Data/DefaultServerConfig.cs.meta

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnityMcpBridge/Editor/Data/McpClients.cs

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ public class McpClients
99
{
1010
public List<McpClient> clients = new()
1111
{
12+
// 1) Cursor
1213
new()
1314
{
14-
name = "Claude Desktop",
15+
name = "Cursor",
1516
windowsConfigPath = Path.Combine(
16-
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
17-
"Claude",
18-
"claude_desktop_config.json"
17+
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
18+
".cursor",
19+
"mcp.json"
1920
),
2021
linuxConfigPath = Path.Combine(
2122
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
22-
"Library",
23-
"Application Support",
24-
"Claude",
25-
"claude_desktop_config.json"
23+
".cursor",
24+
"mcp.json"
2625
),
27-
mcpType = McpTypes.ClaudeDesktop,
26+
mcpType = McpTypes.Cursor,
2827
configStatus = "Not Configured",
2928
},
29+
// 2) Claude Code
3030
new()
3131
{
3232
name = "Claude Code",
@@ -41,58 +41,63 @@ public class McpClients
4141
mcpType = McpTypes.ClaudeCode,
4242
configStatus = "Not Configured",
4343
},
44+
// 3) Windsurf
4445
new()
4546
{
46-
name = "Cursor",
47+
name = "Windsurf",
4748
windowsConfigPath = Path.Combine(
4849
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
49-
".cursor",
50-
"mcp.json"
50+
".codeium",
51+
"windsurf",
52+
"mcp_config.json"
5153
),
5254
linuxConfigPath = Path.Combine(
5355
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
54-
".cursor",
55-
"mcp.json"
56+
".codeium",
57+
"windsurf",
58+
"mcp_config.json"
5659
),
57-
mcpType = McpTypes.Cursor,
60+
mcpType = McpTypes.Windsurf,
5861
configStatus = "Not Configured",
5962
},
63+
// 4) Claude Desktop
6064
new()
6165
{
62-
name = "VSCode GitHub Copilot",
66+
name = "Claude Desktop",
6367
windowsConfigPath = Path.Combine(
6468
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
65-
"Code",
66-
"User",
67-
"settings.json"
69+
"Claude",
70+
"claude_desktop_config.json"
6871
),
6972
linuxConfigPath = Path.Combine(
7073
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
7174
"Library",
7275
"Application Support",
73-
"Code",
74-
"User",
75-
"settings.json"
76+
"Claude",
77+
"claude_desktop_config.json"
7678
),
77-
mcpType = McpTypes.VSCode,
79+
mcpType = McpTypes.ClaudeDesktop,
7880
configStatus = "Not Configured",
7981
},
82+
// 5) VSCode GitHub Copilot
8083
new()
8184
{
82-
name = "Windsurf",
85+
name = "VSCode GitHub Copilot",
8386
windowsConfigPath = Path.Combine(
84-
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
85-
".codeium",
86-
"windsurf",
87-
"mcp_config.json"
87+
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
88+
"Code",
89+
"User",
90+
"settings.json"
8891
),
8992
linuxConfigPath = Path.Combine(
9093
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
91-
".codeium",
92-
"windsurf",
93-
"mcp_config.json"
94+
"Library",
95+
"Application Support",
96+
"Code",
97+
"User",
98+
"settings.json"
9499
),
95-
mcpType = McpTypes.Windsurf,
100+
mcpType = McpTypes.VSCode,
96101
configStatus = "Not Configured",
97102
},
98103
};

UnityMcpBridge/Editor/Data/McpClients.cs.meta

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnityMcpBridge/Editor/Helpers/GameObjectSerializer.cs.meta

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using UnityEditor;
2+
using UnityEngine;
3+
4+
namespace UnityMcpBridge.Editor.Helpers
5+
{
6+
/// <summary>
7+
/// Handles automatic installation of the Python server when the package is first installed.
8+
/// </summary>
9+
[InitializeOnLoad]
10+
public static class PackageInstaller
11+
{
12+
private const string InstallationFlagKey = "UnityMCP.ServerInstalled";
13+
14+
static PackageInstaller()
15+
{
16+
// Check if this is the first time the package is loaded
17+
if (!EditorPrefs.GetBool(InstallationFlagKey, false))
18+
{
19+
// Schedule the installation for after Unity is fully loaded
20+
EditorApplication.delayCall += InstallServerOnFirstLoad;
21+
}
22+
}
23+
24+
private static void InstallServerOnFirstLoad()
25+
{
26+
try
27+
{
28+
Debug.Log("<b><color=#2EA3FF>UNITY-MCP</color></b>: Installing Python server...");
29+
ServerInstaller.EnsureServerInstalled();
30+
31+
// Mark as installed
32+
EditorPrefs.SetBool(InstallationFlagKey, true);
33+
34+
Debug.Log("<b><color=#2EA3FF>UNITY-MCP</color></b>: Python server installation completed successfully.");
35+
}
36+
catch (System.Exception ex)
37+
{
38+
Debug.LogError($"<b><color=#2EA3FF>UNITY-MCP</color></b>: Failed to install Python server: {ex.Message}");
39+
Debug.LogWarning("<b><color=#2EA3FF>UNITY-MCP</color></b>: You may need to manually install the Python server. Check the Unity MCP Editor Window for instructions.");
40+
}
41+
}
42+
}
43+
}

UnityMcpBridge/Editor/Helpers/PackageInstaller.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)