refactor(mcp): Enforce projectRoot and centralize path validation

This commit refactors how project paths are handled in MCP direct functions to improve reliability, particularly when session context is incomplete or missing.

Key changes: 1) Made projectRoot required in MCP tools. 2) Refactored findTasksJsonPath to return {tasksPath, validatedProjectRoot}. 3) Updated all direct functions to pass session to findTasksJsonPath. 4) Updated analyzeTaskComplexityDirect to use the validated root for output path resolution.

This ensures operations relying on project context receive an explicitly provided and validated project root directory, resolving errors caused by incorrect path resolution.
This commit is contained in:
Eyal Toledano
2025-04-11 03:44:27 -04:00
parent 140bd3d265
commit 465ae252f0
26 changed files with 348 additions and 289 deletions

View File

@@ -909,7 +909,7 @@ function setupMCPConfiguration(targetDir, projectName) {
const newMCPServer = {
'task-master-ai': {
command: 'npx',
args: ['-y', '--package', 'task-master-ai', 'task-master-mcp'],
args: ['-y', 'task-master-mcp'],
env: {
ANTHROPIC_API_KEY: '%ANTHROPIC_API_KEY%',
PERPLEXITY_API_KEY: '%PERPLEXITY_API_KEY%',