Skip to content

Commit eeaa7a2

Browse files
updated to find correct directory when installing to claude desktop automatically
1 parent 46db62b commit eeaa7a2

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

Editor/MCPEditorWindow.cs

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,41 @@ private void ConfigureClaudeDesktop()
273273
// Create directory if it doesn't exist
274274
Directory.CreateDirectory(Path.GetDirectoryName(configPath));
275275

276-
// Get the absolute path to the Python directory
277-
string pythonDir = Path.GetFullPath(Path.Combine(Application.dataPath, "unity-mcp", "Python"));
278-
UnityEngine.Debug.Log($"Python directory path: {pythonDir}");
276+
// Find the server.py file location
277+
string serverPath = null;
278+
string pythonDir = null;
279+
280+
// First try to find it in the current project's Assets folder
281+
string localServerPath = Path.GetFullPath(Path.Combine(Application.dataPath, "unity-mcp", "Python", "server.py"));
282+
if (File.Exists(localServerPath))
283+
{
284+
serverPath = localServerPath;
285+
pythonDir = Path.GetDirectoryName(serverPath);
286+
}
287+
else
288+
{
289+
// If not found locally, try to find it in the package cache
290+
string packageName = "com.justinpbarnett.unitymcpserver";
291+
string packageCachePath = Path.Combine(Application.dataPath, "..", "Library", "PackageCache", packageName);
292+
if (Directory.Exists(packageCachePath))
293+
{
294+
serverPath = Path.GetFullPath(Path.Combine(packageCachePath, "Python", "server.py"));
295+
if (File.Exists(serverPath))
296+
{
297+
pythonDir = Path.GetDirectoryName(serverPath);
298+
}
299+
}
300+
}
301+
302+
if (serverPath == null || !File.Exists(serverPath))
303+
{
304+
claudeConfigStatus = "Error: Could not find server.py";
305+
UnityEngine.Debug.LogError("Could not find server.py in either local project or package cache");
306+
return;
307+
}
308+
309+
UnityEngine.Debug.Log($"Found server.py at: {serverPath}");
310+
UnityEngine.Debug.Log($"Python directory: {pythonDir}");
279311

280312
// Create configuration object
281313
var config = new MCPConfig

0 commit comments

Comments
 (0)