VSCode manual config: use resolved uv path; VSCode parse init guards; NVM version parse robustness; help labels [HELP]

main
David Sarno 2025-08-12 21:33:43 -07:00
parent eb7b2e952e
commit a52ce7a219
3 changed files with 35 additions and 21 deletions

View File

@ -101,7 +101,14 @@ namespace UnityMcpBridge.Editor.Helpers
if (string.IsNullOrEmpty(name)) continue; if (string.IsNullOrEmpty(name)) continue;
if (name.StartsWith("v", StringComparison.OrdinalIgnoreCase)) if (name.StartsWith("v", StringComparison.OrdinalIgnoreCase))
{ {
if (Version.TryParse(name.Substring(1), out Version parsed)) // Extract numeric portion: e.g., v18.19.0-nightly -> 18.19.0
string versionStr = name.Substring(1);
int dashIndex = versionStr.IndexOf('-');
if (dashIndex > 0)
{
versionStr = versionStr.Substring(0, dashIndex);
}
if (Version.TryParse(versionStr, out Version parsed))
{ {
string candidate = Path.Combine(versionDir, "bin", "claude"); string candidate = Path.Combine(versionDir, "bin", "claude");
if (File.Exists(candidate)) if (File.Exists(candidate))

View File

@ -12,8 +12,8 @@ namespace UnityMcpBridge.Editor.Models
[JsonProperty("args")] [JsonProperty("args")]
public string[] args; public string[] args;
// VSCode expects a transport type; default to stdio for compatibility // VSCode expects a transport type; include only when explicitly set
[JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)] [JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)]
public string type = "stdio"; public string type;
} }
} }

View File

@ -739,7 +739,7 @@ namespace UnityMcpBridge.Editor.Windows
EditorGUILayout.LabelField(installText, installHintStyle, GUILayout.Height(22), GUILayout.Width(textSize.x + 2), GUILayout.ExpandWidth(false)); EditorGUILayout.LabelField(installText, installHintStyle, GUILayout.Height(22), GUILayout.Width(textSize.x + 2), GUILayout.ExpandWidth(false));
GUIStyle helpLinkStyle = new GUIStyle(EditorStyles.linkLabel) { fontStyle = FontStyle.Bold }; GUIStyle helpLinkStyle = new GUIStyle(EditorStyles.linkLabel) { fontStyle = FontStyle.Bold };
GUILayout.Space(6); GUILayout.Space(6);
if (GUILayout.Button("[CLICK]", helpLinkStyle, GUILayout.Height(22), GUILayout.ExpandWidth(false))) if (GUILayout.Button("[HELP]", helpLinkStyle, GUILayout.Height(22), GUILayout.ExpandWidth(false)))
{ {
Application.OpenURL("https://github.com/CoplayDev/unity-mcp/wiki/Troubleshooting-Unity-MCP-and-Claude-Code"); Application.OpenURL("https://github.com/CoplayDev/unity-mcp/wiki/Troubleshooting-Unity-MCP-and-Claude-Code");
} }
@ -764,7 +764,7 @@ namespace UnityMcpBridge.Editor.Windows
EditorGUILayout.LabelField(installText2, installHintStyle2, GUILayout.Height(22), GUILayout.Width(sz.x + 2), GUILayout.ExpandWidth(false)); EditorGUILayout.LabelField(installText2, installHintStyle2, GUILayout.Height(22), GUILayout.Width(sz.x + 2), GUILayout.ExpandWidth(false));
GUIStyle helpLinkStyle2 = new GUIStyle(EditorStyles.linkLabel) { fontStyle = FontStyle.Bold }; GUIStyle helpLinkStyle2 = new GUIStyle(EditorStyles.linkLabel) { fontStyle = FontStyle.Bold };
GUILayout.Space(6); GUILayout.Space(6);
if (GUILayout.Button("[CLICK]", helpLinkStyle2, GUILayout.Height(22), GUILayout.ExpandWidth(false))) if (GUILayout.Button("[HELP]", helpLinkStyle2, GUILayout.Height(22), GUILayout.ExpandWidth(false)))
{ {
Application.OpenURL("https://github.com/CoplayDev/unity-mcp/wiki/Troubleshooting-Unity-MCP-and-Cursor,-VSCode-&-Windsurf"); Application.OpenURL("https://github.com/CoplayDev/unity-mcp/wiki/Troubleshooting-Unity-MCP-and-Cursor,-VSCode-&-Windsurf");
} }
@ -1051,6 +1051,13 @@ namespace UnityMcpBridge.Editor.Windows
switch (mcpClient.mcpType) switch (mcpClient.mcpType)
{ {
case McpTypes.VSCode: case McpTypes.VSCode:
// Resolve uv so VSCode launches the correct executable even if not on PATH
string uvPathManual = FindUvPath();
if (uvPathManual == null)
{
UnityEngine.Debug.LogError("UV package manager not found. Cannot generate manual configuration.");
return;
}
// Create VSCode-specific configuration with proper format // Create VSCode-specific configuration with proper format
var vscodeConfig = new var vscodeConfig = new
{ {
@ -1058,7 +1065,7 @@ namespace UnityMcpBridge.Editor.Windows
{ {
unityMCP = new unityMCP = new
{ {
command = "uv", command = uvPathManual,
args = new[] { "--directory", pythonDir, "run", "server.py" }, args = new[] { "--directory", pythonDir, "run", "server.py" },
type = "stdio" type = "stdio"
} }