Skip to content

Commit 7c23f24

Browse files
justinpbarnettClaudemsanatan
authored
feat: Unity Asset Store compliance with post-installation dependency setup (#281)
* feat: implement Unity Asset Store compliance with post-installation dependency setup - Remove bundled Python dependencies from Unity package - Add comprehensive 6-step setup wizard with auto-trigger on first import - Implement cross-platform dependency detection (Windows, macOS, Linux) - Add integrated MCP client configuration within setup process - Create production-ready menu structure with clean UI/UX - Ensure complete end-to-end setup requiring no additional configuration - Add comprehensive error handling and recovery mechanisms This implementation ensures Asset Store compliance while maintaining full functionality through guided user setup. Users are left 100% ready to use MCP after completing the setup wizard. * refactor: improve Asset Store compliance implementation with production-ready setup - Remove automatic installation attempts on package import - Always show setup wizard on package install/reinstall - Integrate MCP client configuration as part of setup wizard process - Ensure MCP client config window remains accessible via menu - Remove testing components for production readiness - Replace automatic installation with manual guidance only - Add complete 4-step setup flow: Welcome → Dependencies → Installation Guide → Client Configuration → Complete - Improve user experience with clear instructions and accessible client management * feat: add comprehensive dependency requirement warnings - Add critical warnings throughout setup wizard that package cannot function without dependencies - Update package.json description to clearly state manual dependency installation requirement - Prevent setup completion if dependencies are missing - Enhance skip setup warning to emphasize package will be non-functional - Add error messages explaining consequences of missing dependencies - Update menu item to indicate setup wizard is required - Ensure users understand package is completely non-functional without proper dependency installation * refactor: simplify setup wizard for production BREAKING: Reduced setup wizard from 5 steps to 3 streamlined steps: - Step 1: Setup (welcome + dependency check + installation guide) - Step 2: Configure (client configuration with direct access to full settings) - Step 3: Complete (final status and quick access to resources) Simplifications: - Consolidated UI components with DRY helper methods (DrawSectionTitle, DrawSuccessStatus, DrawErrorStatus) - Simplified dependency status display with clean icons and essential info - Removed complex state management - using simple EditorPrefs instead - Removed unused InstallationOrchestrator and SetupState classes - Streamlined client configuration to direct users to full settings window - Simplified navigation with back/skip/next buttons - Reduced code complexity while maintaining solid principles Results: - 40% less code while maintaining all functionality - Cleaner, more intuitive user flow - Faster setup process with fewer clicks - Production-ready simplicity - Easier maintenance and debugging * fix: add missing using statement for DependencyCheckResult Add missing 'using MCPForUnity.Editor.Dependencies.Models;' to resolve DependencyCheckResult type reference in SetupWizard.cs * refactor: optimize dependency checks and remove dead code * fix: remove unused DrawInstallationProgressStep method Removes leftover method that references deleted _isInstalling and _installationStatus fields, fixing compilation errors. * feat: improve setup wizard UX and add real client configuration 1. Remove dependency mentions from package.json description 2. Only show dependency warnings when dependencies are actually missing 3. Add actual MCP client configuration functionality within the wizard: - Client selection dropdown - Individual client configuration - Claude Code registration/unregistration - Batch configuration for all clients - Manual setup instructions - Real configuration file writing Users can now complete full setup including client configuration without leaving the wizard. * refactor: improve menu text and client restart tip - Remove '(Required)' from Setup Wizard menu item for cleaner appearance - Update tip to reflect that most AI clients auto-detect configuration changes * refactor: simplify client restart tip message * fix: add missing using statement for MCPForUnityEditorWindow Add 'using MCPForUnity.Editor.Windows;' to resolve unresolved symbol error for MCPForUnityEditorWindow in SetupWizard.cs * Format code * Remove unused folders * Same for validators * Same for Setup... * feat: add setup wizard persistence to avoid showing on subsequent imports * fix: update Python version check to support Python 4+ across all platform detectors * refactor: extract common platform detection logic into PlatformDetectorBase class * feat: add configuration helpers for MCP client setup with sophisticated path resolution * fix: add missing override keyword to DetectPython method in platform detectors * fix: update menu item labels for consistent capitalization and naming * fix: standardize "MCP For Unity" capitalization in window titles and dialogs * refactor: update package ID from justinpbarnett to coplaydev across codebase * refactor: remove unused validation and configuration helper methods * refactor: remove unused warnOnLegacyPackageId parameter from TryFindEmbeddedServerSource --------- Co-authored-by: Claude <claude@anthropic.com> Co-authored-by: Marcus Sanatan <msanatan@gmail.com>
1 parent f6796e6 commit 7c23f24

32 files changed

+2903
-438
lines changed

UnityMcpBridge/Editor/Dependencies.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 308 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,308 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Runtime.InteropServices;
5+
using MCPForUnity.Editor.Dependencies.Models;
6+
using MCPForUnity.Editor.Dependencies.PlatformDetectors;
7+
using MCPForUnity.Editor.Helpers;
8+
using UnityEditor;
9+
using UnityEngine;
10+
11+
namespace MCPForUnity.Editor.Dependencies
12+
{
13+
/// <summary>
14+
/// Main orchestrator for dependency validation and management
15+
/// </summary>
16+
public static class DependencyManager
17+
{
18+
private static readonly List<IPlatformDetector> _detectors = new List<IPlatformDetector>
19+
{
20+
new WindowsPlatformDetector(),
21+
new MacOSPlatformDetector(),
22+
new LinuxPlatformDetector()
23+
};
24+
25+
private static IPlatformDetector _currentDetector;
26+
27+
/// <summary>
28+
/// Get the platform detector for the current operating system
29+
/// </summary>
30+
public static IPlatformDetector GetCurrentPlatformDetector()
31+
{
32+
if (_currentDetector == null)
33+
{
34+
_currentDetector = _detectors.FirstOrDefault(d => d.CanDetect);
35+
if (_currentDetector == null)
36+
{
37+
throw new PlatformNotSupportedException($"No detector available for current platform: {RuntimeInformation.OSDescription}");
38+
}
39+
}
40+
return _currentDetector;
41+
}
42+
43+
/// <summary>
44+
/// Perform a comprehensive dependency check
45+
/// </summary>
46+
public static DependencyCheckResult CheckAllDependencies()
47+
{
48+
var result = new DependencyCheckResult();
49+
50+
try
51+
{
52+
var detector = GetCurrentPlatformDetector();
53+
McpLog.Info($"Checking dependencies on {detector.PlatformName}...", always: false);
54+
55+
// Check Python
56+
var pythonStatus = detector.DetectPython();
57+
result.Dependencies.Add(pythonStatus);
58+
59+
// Check UV
60+
var uvStatus = detector.DetectUV();
61+
result.Dependencies.Add(uvStatus);
62+
63+
// Check MCP Server
64+
var serverStatus = detector.DetectMCPServer();
65+
result.Dependencies.Add(serverStatus);
66+
67+
// Generate summary and recommendations
68+
result.GenerateSummary();
69+
GenerateRecommendations(result, detector);
70+
71+
McpLog.Info($"Dependency check completed. System ready: {result.IsSystemReady}", always: false);
72+
}
73+
catch (Exception ex)
74+
{
75+
McpLog.Error($"Error during dependency check: {ex.Message}");
76+
result.Summary = $"Dependency check failed: {ex.Message}";
77+
result.IsSystemReady = false;
78+
}
79+
80+
return result;
81+
}
82+
83+
/// <summary>
84+
/// Quick check if system is ready for MCP operations
85+
/// </summary>
86+
public static bool IsSystemReady()
87+
{
88+
try
89+
{
90+
var result = CheckAllDependencies();
91+
return result.IsSystemReady;
92+
}
93+
catch
94+
{
95+
return false;
96+
}
97+
}
98+
99+
/// <summary>
100+
/// Get a summary of missing dependencies
101+
/// </summary>
102+
public static string GetMissingDependenciesSummary()
103+
{
104+
try
105+
{
106+
var result = CheckAllDependencies();
107+
var missing = result.GetMissingRequired();
108+
109+
if (missing.Count == 0)
110+
{
111+
return "All required dependencies are available.";
112+
}
113+
114+
var names = missing.Select(d => d.Name).ToArray();
115+
return $"Missing required dependencies: {string.Join(", ", names)}";
116+
}
117+
catch (Exception ex)
118+
{
119+
return $"Error checking dependencies: {ex.Message}";
120+
}
121+
}
122+
123+
/// <summary>
124+
/// Check if a specific dependency is available
125+
/// </summary>
126+
public static bool IsDependencyAvailable(string dependencyName)
127+
{
128+
try
129+
{
130+
var detector = GetCurrentPlatformDetector();
131+
132+
return dependencyName.ToLowerInvariant() switch
133+
{
134+
"python" => detector.DetectPython().IsAvailable,
135+
"uv" => detector.DetectUV().IsAvailable,
136+
"mcpserver" or "mcp-server" => detector.DetectMCPServer().IsAvailable,
137+
_ => false
138+
};
139+
}
140+
catch
141+
{
142+
return false;
143+
}
144+
}
145+
146+
/// <summary>
147+
/// Get installation recommendations for the current platform
148+
/// </summary>
149+
public static string GetInstallationRecommendations()
150+
{
151+
try
152+
{
153+
var detector = GetCurrentPlatformDetector();
154+
return detector.GetInstallationRecommendations();
155+
}
156+
catch (Exception ex)
157+
{
158+
return $"Error getting installation recommendations: {ex.Message}";
159+
}
160+
}
161+
162+
/// <summary>
163+
/// Get platform-specific installation URLs
164+
/// </summary>
165+
public static (string pythonUrl, string uvUrl) GetInstallationUrls()
166+
{
167+
try
168+
{
169+
var detector = GetCurrentPlatformDetector();
170+
return (detector.GetPythonInstallUrl(), detector.GetUVInstallUrl());
171+
}
172+
catch
173+
{
174+
return ("https://python.org/downloads/", "https://docs.astral.sh/uv/getting-started/installation/");
175+
}
176+
}
177+
178+
/// <summary>
179+
/// Validate that the MCP server can be started
180+
/// </summary>
181+
public static bool ValidateMCPServerStartup()
182+
{
183+
try
184+
{
185+
// Check if Python and UV are available
186+
if (!IsDependencyAvailable("python") || !IsDependencyAvailable("uv"))
187+
{
188+
return false;
189+
}
190+
191+
// Try to ensure server is installed
192+
ServerInstaller.EnsureServerInstalled();
193+
194+
// Check if server files exist
195+
var serverStatus = GetCurrentPlatformDetector().DetectMCPServer();
196+
return serverStatus.IsAvailable;
197+
}
198+
catch (Exception ex)
199+
{
200+
McpLog.Error($"Error validating MCP server startup: {ex.Message}");
201+
return false;
202+
}
203+
}
204+
205+
/// <summary>
206+
/// Attempt to repair the Python environment
207+
/// </summary>
208+
public static bool RepairPythonEnvironment()
209+
{
210+
try
211+
{
212+
McpLog.Info("Attempting to repair Python environment...");
213+
return ServerInstaller.RepairPythonEnvironment();
214+
}
215+
catch (Exception ex)
216+
{
217+
McpLog.Error($"Error repairing Python environment: {ex.Message}");
218+
return false;
219+
}
220+
}
221+
222+
/// <summary>
223+
/// Get detailed dependency information for diagnostics
224+
/// </summary>
225+
public static string GetDependencyDiagnostics()
226+
{
227+
try
228+
{
229+
var result = CheckAllDependencies();
230+
var detector = GetCurrentPlatformDetector();
231+
232+
var diagnostics = new System.Text.StringBuilder();
233+
diagnostics.AppendLine($"Platform: {detector.PlatformName}");
234+
diagnostics.AppendLine($"Check Time: {result.CheckedAt:yyyy-MM-dd HH:mm:ss} UTC");
235+
diagnostics.AppendLine($"System Ready: {result.IsSystemReady}");
236+
diagnostics.AppendLine();
237+
238+
foreach (var dep in result.Dependencies)
239+
{
240+
diagnostics.AppendLine($"=== {dep.Name} ===");
241+
diagnostics.AppendLine($"Available: {dep.IsAvailable}");
242+
diagnostics.AppendLine($"Required: {dep.IsRequired}");
243+
244+
if (!string.IsNullOrEmpty(dep.Version))
245+
diagnostics.AppendLine($"Version: {dep.Version}");
246+
247+
if (!string.IsNullOrEmpty(dep.Path))
248+
diagnostics.AppendLine($"Path: {dep.Path}");
249+
250+
if (!string.IsNullOrEmpty(dep.Details))
251+
diagnostics.AppendLine($"Details: {dep.Details}");
252+
253+
if (!string.IsNullOrEmpty(dep.ErrorMessage))
254+
diagnostics.AppendLine($"Error: {dep.ErrorMessage}");
255+
256+
diagnostics.AppendLine();
257+
}
258+
259+
if (result.RecommendedActions.Count > 0)
260+
{
261+
diagnostics.AppendLine("=== Recommended Actions ===");
262+
foreach (var action in result.RecommendedActions)
263+
{
264+
diagnostics.AppendLine($"- {action}");
265+
}
266+
}
267+
268+
return diagnostics.ToString();
269+
}
270+
catch (Exception ex)
271+
{
272+
return $"Error generating diagnostics: {ex.Message}";
273+
}
274+
}
275+
276+
private static void GenerateRecommendations(DependencyCheckResult result, IPlatformDetector detector)
277+
{
278+
var missing = result.GetMissingDependencies();
279+
280+
if (missing.Count == 0)
281+
{
282+
result.RecommendedActions.Add("All dependencies are available. You can start using MCP for Unity.");
283+
return;
284+
}
285+
286+
foreach (var dep in missing)
287+
{
288+
if (dep.Name == "Python")
289+
{
290+
result.RecommendedActions.Add($"Install Python 3.10+ from: {detector.GetPythonInstallUrl()}");
291+
}
292+
else if (dep.Name == "UV Package Manager")
293+
{
294+
result.RecommendedActions.Add($"Install UV package manager from: {detector.GetUVInstallUrl()}");
295+
}
296+
else if (dep.Name == "MCP Server")
297+
{
298+
result.RecommendedActions.Add("MCP Server will be installed automatically when needed.");
299+
}
300+
}
301+
302+
if (result.GetMissingRequired().Count > 0)
303+
{
304+
result.RecommendedActions.Add("Use the Setup Wizard (Window > MCP for Unity > Setup Wizard) for guided installation.");
305+
}
306+
}
307+
}
308+
}

UnityMcpBridge/Editor/Dependencies/DependencyManager.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnityMcpBridge/Editor/Dependencies/Models.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)