fix(mcp-server): construct default tasks.json path when file parameter not provided (#1276)

Co-authored-by: Ralph Khreish <Crunchyman-ralph@users.noreply.github.com>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Fixes #1272
This commit is contained in:
Ralph Khreish
2025-10-06 11:50:45 +02:00
committed by GitHub
parent 4b5473860b
commit caee040907
2 changed files with 25 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"task-master-ai": patch
---
Fix MCP server error when file parameter not provided - now properly constructs default tasks.json path instead of failing with 'tasksJsonPath is required' error.

View File

@@ -69,11 +69,29 @@ export function resolveTasksPath(args, log = silentLogger) {
// Use core findTasksPath with explicit path and normalized projectRoot context // Use core findTasksPath with explicit path and normalized projectRoot context
if (projectRoot) { if (projectRoot) {
return coreFindTasksPath(explicitPath, { projectRoot }, log); const foundPath = coreFindTasksPath(explicitPath, { projectRoot }, log);
// If core function returns null and no explicit path was provided,
// construct the expected default path as documented
if (foundPath === null && !explicitPath) {
const defaultPath = path.join(
projectRoot,
'.taskmaster',
'tasks',
'tasks.json'
);
log?.info?.(
`Core findTasksPath returned null, using default path: ${defaultPath}`
);
return defaultPath;
}
return foundPath;
} }
// Fallback to core function without projectRoot context // Fallback to core function without projectRoot context
return coreFindTasksPath(explicitPath, null, log); const foundPath = coreFindTasksPath(explicitPath, null, log);
// Note: When no projectRoot is available, we can't construct a default path
// so we return null and let the calling code handle the error
return foundPath;
} }
/** /**