CoplayDev/unity-mcp · error · InvalidOperationException
Claude CLI not found. Please install Claude Code first.
Error message
Claude CLI not found. Please install Claude Code first.
What it means
ClaudeCliMcpConfigurator.RegisterWithCapturedValues() is the thread-safe registration path that uses pre-captured parameter values. It throws if claudePath is null or empty. GetClaudeCliPath() returns null when an override is set but the file does not exist (no fallback), or when ExecPath.ResolveClaude() fails to discover the binary in native-installer, npm, NVM, or PATH locations.
Source
Thrown at MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs:889
RegisterWithCapturedValues(projectDir, claudePath, pathPrepend,
useHttpTransport, httpUrl, uvxPath, fromArgs, packageName, uvxDevFlags,
apiKey, serverTransport);
}
}
/// <summary>
/// Thread-safe registration using pre-captured values.
/// </summary>
private void RegisterWithCapturedValues(
string projectDir, string claudePath, string pathPrepend,
bool useHttpTransport, string httpUrl,
string uvxPath, string fromArgs, string packageName, string uvxDevFlags,
string apiKey,
Models.ConfiguredTransport serverTransport)
{
if (string.IsNullOrEmpty(claudePath))
{
throw new InvalidOperationException("Claude CLI not found. Please install Claude Code first.");
}
string args;
if (useHttpTransport)
{
// Only include API key header for remote-hosted mode
// Use --scope local to register in the project-local config, avoiding conflicts with user-level config (#664)
if (serverTransport == Models.ConfiguredTransport.HttpRemote && !string.IsNullOrEmpty(apiKey))
{
string safeKey = SanitizeShellHeaderValue(apiKey);
args = $"mcp add --scope local --transport http UnityMCP {httpUrl} --header \"{AuthConstants.ApiKeyHeader}: {safeKey}\"";
}
else
{
args = $"mcp add --scope local --transport http UnityMCP {httpUrl}";
}
}
elseView on GitHub (pinned to c21bf496bc)
Solutions
- Install Claude Code: `npm install -g @anthropic-ai/claude-code` or use the official installer.
- If already installed, set the Claude CLI Path Override in Advanced Settings to the full path (find it with `which claude`).
- On macOS, ensure /opt/homebrew/bin or the npm global bin is in the system PATH that Unity inherits.
- Verify with `claude --version` in a terminal before retrying Configure.
Defensive patterns
Strategy: validation
Validate before calling
string claudePath = MCPServiceLocator.Paths.GetClaudeCliPath();
if (string.IsNullOrEmpty(claudePath))
{ ShowError("Claude CLI not found. Install Claude Code or set override."); return; } Try / catch
try { configurator.Configure(); }
catch (InvalidOperationException ex) when (ex.Message.Contains("Claude CLI not found"))
{ ShowInstallGuide("Claude Code", "https://claude.ai/code"); } Prevention
- Verify Claude Code is installed with `claude --version` before configuring.
- Set the CLI path override in Advanced Settings if the binary is not in PATH.
- On macOS, ensure /opt/homebrew/bin is in Unity's inherited PATH.
When it happens
Trigger: The thread-safe Configure path (called from a background task) attempts to register UnityMCP via `claude mcp add` but claudePath was null at capture time. This path is used when the configurator is invoked off the main Unity thread.
Common situations: Claude Code CLI was never installed. The Claude CLI override in Advanced Settings points to a deleted/moved binary. Claude Code was installed via npm but the npm global bin path is not in PATH. On macOS, the binary is in /opt/homebrew/bin but Unity's PATH does not include it.
Related errors
- Failed to register with Claude Code: {stderr} {stdout}
- uvx not found. Install uv/uvx or set the override in Advance
- uvx not found. Install uv/uvx or set the override in Advance
- uvx not found. Install uv/uvx or set the override in Advance
- Cherry Studio uses UI-based configuration. Please use the Ma
AI-assisted analysis of CoplayDev/unity-mcp@c21bf496bc (2026-08-13).
Data as JSON: /api/errors/112d8c5538b63ede.
Report an issue: GitHub.