Skip to content

Commit 7bfad3b

Browse files
committed
fix: wrap uvx in cmd /c for Windows clients to ensure PATH resolution
1 parent 293bd1f commit 7bfad3b

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

MCPForUnity/Editor/Helpers/ConfigJsonBuilder.cs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,31 @@ private static void PopulateUnityNode(JObject unity, string uvPath, McpClient cl
8585
// Stdio mode: Use uvx command
8686
var (uvxPath, fromUrl, packageName) = AssetPathUtility.GetUvxCommandParts();
8787

88-
unity["command"] = uvxPath;
88+
var args = new List<string>();
8989

90-
var args = new List<string> { packageName };
91-
if (!string.IsNullOrEmpty(fromUrl))
90+
// Fix for Windows GUI apps (Claude Desktop, Cursor, etc.):
91+
// Wrap in cmd /c to ensure PATH and environment are properly resolved.
92+
if (UnityEngine.Application.platform == UnityEngine.RuntimePlatform.WindowsEditor)
93+
{
94+
unity["command"] = "cmd";
95+
args.Add("/c");
96+
97+
// If uvxPath contains spaces, we might need to ensure it's treated as a command.
98+
// But typically in JSON args, it's just the next argument.
99+
args.Add(uvxPath);
100+
}
101+
else
92102
{
93-
args.Insert(0, fromUrl);
94-
args.Insert(0, "--from");
103+
unity["command"] = uvxPath;
95104
}
96105

106+
if (!string.IsNullOrEmpty(fromUrl))
107+
{
108+
args.Add("--from");
109+
args.Add(fromUrl);
110+
}
111+
112+
args.Add(packageName);
97113
args.Add("--transport");
98114
args.Add("stdio");
99115

0 commit comments

Comments
 (0)