CoplayDev/unity-mcp · error · ArgumentException
Folder must contain Editor and Runtime subfolders.
Error message
Folder must contain Editor and Runtime subfolders.
What it means
Thrown by ValidateSource when the source folder exists but lacks one or both required 'Editor' and 'Runtime' subdirectories. MCP for Unity packages follow a UPM-style layout that needs both; pointing at the wrong folder (e.g. the repo root) fails this check.
Source
Thrown at MCPForUnity/Editor/Services/PackageDeploymentService.cs:245
if (!Directory.Exists(sourcePath))
{
if (throwOnError)
{
throw new ArgumentException("Selected folder does not exist.");
}
return "Selected folder does not exist.";
}
bool hasEditor = Directory.Exists(Path.Combine(sourcePath, "Editor"));
bool hasRuntime = Directory.Exists(Path.Combine(sourcePath, "Runtime"));
if (!hasEditor || !hasRuntime)
{
string message = "Folder must contain Editor and Runtime subfolders.";
if (throwOnError)
{
throw new ArgumentException(message);
}
return message;
}
return null;
}
private static string MakeAbsolute(string assetPath)
{
assetPath = assetPath.Replace('\\', '/');
if (assetPath.StartsWith("Assets/", StringComparison.OrdinalIgnoreCase))
{
return Path.GetFullPath(Path.Combine(Application.dataPath, "..", assetPath));
}
if (assetPath.StartsWith("Packages/", StringComparison.OrdinalIgnoreCase))View on GitHub (pinned to c21bf496bc)
Solutions
- Point sourcePath at the package root that contains both 'Editor' and 'Runtime' subfolders (e.g. the MCPForUnity/ directory).
- If building a custom package, create both Editor/ and Runtime/ subfolders before deploying.
- Do not select the Editor/ folder itself — select its parent.
Example fix
// before — selected the repo root, which has no Editor/ + Runtime/ ValidateSource(repoRoot, throwOnError: true); // throws // after — select the package folder containing both ValidateSource(Path.Combine(repoRoot, "MCPForUnity"), throwOnError: true);
Defensive patterns
Strategy: validation
Validate before calling
bool hasEditor = Directory.Exists(Path.Combine(sourcePath, "Editor"));
bool hasRuntime = Directory.Exists(Path.Combine(sourcePath, "Runtime"));
if (!hasEditor || !hasRuntime)
return ErrorResponse("Source folder must contain Editor/ and Runtime/ subfolders."); Type guard
static bool HasPackageLayout(string p)
=> Directory.Exists(Path.Combine(p, "Editor"))
&& Directory.Exists(Path.Combine(p, "Runtime")); Try / catch
try { ValidateSource(sourcePath, throwOnError: true); }
catch (ArgumentException ex) when (ex.Message.Contains("Editor and Runtime"))
{ /* point at the package root that contains both subfolders */ } Prevention
- Select the package root containing both Editor/ and Runtime/, not the repo root or the Editor folder itself.
- For custom packages, create both subfolders before deploying.
- Use ValidateSource(throwOnError:false) to surface the structural error as a message.
When it happens
Trigger: sourcePath points at the repository root, a flat package, or a sibling folder that has no Editor/ or Runtime/ subfolder; only one of the two is present.
Common situations: User selected the repo root instead of the MCPForUnity/ package folder; a custom package built without the standard layout; selected the Editor folder itself instead of its parent.
Related errors
- Source path cannot be empty.
- Selected folder does not exist.
- Color array must have 3 or 4 elements.
- Port must be positive.
- Port {port} is already in use.
AI-assisted analysis of CoplayDev/unity-mcp@c21bf496bc (2026-08-13).
Data as JSON: /api/errors/c6e7d1e6e6dfe868.
Report an issue: GitHub.