Skip to content

An AI-powered task-management system you can drop into Cursor, Lovable, Windsurf, Roo, and others.

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

Ralph Khreishcaee040907f8
diff --git a/.changeset/fix-mcp-default-tasks-path.md b/.changeset/fix-mcp-default-tasks-path.md
new file mode 100644
index 00000000..a124e958
--- /dev/null
+++ b/.changeset/fix-mcp-default-tasks-path.md
@@ -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.
\ No newline at end of file
diff --git a/mcp-server/src/core/utils/path-utils.js b/mcp-server/src/core/utils/path-utils.js
index 9aa5ef6d..af47ba5f 100644
--- a/mcp-server/src/core/utils/path-utils.js
+++ b/mcp-server/src/core/utils/path-utils.js
@@ -69,11 +69,29 @@ export function resolveTasksPath(args, log = silentLogger) {
// Use core findTasksPath with explicit path and normalized projectRoot context
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
- 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;
}
/**