eyaltoledano/claude-task-master · warning

Warning: Could not find project root to check mcp.json.

Error message

Warning: Could not find project root to check mcp.json.

What it means

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'.

Solutions

  1. Run the command from inside your project directory (the one containing .taskmaster or .git).
  2. Pass the project root explicitly: getMcpApiKeyStatus(provider, '/path/to/project').
  3. Create .cursor/mcp.json in the project if you intend to use Cursor MCP-scoped API keys, and set up project markers.

Example fix

// before
getMcpApiKeyStatus('anthropic');
// after
getMcpApiKeyStatus('anthropic', '/home/me/my-app');
Defensive patterns

Strategy: validation

Validate before calling

const { findProjectRoot } = require('./scripts/modules/utils.js');
const root = explicitRoot || findProjectRoot();
if (!root) {
  console.error('Run from inside a task-master project or pass projectRoot explicitly');
} else {
  getMcpApiKeyStatus('anthropic', root);
}

Prevention

When it happens

Trigger: Calling getMcpApiKeyStatus(providerName) without a projectRoot argument from an environment where findProjectRoot() cannot locate a project root (no .taskmaster/.git markers upward from cwd).

Common situations: 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.

Related errors


AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29). Data as JSON: /api/errors/2008e7889e10ac60. Report an issue: GitHub.

Appendix: source

Thrown at scripts/modules/config-manager.js:941

	return (
		apiKeyValue &&
		apiKeyValue.trim() !== '' &&
		!/YOUR_.*_API_KEY_HERE/.test(apiKeyValue) && // General placeholder check
		!apiKeyValue.includes('KEY_HERE')
	); // Another common placeholder pattern
}

/**
 * Checks the API key status within .cursor/mcp.json for a given provider.
 * Reads the mcp.json file, finds the taskmaster-ai server config, and checks the relevant env var.
 * @param {string} providerName The name of the provider.
 * @param {string|null} projectRoot - Optional explicit path to the project root.
 * @returns {boolean} True if the key exists and is not a placeholder, false otherwise.
 */
function getMcpApiKeyStatus(providerName, projectRoot = null) {
	const rootDir = projectRoot || findProjectRoot(); // Use existing root finding
	if (!rootDir) {
		console.warn(
			chalk.yellow('Warning: Could not find project root to check mcp.json.')
		);
		return false; // Cannot check without root
	}
	const mcpConfigPath = path.join(rootDir, '.cursor', 'mcp.json');

	if (!fs.existsSync(mcpConfigPath)) {
		// console.warn(chalk.yellow('Warning: .cursor/mcp.json not found.'));
		return false; // File doesn't exist
	}

	try {
		const mcpConfigRaw = fs.readFileSync(mcpConfigPath, 'utf-8');
		const mcpConfig = JSON.parse(mcpConfigRaw);

		const mcpEnv =
			mcpConfig?.mcpServers?.['task-master-ai']?.env ||
			mcpConfig?.mcpServers?.['taskmaster-ai']?.env;

View on GitHub (pinned to c0c98d367c)