unity-mcp/MCPForUnity/Editor/Services/PathResolverService.cs

246 lines
9.6 KiB
C#
Raw Normal View History

New UI and work without MCP server embedded (#313) * First pass at new UI * Point to new UI * Refactor: New Service-Based MCP Editor Window Architecture We separate the business logic from the UI rendering of the new editor window with new services. I didn't go full Dependency Injection, not sure if I want to add those deps to the install as yet, but service location is fairly straightforward. Some differences with the old window: - No more Auto-Setup, users will manually decide what they want to do - Removed Python detection warning, we have a setup wizard now - Added explicit path overrides for `uv` and the MCP server itself * style: add flex-shrink and overflow handling to improve UI element scaling * fix: update UI configuration and visibility when client status changes * feat: add menu item to open legacy MCP configuration window * refactor: improve editor window lifecycle handling with proper update subscription * feat: add auto-verification of bridge health when connected * fix: update Claude Code MCP server registration to use lowercase unityMCP name and correct the manual installation instructions * fix: add Claude CLI directory to PATH for node/nvm environments * Clarify how users will see MCP tools * Add a keyboard shortcut to open the window * feat: add server download UI and improve installation status messaging This is needed for the Unity Asset Store, which doesn't have the Python server embedded. * feat: add dynamic asset path detection to support both Package Manager and Asset Store installations * fix: replace unicode emojis with escaped characters in status messages * feat: add server package creation and GitHub release publishing to version bump workflow * fix: add v prefix to server package filename in release workflow * Fix download location * style: improve dropdown and settings layout responsiveness with flex-shrink and max-width * feat: add package.json version detection and refactor path utilities * refactor: simplify imports and use fully qualified names in ServerInstaller.cs * refactor: replace Unity Debug.Log calls with custom McpLog class * fix: extract server files to temp directory before moving to final location * docs: add v6 UI documentation and screenshots with service architecture overview * docs: add new UI Toolkit-based editor window with service architecture and path overrides * feat: improve package path resolution to support Package Manager and Asset Store installations * Change Claude Code's casing back to "UnityMCP" There's no need to break anything as yet * fix: update success dialog text to clarify manual bridge start requirement * refactor: move RefreshDebounce and ManageScriptRefreshHelpers classes inside namespace * feat: add Asset Store fallback path detection for package root lookup * fix: update server installation success message to be more descriptive * refactor: replace Unity Debug.Log calls with custom McpLog utility * fix: add file existence check before opening configuration file * refactor: simplify asset path handling and remove redundant helper namespace references * docs: update code block syntax highlighting in UI changes doc * docs: add code block syntax highlighting for file structure example * feat: import UnityEditor.UIElements namespace for UI components for Unity 2021 compatibility * refactor: rename Python server references to MCP server for consistency * fix: reset client status label color after error state is cleared * Replace the phrase "Python server" with "MCP server" * MInor doc clarification * docs: add path override methods for UV and Claude CLI executables * docs: update service locator registration method name from SetCustomImplementation to Register
2025-10-11 15:08:16 +08:00
using System;
using System.Diagnostics;
using System.IO;
using MCPForUnity.Editor.Helpers;
using UnityEditor;
using UnityEngine;
namespace MCPForUnity.Editor.Services
{
/// <summary>
/// Implementation of path resolver service with override support
/// </summary>
public class PathResolverService : IPathResolverService
{
private const string PythonDirOverrideKey = "MCPForUnity.PythonDirOverride";
private const string UvPathOverrideKey = "MCPForUnity.UvPath";
private const string ClaudeCliPathOverrideKey = "MCPForUnity.ClaudeCliPath";
public bool HasMcpServerOverride => !string.IsNullOrEmpty(EditorPrefs.GetString(PythonDirOverrideKey, null));
public bool HasUvPathOverride => !string.IsNullOrEmpty(EditorPrefs.GetString(UvPathOverrideKey, null));
public bool HasClaudeCliPathOverride => !string.IsNullOrEmpty(EditorPrefs.GetString(ClaudeCliPathOverrideKey, null));
public string GetMcpServerPath()
{
// Check for override first
string overridePath = EditorPrefs.GetString(PythonDirOverrideKey, null);
if (!string.IsNullOrEmpty(overridePath) && File.Exists(Path.Combine(overridePath, "server.py")))
{
return overridePath;
}
// Fall back to automatic detection
return McpPathResolver.FindPackagePythonDirectory(false);
}
public string GetUvPath()
{
// Check for override first
string overridePath = EditorPrefs.GetString(UvPathOverrideKey, null);
if (!string.IsNullOrEmpty(overridePath) && File.Exists(overridePath))
{
return overridePath;
}
// Fall back to automatic detection
try
{
return ServerInstaller.FindUvPath();
}
catch
{
return null;
}
}
public string GetClaudeCliPath()
{
// Check for override first
string overridePath = EditorPrefs.GetString(ClaudeCliPathOverrideKey, null);
if (!string.IsNullOrEmpty(overridePath) && File.Exists(overridePath))
{
return overridePath;
}
// Fall back to automatic detection
return ExecPath.ResolveClaude();
}
public bool IsPythonDetected()
{
try
{
// Windows-specific Python detection
if (Application.platform == RuntimePlatform.WindowsEditor)
{
// Common Windows Python installation paths
string[] windowsCandidates =
{
feat: lower minimum Python requirement to 3.10+ (#362) * feat: lower minimum Python requirement to 3.10+ - Updated Python version requirement from 3.11+ to 3.10+ across all platform detectors - Added Python 3.10 to MacOS framework search paths for broader compatibility - Modified version validation logic to accept Python 3.10 or higher - Updated documentation and error messages to reflect new minimum Python version - Changed pyproject.toml requires-python field to ">=3.10" - Updated badges and requirements in README files to show Python 3.10 support * feat: add Python 3.10 and 3.11 to Windows path detection - Added Python 3.10 installation path to LocalApplicationData search locations - Added Python 3.10 and 3.11 paths to ProgramFiles search locations - Expanded Python version compatibility to support older installations while maintaining support for newer versions * feat: add Python 3.14 support and update path detection - Added Python 3.14 installation paths to Windows and macOS platform detectors - Removed legacy Python 3.9 paths from Windows path detection - Updated Windows installation recommendations to suggest Python 3.10 or higher - Added additional Python framework paths (3.10, 3.11) for macOS UV package manager detection - Extended UV executable path detection to include Python 3.14 locations on both platforms * Reduce size of README img * Revert "Reduce size of README img" This reverts commit 6fb99c7047bdef3610fb94dd3741c71c9e3ffcc1. * Adjust size in README to maintain quality but be smaller
2025-11-01 03:44:10 +08:00
@"C:\Python314\python.exe",
New UI and work without MCP server embedded (#313) * First pass at new UI * Point to new UI * Refactor: New Service-Based MCP Editor Window Architecture We separate the business logic from the UI rendering of the new editor window with new services. I didn't go full Dependency Injection, not sure if I want to add those deps to the install as yet, but service location is fairly straightforward. Some differences with the old window: - No more Auto-Setup, users will manually decide what they want to do - Removed Python detection warning, we have a setup wizard now - Added explicit path overrides for `uv` and the MCP server itself * style: add flex-shrink and overflow handling to improve UI element scaling * fix: update UI configuration and visibility when client status changes * feat: add menu item to open legacy MCP configuration window * refactor: improve editor window lifecycle handling with proper update subscription * feat: add auto-verification of bridge health when connected * fix: update Claude Code MCP server registration to use lowercase unityMCP name and correct the manual installation instructions * fix: add Claude CLI directory to PATH for node/nvm environments * Clarify how users will see MCP tools * Add a keyboard shortcut to open the window * feat: add server download UI and improve installation status messaging This is needed for the Unity Asset Store, which doesn't have the Python server embedded. * feat: add dynamic asset path detection to support both Package Manager and Asset Store installations * fix: replace unicode emojis with escaped characters in status messages * feat: add server package creation and GitHub release publishing to version bump workflow * fix: add v prefix to server package filename in release workflow * Fix download location * style: improve dropdown and settings layout responsiveness with flex-shrink and max-width * feat: add package.json version detection and refactor path utilities * refactor: simplify imports and use fully qualified names in ServerInstaller.cs * refactor: replace Unity Debug.Log calls with custom McpLog class * fix: extract server files to temp directory before moving to final location * docs: add v6 UI documentation and screenshots with service architecture overview * docs: add new UI Toolkit-based editor window with service architecture and path overrides * feat: improve package path resolution to support Package Manager and Asset Store installations * Change Claude Code's casing back to "UnityMCP" There's no need to break anything as yet * fix: update success dialog text to clarify manual bridge start requirement * refactor: move RefreshDebounce and ManageScriptRefreshHelpers classes inside namespace * feat: add Asset Store fallback path detection for package root lookup * fix: update server installation success message to be more descriptive * refactor: replace Unity Debug.Log calls with custom McpLog utility * fix: add file existence check before opening configuration file * refactor: simplify asset path handling and remove redundant helper namespace references * docs: update code block syntax highlighting in UI changes doc * docs: add code block syntax highlighting for file structure example * feat: import UnityEditor.UIElements namespace for UI components for Unity 2021 compatibility * refactor: rename Python server references to MCP server for consistency * fix: reset client status label color after error state is cleared * Replace the phrase "Python server" with "MCP server" * MInor doc clarification * docs: add path override methods for UV and Claude CLI executables * docs: update service locator registration method name from SetCustomImplementation to Register
2025-10-11 15:08:16 +08:00
@"C:\Python313\python.exe",
@"C:\Python312\python.exe",
@"C:\Python311\python.exe",
@"C:\Python310\python.exe",
feat: lower minimum Python requirement to 3.10+ (#362) * feat: lower minimum Python requirement to 3.10+ - Updated Python version requirement from 3.11+ to 3.10+ across all platform detectors - Added Python 3.10 to MacOS framework search paths for broader compatibility - Modified version validation logic to accept Python 3.10 or higher - Updated documentation and error messages to reflect new minimum Python version - Changed pyproject.toml requires-python field to ">=3.10" - Updated badges and requirements in README files to show Python 3.10 support * feat: add Python 3.10 and 3.11 to Windows path detection - Added Python 3.10 installation path to LocalApplicationData search locations - Added Python 3.10 and 3.11 paths to ProgramFiles search locations - Expanded Python version compatibility to support older installations while maintaining support for newer versions * feat: add Python 3.14 support and update path detection - Added Python 3.14 installation paths to Windows and macOS platform detectors - Removed legacy Python 3.9 paths from Windows path detection - Updated Windows installation recommendations to suggest Python 3.10 or higher - Added additional Python framework paths (3.10, 3.11) for macOS UV package manager detection - Extended UV executable path detection to include Python 3.14 locations on both platforms * Reduce size of README img * Revert "Reduce size of README img" This reverts commit 6fb99c7047bdef3610fb94dd3741c71c9e3ffcc1. * Adjust size in README to maintain quality but be smaller
2025-11-01 03:44:10 +08:00
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Programs\Python\Python314\python.exe"),
New UI and work without MCP server embedded (#313) * First pass at new UI * Point to new UI * Refactor: New Service-Based MCP Editor Window Architecture We separate the business logic from the UI rendering of the new editor window with new services. I didn't go full Dependency Injection, not sure if I want to add those deps to the install as yet, but service location is fairly straightforward. Some differences with the old window: - No more Auto-Setup, users will manually decide what they want to do - Removed Python detection warning, we have a setup wizard now - Added explicit path overrides for `uv` and the MCP server itself * style: add flex-shrink and overflow handling to improve UI element scaling * fix: update UI configuration and visibility when client status changes * feat: add menu item to open legacy MCP configuration window * refactor: improve editor window lifecycle handling with proper update subscription * feat: add auto-verification of bridge health when connected * fix: update Claude Code MCP server registration to use lowercase unityMCP name and correct the manual installation instructions * fix: add Claude CLI directory to PATH for node/nvm environments * Clarify how users will see MCP tools * Add a keyboard shortcut to open the window * feat: add server download UI and improve installation status messaging This is needed for the Unity Asset Store, which doesn't have the Python server embedded. * feat: add dynamic asset path detection to support both Package Manager and Asset Store installations * fix: replace unicode emojis with escaped characters in status messages * feat: add server package creation and GitHub release publishing to version bump workflow * fix: add v prefix to server package filename in release workflow * Fix download location * style: improve dropdown and settings layout responsiveness with flex-shrink and max-width * feat: add package.json version detection and refactor path utilities * refactor: simplify imports and use fully qualified names in ServerInstaller.cs * refactor: replace Unity Debug.Log calls with custom McpLog class * fix: extract server files to temp directory before moving to final location * docs: add v6 UI documentation and screenshots with service architecture overview * docs: add new UI Toolkit-based editor window with service architecture and path overrides * feat: improve package path resolution to support Package Manager and Asset Store installations * Change Claude Code's casing back to "UnityMCP" There's no need to break anything as yet * fix: update success dialog text to clarify manual bridge start requirement * refactor: move RefreshDebounce and ManageScriptRefreshHelpers classes inside namespace * feat: add Asset Store fallback path detection for package root lookup * fix: update server installation success message to be more descriptive * refactor: replace Unity Debug.Log calls with custom McpLog utility * fix: add file existence check before opening configuration file * refactor: simplify asset path handling and remove redundant helper namespace references * docs: update code block syntax highlighting in UI changes doc * docs: add code block syntax highlighting for file structure example * feat: import UnityEditor.UIElements namespace for UI components for Unity 2021 compatibility * refactor: rename Python server references to MCP server for consistency * fix: reset client status label color after error state is cleared * Replace the phrase "Python server" with "MCP server" * MInor doc clarification * docs: add path override methods for UV and Claude CLI executables * docs: update service locator registration method name from SetCustomImplementation to Register
2025-10-11 15:08:16 +08:00
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Programs\Python\Python313\python.exe"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Programs\Python\Python312\python.exe"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Programs\Python\Python311\python.exe"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Programs\Python\Python310\python.exe"),
feat: lower minimum Python requirement to 3.10+ (#362) * feat: lower minimum Python requirement to 3.10+ - Updated Python version requirement from 3.11+ to 3.10+ across all platform detectors - Added Python 3.10 to MacOS framework search paths for broader compatibility - Modified version validation logic to accept Python 3.10 or higher - Updated documentation and error messages to reflect new minimum Python version - Changed pyproject.toml requires-python field to ">=3.10" - Updated badges and requirements in README files to show Python 3.10 support * feat: add Python 3.10 and 3.11 to Windows path detection - Added Python 3.10 installation path to LocalApplicationData search locations - Added Python 3.10 and 3.11 paths to ProgramFiles search locations - Expanded Python version compatibility to support older installations while maintaining support for newer versions * feat: add Python 3.14 support and update path detection - Added Python 3.14 installation paths to Windows and macOS platform detectors - Removed legacy Python 3.9 paths from Windows path detection - Updated Windows installation recommendations to suggest Python 3.10 or higher - Added additional Python framework paths (3.10, 3.11) for macOS UV package manager detection - Extended UV executable path detection to include Python 3.14 locations on both platforms * Reduce size of README img * Revert "Reduce size of README img" This reverts commit 6fb99c7047bdef3610fb94dd3741c71c9e3ffcc1. * Adjust size in README to maintain quality but be smaller
2025-11-01 03:44:10 +08:00
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Python314\python.exe"),
New UI and work without MCP server embedded (#313) * First pass at new UI * Point to new UI * Refactor: New Service-Based MCP Editor Window Architecture We separate the business logic from the UI rendering of the new editor window with new services. I didn't go full Dependency Injection, not sure if I want to add those deps to the install as yet, but service location is fairly straightforward. Some differences with the old window: - No more Auto-Setup, users will manually decide what they want to do - Removed Python detection warning, we have a setup wizard now - Added explicit path overrides for `uv` and the MCP server itself * style: add flex-shrink and overflow handling to improve UI element scaling * fix: update UI configuration and visibility when client status changes * feat: add menu item to open legacy MCP configuration window * refactor: improve editor window lifecycle handling with proper update subscription * feat: add auto-verification of bridge health when connected * fix: update Claude Code MCP server registration to use lowercase unityMCP name and correct the manual installation instructions * fix: add Claude CLI directory to PATH for node/nvm environments * Clarify how users will see MCP tools * Add a keyboard shortcut to open the window * feat: add server download UI and improve installation status messaging This is needed for the Unity Asset Store, which doesn't have the Python server embedded. * feat: add dynamic asset path detection to support both Package Manager and Asset Store installations * fix: replace unicode emojis with escaped characters in status messages * feat: add server package creation and GitHub release publishing to version bump workflow * fix: add v prefix to server package filename in release workflow * Fix download location * style: improve dropdown and settings layout responsiveness with flex-shrink and max-width * feat: add package.json version detection and refactor path utilities * refactor: simplify imports and use fully qualified names in ServerInstaller.cs * refactor: replace Unity Debug.Log calls with custom McpLog class * fix: extract server files to temp directory before moving to final location * docs: add v6 UI documentation and screenshots with service architecture overview * docs: add new UI Toolkit-based editor window with service architecture and path overrides * feat: improve package path resolution to support Package Manager and Asset Store installations * Change Claude Code's casing back to "UnityMCP" There's no need to break anything as yet * fix: update success dialog text to clarify manual bridge start requirement * refactor: move RefreshDebounce and ManageScriptRefreshHelpers classes inside namespace * feat: add Asset Store fallback path detection for package root lookup * fix: update server installation success message to be more descriptive * refactor: replace Unity Debug.Log calls with custom McpLog utility * fix: add file existence check before opening configuration file * refactor: simplify asset path handling and remove redundant helper namespace references * docs: update code block syntax highlighting in UI changes doc * docs: add code block syntax highlighting for file structure example * feat: import UnityEditor.UIElements namespace for UI components for Unity 2021 compatibility * refactor: rename Python server references to MCP server for consistency * fix: reset client status label color after error state is cleared * Replace the phrase "Python server" with "MCP server" * MInor doc clarification * docs: add path override methods for UV and Claude CLI executables * docs: update service locator registration method name from SetCustomImplementation to Register
2025-10-11 15:08:16 +08:00
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Python313\python.exe"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Python312\python.exe"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Python311\python.exe"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Python310\python.exe"),
};
foreach (string c in windowsCandidates)
{
if (File.Exists(c)) return true;
}
// Try 'where python' command (Windows equivalent of 'which')
var psi = new ProcessStartInfo
{
FileName = "where",
Arguments = "python",
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
};
using (var p = Process.Start(psi))
{
string outp = p.StandardOutput.ReadToEnd().Trim();
p.WaitForExit(2000);
if (p.ExitCode == 0 && !string.IsNullOrEmpty(outp))
{
string[] lines = outp.Split('\n');
foreach (string line in lines)
{
string trimmed = line.Trim();
if (File.Exists(trimmed)) return true;
}
}
}
}
else
{
// macOS/Linux detection
string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) ?? string.Empty;
string[] candidates =
{
"/opt/homebrew/bin/python3",
"/usr/local/bin/python3",
"/usr/bin/python3",
"/opt/local/bin/python3",
Path.Combine(home, ".local", "bin", "python3"),
feat: lower minimum Python requirement to 3.10+ (#362) * feat: lower minimum Python requirement to 3.10+ - Updated Python version requirement from 3.11+ to 3.10+ across all platform detectors - Added Python 3.10 to MacOS framework search paths for broader compatibility - Modified version validation logic to accept Python 3.10 or higher - Updated documentation and error messages to reflect new minimum Python version - Changed pyproject.toml requires-python field to ">=3.10" - Updated badges and requirements in README files to show Python 3.10 support * feat: add Python 3.10 and 3.11 to Windows path detection - Added Python 3.10 installation path to LocalApplicationData search locations - Added Python 3.10 and 3.11 paths to ProgramFiles search locations - Expanded Python version compatibility to support older installations while maintaining support for newer versions * feat: add Python 3.14 support and update path detection - Added Python 3.14 installation paths to Windows and macOS platform detectors - Removed legacy Python 3.9 paths from Windows path detection - Updated Windows installation recommendations to suggest Python 3.10 or higher - Added additional Python framework paths (3.10, 3.11) for macOS UV package manager detection - Extended UV executable path detection to include Python 3.14 locations on both platforms * Reduce size of README img * Revert "Reduce size of README img" This reverts commit 6fb99c7047bdef3610fb94dd3741c71c9e3ffcc1. * Adjust size in README to maintain quality but be smaller
2025-11-01 03:44:10 +08:00
"/Library/Frameworks/Python.framework/Versions/3.14/bin/python3",
New UI and work without MCP server embedded (#313) * First pass at new UI * Point to new UI * Refactor: New Service-Based MCP Editor Window Architecture We separate the business logic from the UI rendering of the new editor window with new services. I didn't go full Dependency Injection, not sure if I want to add those deps to the install as yet, but service location is fairly straightforward. Some differences with the old window: - No more Auto-Setup, users will manually decide what they want to do - Removed Python detection warning, we have a setup wizard now - Added explicit path overrides for `uv` and the MCP server itself * style: add flex-shrink and overflow handling to improve UI element scaling * fix: update UI configuration and visibility when client status changes * feat: add menu item to open legacy MCP configuration window * refactor: improve editor window lifecycle handling with proper update subscription * feat: add auto-verification of bridge health when connected * fix: update Claude Code MCP server registration to use lowercase unityMCP name and correct the manual installation instructions * fix: add Claude CLI directory to PATH for node/nvm environments * Clarify how users will see MCP tools * Add a keyboard shortcut to open the window * feat: add server download UI and improve installation status messaging This is needed for the Unity Asset Store, which doesn't have the Python server embedded. * feat: add dynamic asset path detection to support both Package Manager and Asset Store installations * fix: replace unicode emojis with escaped characters in status messages * feat: add server package creation and GitHub release publishing to version bump workflow * fix: add v prefix to server package filename in release workflow * Fix download location * style: improve dropdown and settings layout responsiveness with flex-shrink and max-width * feat: add package.json version detection and refactor path utilities * refactor: simplify imports and use fully qualified names in ServerInstaller.cs * refactor: replace Unity Debug.Log calls with custom McpLog class * fix: extract server files to temp directory before moving to final location * docs: add v6 UI documentation and screenshots with service architecture overview * docs: add new UI Toolkit-based editor window with service architecture and path overrides * feat: improve package path resolution to support Package Manager and Asset Store installations * Change Claude Code's casing back to "UnityMCP" There's no need to break anything as yet * fix: update success dialog text to clarify manual bridge start requirement * refactor: move RefreshDebounce and ManageScriptRefreshHelpers classes inside namespace * feat: add Asset Store fallback path detection for package root lookup * fix: update server installation success message to be more descriptive * refactor: replace Unity Debug.Log calls with custom McpLog utility * fix: add file existence check before opening configuration file * refactor: simplify asset path handling and remove redundant helper namespace references * docs: update code block syntax highlighting in UI changes doc * docs: add code block syntax highlighting for file structure example * feat: import UnityEditor.UIElements namespace for UI components for Unity 2021 compatibility * refactor: rename Python server references to MCP server for consistency * fix: reset client status label color after error state is cleared * Replace the phrase "Python server" with "MCP server" * MInor doc clarification * docs: add path override methods for UV and Claude CLI executables * docs: update service locator registration method name from SetCustomImplementation to Register
2025-10-11 15:08:16 +08:00
"/Library/Frameworks/Python.framework/Versions/3.13/bin/python3",
"/Library/Frameworks/Python.framework/Versions/3.12/bin/python3",
feat: lower minimum Python requirement to 3.10+ (#362) * feat: lower minimum Python requirement to 3.10+ - Updated Python version requirement from 3.11+ to 3.10+ across all platform detectors - Added Python 3.10 to MacOS framework search paths for broader compatibility - Modified version validation logic to accept Python 3.10 or higher - Updated documentation and error messages to reflect new minimum Python version - Changed pyproject.toml requires-python field to ">=3.10" - Updated badges and requirements in README files to show Python 3.10 support * feat: add Python 3.10 and 3.11 to Windows path detection - Added Python 3.10 installation path to LocalApplicationData search locations - Added Python 3.10 and 3.11 paths to ProgramFiles search locations - Expanded Python version compatibility to support older installations while maintaining support for newer versions * feat: add Python 3.14 support and update path detection - Added Python 3.14 installation paths to Windows and macOS platform detectors - Removed legacy Python 3.9 paths from Windows path detection - Updated Windows installation recommendations to suggest Python 3.10 or higher - Added additional Python framework paths (3.10, 3.11) for macOS UV package manager detection - Extended UV executable path detection to include Python 3.14 locations on both platforms * Reduce size of README img * Revert "Reduce size of README img" This reverts commit 6fb99c7047bdef3610fb94dd3741c71c9e3ffcc1. * Adjust size in README to maintain quality but be smaller
2025-11-01 03:44:10 +08:00
"/Library/Frameworks/Python.framework/Versions/3.11/bin/python3",
"/Library/Frameworks/Python.framework/Versions/3.10/bin/python3",
New UI and work without MCP server embedded (#313) * First pass at new UI * Point to new UI * Refactor: New Service-Based MCP Editor Window Architecture We separate the business logic from the UI rendering of the new editor window with new services. I didn't go full Dependency Injection, not sure if I want to add those deps to the install as yet, but service location is fairly straightforward. Some differences with the old window: - No more Auto-Setup, users will manually decide what they want to do - Removed Python detection warning, we have a setup wizard now - Added explicit path overrides for `uv` and the MCP server itself * style: add flex-shrink and overflow handling to improve UI element scaling * fix: update UI configuration and visibility when client status changes * feat: add menu item to open legacy MCP configuration window * refactor: improve editor window lifecycle handling with proper update subscription * feat: add auto-verification of bridge health when connected * fix: update Claude Code MCP server registration to use lowercase unityMCP name and correct the manual installation instructions * fix: add Claude CLI directory to PATH for node/nvm environments * Clarify how users will see MCP tools * Add a keyboard shortcut to open the window * feat: add server download UI and improve installation status messaging This is needed for the Unity Asset Store, which doesn't have the Python server embedded. * feat: add dynamic asset path detection to support both Package Manager and Asset Store installations * fix: replace unicode emojis with escaped characters in status messages * feat: add server package creation and GitHub release publishing to version bump workflow * fix: add v prefix to server package filename in release workflow * Fix download location * style: improve dropdown and settings layout responsiveness with flex-shrink and max-width * feat: add package.json version detection and refactor path utilities * refactor: simplify imports and use fully qualified names in ServerInstaller.cs * refactor: replace Unity Debug.Log calls with custom McpLog class * fix: extract server files to temp directory before moving to final location * docs: add v6 UI documentation and screenshots with service architecture overview * docs: add new UI Toolkit-based editor window with service architecture and path overrides * feat: improve package path resolution to support Package Manager and Asset Store installations * Change Claude Code's casing back to "UnityMCP" There's no need to break anything as yet * fix: update success dialog text to clarify manual bridge start requirement * refactor: move RefreshDebounce and ManageScriptRefreshHelpers classes inside namespace * feat: add Asset Store fallback path detection for package root lookup * fix: update server installation success message to be more descriptive * refactor: replace Unity Debug.Log calls with custom McpLog utility * fix: add file existence check before opening configuration file * refactor: simplify asset path handling and remove redundant helper namespace references * docs: update code block syntax highlighting in UI changes doc * docs: add code block syntax highlighting for file structure example * feat: import UnityEditor.UIElements namespace for UI components for Unity 2021 compatibility * refactor: rename Python server references to MCP server for consistency * fix: reset client status label color after error state is cleared * Replace the phrase "Python server" with "MCP server" * MInor doc clarification * docs: add path override methods for UV and Claude CLI executables * docs: update service locator registration method name from SetCustomImplementation to Register
2025-10-11 15:08:16 +08:00
};
foreach (string c in candidates)
{
if (File.Exists(c)) return true;
}
// Try 'which python3'
var psi = new ProcessStartInfo
{
FileName = "/usr/bin/which",
Arguments = "python3",
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
};
using (var p = Process.Start(psi))
{
string outp = p.StandardOutput.ReadToEnd().Trim();
p.WaitForExit(2000);
if (p.ExitCode == 0 && !string.IsNullOrEmpty(outp) && File.Exists(outp)) return true;
}
}
}
catch { }
return false;
}
public bool IsUvDetected()
{
return !string.IsNullOrEmpty(GetUvPath());
}
public bool IsClaudeCliDetected()
{
return !string.IsNullOrEmpty(GetClaudeCliPath());
}
public void SetMcpServerOverride(string path)
{
if (string.IsNullOrEmpty(path))
{
ClearMcpServerOverride();
return;
}
if (!File.Exists(Path.Combine(path, "server.py")))
{
throw new ArgumentException("The selected folder does not contain server.py");
}
EditorPrefs.SetString(PythonDirOverrideKey, path);
}
public void SetUvPathOverride(string path)
{
if (string.IsNullOrEmpty(path))
{
ClearUvPathOverride();
return;
}
if (!File.Exists(path))
{
throw new ArgumentException("The selected UV executable does not exist");
}
EditorPrefs.SetString(UvPathOverrideKey, path);
}
public void SetClaudeCliPathOverride(string path)
{
if (string.IsNullOrEmpty(path))
{
ClearClaudeCliPathOverride();
return;
}
if (!File.Exists(path))
{
throw new ArgumentException("The selected Claude CLI executable does not exist");
}
EditorPrefs.SetString(ClaudeCliPathOverrideKey, path);
// Also update the ExecPath helper for backwards compatibility
ExecPath.SetClaudeCliPath(path);
}
public void ClearMcpServerOverride()
{
EditorPrefs.DeleteKey(PythonDirOverrideKey);
}
public void ClearUvPathOverride()
{
EditorPrefs.DeleteKey(UvPathOverrideKey);
}
public void ClearClaudeCliPathOverride()
{
EditorPrefs.DeleteKey(ClaudeCliPathOverrideKey);
}
}
}