Skip to content

Commit 5dbdffe

Browse files
committed
Simplify server management logic
1 parent a56b98f commit 5dbdffe

File tree

1 file changed

+8
-46
lines changed

1 file changed

+8
-46
lines changed

MCPForUnity/Editor/Services/ServerManagementService.cs

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -22,49 +22,8 @@ public bool ClearUvxCache()
2222
{
2323
try
2424
{
25-
var pathService = MCPServiceLocator.Paths;
26-
bool hasOverride = pathService.HasUvxPathOverride;
27-
string uvCommand = "uv";
28-
29-
if (hasOverride)
30-
{
31-
string overridePath = pathService.GetUvxPath();
32-
33-
if (!string.IsNullOrEmpty(overridePath) && File.Exists(overridePath))
34-
{
35-
string overrideDirectory = Path.GetDirectoryName(overridePath);
36-
string overrideExtension = Path.GetExtension(overridePath);
37-
string overrideName = Path.GetFileNameWithoutExtension(overridePath);
38-
39-
if (!string.IsNullOrEmpty(overrideDirectory) && overrideName.Equals("uvx", StringComparison.OrdinalIgnoreCase))
40-
{
41-
string uvSibling = Path.Combine(overrideDirectory, string.IsNullOrEmpty(overrideExtension) ? "uv" : $"uv{overrideExtension}");
42-
if (File.Exists(uvSibling))
43-
{
44-
uvCommand = uvSibling;
45-
McpLog.Debug($"Using uv executable inferred from override: {uvSibling}");
46-
}
47-
else
48-
{
49-
uvCommand = overridePath;
50-
McpLog.Debug($"Using override executable: {overridePath}");
51-
}
52-
}
53-
else
54-
{
55-
uvCommand = overridePath;
56-
McpLog.Debug($"Using override executable: {overridePath}");
57-
}
58-
}
59-
else
60-
{
61-
McpLog.Debug("uv override was not found at specified location, falling back to system PATH.");
62-
}
63-
}
64-
else
65-
{
66-
McpLog.Debug("No uv override configured; using 'uv' from system PATH.");
67-
}
25+
string uvxPath = MCPServiceLocator.Paths.GetUvxPath();
26+
string uvCommand = uvxPath.Remove(uvxPath.Length - 1, 1);
6827

6928
// Get the package name
7029
string packageName = "mcp-for-unity";
@@ -105,12 +64,15 @@ private bool ExecuteUvCommand(string uvCommand, string args, out string stdout,
10564
stdout = null;
10665
stderr = null;
10766

108-
if (!string.Equals(uvCommand, "uv", StringComparison.OrdinalIgnoreCase))
67+
string uvxPath = MCPServiceLocator.Paths.GetUvxPath();
68+
string uvPath = uvxPath.Remove(uvxPath.Length - 1, 1);
69+
70+
if (!string.Equals(uvCommand, uvPath, StringComparison.OrdinalIgnoreCase))
10971
{
11072
return ExecPath.TryRun(uvCommand, args, Application.dataPath, out stdout, out stderr, 30000);
11173
}
11274

113-
string command = $"uv {args}";
75+
string command = $"{uvPath} {args}";
11476
string extraPathPrepend = GetPlatformSpecificPathPrepend();
11577

11678
if (Application.platform == RuntimePlatform.WindowsEditor)
@@ -126,7 +88,7 @@ private bool ExecuteUvCommand(string uvCommand, string args, out string stdout,
12688
return ExecPath.TryRun(shell, $"-lc \"{escaped}\"", Application.dataPath, out stdout, out stderr, 30000, extraPathPrepend);
12789
}
12890

129-
return ExecPath.TryRun("uv", args, Application.dataPath, out stdout, out stderr, 30000, extraPathPrepend);
91+
return ExecPath.TryRun(uvPath, args, Application.dataPath, out stdout, out stderr, 30000, extraPathPrepend);
13092
}
13193

13294
private string GetPlatformSpecificPathPrepend()

0 commit comments

Comments
 (0)