{"record":{"id":"2008e7889e10ac60","repo":"eyaltoledano/claude-task-master","slug":"warning-could-not-find-project-root-to-check-mcp","errorCode":null,"errorMessage":"Warning: Could not find project root to check mcp.json.","messagePattern":"Warning: Could not find project root to check mcp\\.json\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"scripts/modules/config-manager.js","lineNumber":941,"sourceCode":"\treturn (\n\t\tapiKeyValue &&\n\t\tapiKeyValue.trim() !== '' &&\n\t\t!/YOUR_.*_API_KEY_HERE/.test(apiKeyValue) && // General placeholder check\n\t\t!apiKeyValue.includes('KEY_HERE')\n\t); // Another common placeholder pattern\n}\n\n/**\n * Checks the API key status within .cursor/mcp.json for a given provider.\n * Reads the mcp.json file, finds the taskmaster-ai server config, and checks the relevant env var.\n * @param {string} providerName The name of the provider.\n * @param {string|null} projectRoot - Optional explicit path to the project root.\n * @returns {boolean} True if the key exists and is not a placeholder, false otherwise.\n */\nfunction getMcpApiKeyStatus(providerName, projectRoot = null) {\n\tconst rootDir = projectRoot || findProjectRoot(); // Use existing root finding\n\tif (!rootDir) {\n\t\tconsole.warn(\n\t\t\tchalk.yellow('Warning: Could not find project root to check mcp.json.')\n\t\t);\n\t\treturn false; // Cannot check without root\n\t}\n\tconst mcpConfigPath = path.join(rootDir, '.cursor', 'mcp.json');\n\n\tif (!fs.existsSync(mcpConfigPath)) {\n\t\t// console.warn(chalk.yellow('Warning: .cursor/mcp.json not found.'));\n\t\treturn false; // File doesn't exist\n\t}\n\n\ttry {\n\t\tconst mcpConfigRaw = fs.readFileSync(mcpConfigPath, 'utf-8');\n\t\tconst mcpConfig = JSON.parse(mcpConfigRaw);\n\n\t\tconst mcpEnv =\n\t\t\tmcpConfig?.mcpServers?.['task-master-ai']?.env ||\n\t\t\tmcpConfig?.mcpServers?.['taskmaster-ai']?.env;","sourceCodeStart":923,"sourceCodeEnd":959,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/config-manager.js#L923-L959","documentation":"getMcpApiKeyStatus checks whether an API key for a provider is present in <projectRoot>/.cursor/mcp.json (and not a placeholder). If no project root can be found (explicit root is null and findProjectRoot() fails), it emits this warning and returns false, meaning 'cannot verify key presence'.","triggerScenarios":"Calling getMcpApiKeyStatus(providerName) without a projectRoot argument from an environment where findProjectRoot() cannot locate a project root (no .taskmaster/.git markers upward from cwd).","commonSituations":"Running task-master from a home directory or temp dir outside any project; invoking MCP-shipped tools from a working directory detached from the project; embedding Task Master in scripts run with the wrong cwd.","solutions":["Run the command from inside your project directory (the one containing .taskmaster or .git).","Pass the project root explicitly: getMcpApiKeyStatus(provider, '/path/to/project').","Create .cursor/mcp.json in the project if you intend to use Cursor MCP-scoped API keys, and set up project markers."],"exampleFix":"// before\ngetMcpApiKeyStatus('anthropic');\n// after\ngetMcpApiKeyStatus('anthropic', '/home/me/my-app');","handlingStrategy":"validation","validationCode":"const { findProjectRoot } = require('./scripts/modules/utils.js');\nconst root = explicitRoot || findProjectRoot();\nif (!root) {\n  console.error('Run from inside a task-master project or pass projectRoot explicitly');\n} else {\n  getMcpApiKeyStatus('anthropic', root);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass projectRoot explicitly when calling ConfigManager/API functions from scripts.","Run commands with cwd set to the project directory.","Ensure project marker files (.taskmaster or .git) exist at the expected root."],"tags":["config","project-root","mcp"],"backgroundTag":"project-root-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}