Skip to content

Commit a52ce7a

Browse files
committed
VSCode manual config: use resolved uv path; VSCode parse init guards; NVM version parse robustness; help labels [HELP]
1 parent eb7b2e9 commit a52ce7a

File tree

3 files changed

+35
-21
lines changed

3 files changed

+35
-21
lines changed

UnityMcpBridge/Editor/Helpers/ExecPath.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,14 @@ private static string ResolveClaudeFromNvm(string home)
101101
if (string.IsNullOrEmpty(name)) continue;
102102
if (name.StartsWith("v", StringComparison.OrdinalIgnoreCase))
103103
{
104-
if (Version.TryParse(name.Substring(1), out Version parsed))
104+
// Extract numeric portion: e.g., v18.19.0-nightly -> 18.19.0
105+
string versionStr = name.Substring(1);
106+
int dashIndex = versionStr.IndexOf('-');
107+
if (dashIndex > 0)
108+
{
109+
versionStr = versionStr.Substring(0, dashIndex);
110+
}
111+
if (Version.TryParse(versionStr, out Version parsed))
105112
{
106113
string candidate = Path.Combine(versionDir, "bin", "claude");
107114
if (File.Exists(candidate))

UnityMcpBridge/Editor/Models/MCPConfigServer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ public class McpConfigServer
1212
[JsonProperty("args")]
1313
public string[] args;
1414

15-
// VSCode expects a transport type; default to stdio for compatibility
15+
// VSCode expects a transport type; include only when explicitly set
1616
[JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)]
17-
public string type = "stdio";
17+
public string type;
1818
}
1919
}

UnityMcpBridge/Editor/Windows/UnityMcpEditorWindow.cs

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ private void DrawClientConfigurationCompact(McpClient mcpClient)
739739
EditorGUILayout.LabelField(installText, installHintStyle, GUILayout.Height(22), GUILayout.Width(textSize.x + 2), GUILayout.ExpandWidth(false));
740740
GUIStyle helpLinkStyle = new GUIStyle(EditorStyles.linkLabel) { fontStyle = FontStyle.Bold };
741741
GUILayout.Space(6);
742-
if (GUILayout.Button("[CLICK]", helpLinkStyle, GUILayout.Height(22), GUILayout.ExpandWidth(false)))
742+
if (GUILayout.Button("[HELP]", helpLinkStyle, GUILayout.Height(22), GUILayout.ExpandWidth(false)))
743743
{
744744
Application.OpenURL("https://github.com/CoplayDev/unity-mcp/wiki/Troubleshooting-Unity-MCP-and-Claude-Code");
745745
}
@@ -764,7 +764,7 @@ private void DrawClientConfigurationCompact(McpClient mcpClient)
764764
EditorGUILayout.LabelField(installText2, installHintStyle2, GUILayout.Height(22), GUILayout.Width(sz.x + 2), GUILayout.ExpandWidth(false));
765765
GUIStyle helpLinkStyle2 = new GUIStyle(EditorStyles.linkLabel) { fontStyle = FontStyle.Bold };
766766
GUILayout.Space(6);
767-
if (GUILayout.Button("[CLICK]", helpLinkStyle2, GUILayout.Height(22), GUILayout.ExpandWidth(false)))
767+
if (GUILayout.Button("[HELP]", helpLinkStyle2, GUILayout.Height(22), GUILayout.ExpandWidth(false)))
768768
{
769769
Application.OpenURL("https://github.com/CoplayDev/unity-mcp/wiki/Troubleshooting-Unity-MCP-and-Cursor,-VSCode-&-Windsurf");
770770
}
@@ -1050,22 +1050,29 @@ private void ShowManualInstructionsWindow(string configPath, McpClient mcpClient
10501050
// Use switch statement to handle different client types
10511051
switch (mcpClient.mcpType)
10521052
{
1053-
case McpTypes.VSCode:
1054-
// Create VSCode-specific configuration with proper format
1055-
var vscodeConfig = new
1056-
{
1057-
servers = new
1058-
{
1059-
unityMCP = new
1060-
{
1061-
command = "uv",
1062-
args = new[] { "--directory", pythonDir, "run", "server.py" },
1063-
type = "stdio"
1064-
}
1065-
}
1066-
};
1067-
manualConfigJson = JsonConvert.SerializeObject(vscodeConfig, jsonSettings);
1068-
break;
1053+
case McpTypes.VSCode:
1054+
// Resolve uv so VSCode launches the correct executable even if not on PATH
1055+
string uvPathManual = FindUvPath();
1056+
if (uvPathManual == null)
1057+
{
1058+
UnityEngine.Debug.LogError("UV package manager not found. Cannot generate manual configuration.");
1059+
return;
1060+
}
1061+
// Create VSCode-specific configuration with proper format
1062+
var vscodeConfig = new
1063+
{
1064+
servers = new
1065+
{
1066+
unityMCP = new
1067+
{
1068+
command = uvPathManual,
1069+
args = new[] { "--directory", pythonDir, "run", "server.py" },
1070+
type = "stdio"
1071+
}
1072+
}
1073+
};
1074+
manualConfigJson = JsonConvert.SerializeObject(vscodeConfig, jsonSettings);
1075+
break;
10691076

10701077
default:
10711078
// Create standard MCP configuration for other clients

0 commit comments

Comments
 (0)