{"record":{"id":"112d8c5538b63ede","repo":"CoplayDev/unity-mcp","slug":"claude-cli-not-found-please-install-claude-code-f","errorCode":null,"errorMessage":"Claude CLI not found. Please install Claude Code first.","messagePattern":"Claude CLI not found\\. Please install Claude Code first\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs","lineNumber":889,"sourceCode":"                RegisterWithCapturedValues(projectDir, claudePath, pathPrepend,\n                    useHttpTransport, httpUrl, uvxPath, fromArgs, packageName, uvxDevFlags,\n                    apiKey, serverTransport);\n            }\n        }\n\n        /// <summary>\n        /// Thread-safe registration using pre-captured values.\n        /// </summary>\n        private void RegisterWithCapturedValues(\n            string projectDir, string claudePath, string pathPrepend,\n            bool useHttpTransport, string httpUrl,\n            string uvxPath, string fromArgs, string packageName, string uvxDevFlags,\n            string apiKey,\n            Models.ConfiguredTransport serverTransport)\n        {\n            if (string.IsNullOrEmpty(claudePath))\n            {\n                throw new InvalidOperationException(\"Claude CLI not found. Please install Claude Code first.\");\n            }\n\n            string args;\n            if (useHttpTransport)\n            {\n                // Only include API key header for remote-hosted mode\n                // Use --scope local to register in the project-local config, avoiding conflicts with user-level config (#664)\n                if (serverTransport == Models.ConfiguredTransport.HttpRemote && !string.IsNullOrEmpty(apiKey))\n                {\n                    string safeKey = SanitizeShellHeaderValue(apiKey);\n                    args = $\"mcp add --scope local --transport http UnityMCP {httpUrl} --header \\\"{AuthConstants.ApiKeyHeader}: {safeKey}\\\"\";\n                }\n                else\n                {\n                    args = $\"mcp add --scope local --transport http UnityMCP {httpUrl}\";\n                }\n            }\n            else","sourceCodeStart":871,"sourceCodeEnd":907,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs#L871-L907","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"string claudePath = MCPServiceLocator.Paths.GetClaudeCliPath();\nif (string.IsNullOrEmpty(claudePath))\n{ ShowError(\"Claude CLI not found. Install Claude Code or set override.\"); return; }","typeGuard":null,"tryCatchPattern":"try { configurator.Configure(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Claude CLI not found\"))\n{ ShowInstallGuide(\"Claude Code\", \"https://claude.ai/code\"); }","preventionTips":["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."],"tags":["configuration","claude-cli","dependency","registration","thread-safe"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}