Skip to content

Commit b5192a1

Browse files
committed
refactor: replace external Python scripts and batch files with new Unity Editor C# utilities and a Python server project.
1 parent 066d966 commit b5192a1

File tree

10 files changed

+16
-675
lines changed

10 files changed

+16
-675
lines changed

MCPForUnity/Editor/Dependencies/DependencyManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private static DependencyCheckResult CheckAllDependenciesInternal(DependencyCont
118118
Version = isServerReady ? "Installed" : "Missing",
119119
IsAvailable = isServerReady,
120120
Details = isServerReady ? "Virtual Environment Ready" : "Run 'Install Server Environment'",
121-
ErrorMessage = "Virtual environment not set up"
121+
ErrorMessage = isServerReady ? null : "Virtual environment not set up"
122122
});
123123
}
124124
catch (Exception ex)

MCPForUnity/Editor/Helpers/AssetPathUtility.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,11 @@ public static string GetWrapperJsPath()
140140
}
141141

142142
// Also check without the ~ just in case
143-
string wrapperPathNoTilde = Path.Combine(Path.GetDirectoryName(wrapperPath), "Server", "wrapper.js");
143+
// Also check without the ~ just in case
144+
string wrapperPathNoTilde = Path.Combine(Path.GetDirectoryName(wrapperPath), "..", "Server", "wrapper.js");
144145
if (File.Exists(wrapperPathNoTilde))
145146
{
146-
return wrapperPathNoTilde;
147+
return Path.GetFullPath(wrapperPathNoTilde);
147148
}
148149

149150
return null;

MCPForUnity/Editor/Helpers/ConfigJsonBuilder.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,14 @@ private static void PopulateUnityNode(JObject unity, string uvPath, McpClient cl
139139
}
140140

141141
// Force UTF-8 environment variables for Python Stdio stability
142-
// This is crucial when running via uvx without a wrapper to prevent "invalid trailing data" errors
143-
var env = EnsureObject(unity, "env");
144-
env["PYTHONUTF8"] = "1";
145-
env["PYTHONIOENCODING"] = "utf-8";
146-
env["PYTHONUNBUFFERED"] = "1";
142+
// (only meaningful when we're launching a process, i.e., stdio mode)
143+
if (!useHttpTransport)
144+
{
145+
var env = EnsureObject(unity, "env");
146+
env["PYTHONUTF8"] = "1";
147+
env["PYTHONIOENCODING"] = "utf-8";
148+
env["PYTHONUNBUFFERED"] = "1";
149+
}
147150

148151
bool requiresEnv = client?.EnsureEnvObject == true;
149152
bool stripEnv = client?.StripEnvWhenNotRequired == true;

MCPForUnity/Server~/pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ dev = [
2020
]
2121

2222
[project.scripts]
23-
mcp-for-unity = "main:main"
23+
mcp-for-unity = "src.main:main"
24+
25+
[tool.setuptools.packages.find]
26+
where = ["src"]
2427

2528
[build-system]
2629
requires = ["setuptools>=80.9.0", "wheel>=0.45.1"]

claude_skill_unity.zip

-73.5 KB
Binary file not shown.

deploy-dev.bat

Lines changed: 0 additions & 151 deletions
This file was deleted.

mcp_source.py

Lines changed: 0 additions & 173 deletions
This file was deleted.

0 commit comments

Comments
 (0)