An AI-powered task-management system you can drop into Cursor, Lovable, Windsurf, Roo, and others.
JavaScript aicursorcursor-aicursorailovablelovable-devroocodetask-managertaskstasks-listwindsurfwindsurf-ai
fix: add rest of tools that need wrapper
Ralph Khreish8f8a3dc45d11
diff --git a/mcp-server/src/tools/initialize-project.js b/mcp-server/src/tools/initialize-project.jsindex 56126ad6..db005875 100644--- a/mcp-server/src/tools/initialize-project.js+++ b/mcp-server/src/tools/initialize-project.js@@ -1,5 +1,9 @@import { z } from 'zod';-import { createErrorResponse, handleApiResult } from './utils.js';+import {+ createErrorResponse,+ handleApiResult,+ withNormalizedProjectRoot+} from './utils.js';import { initializeProjectDirect } from '../core/task-master-core.js';export function registerInitializeProjectTool(server) {@@ -33,19 +37,10 @@ export function registerInitializeProjectTool(server) {'The root directory for the project. ALWAYS SET THIS TO THE PROJECT ROOT DIRECTORY. IF NOT SET, THE TOOL WILL NOT WORK.')}),- execute: async (args, context) => {+ execute: withNormalizedProjectRoot(async (args, context) => {const { log } = context;const session = context.session;- log.info(- '>>> Full Context Received by Tool:',- JSON.stringify(context, null, 2)- );- log.info(`Context received in tool function: ${context}`);- log.info(- `Session received in tool function: ${session ? session : 'undefined'}`- );-try {log.info(`Executing initialize_project tool with args: ${JSON.stringify(args)}`@@ -59,6 +54,6 @@ export function registerInitializeProjectTool(server) {log.error(errorMessage, error);return createErrorResponse(errorMessage, { details: error.stack });}- }+ })});}diff --git a/mcp-server/src/tools/parse-prd.js b/mcp-server/src/tools/parse-prd.jsindex 7cd36855..3fb95080 100644--- a/mcp-server/src/tools/parse-prd.js+++ b/mcp-server/src/tools/parse-prd.js@@ -5,7 +5,11 @@import { z } from 'zod';import path from 'path';-import { handleApiResult, createErrorResponse } from './utils.js';+import {+ handleApiResult,+ createErrorResponse,+ withNormalizedProjectRoot+} from './utils.js';import { parsePRDDirect } from '../core/task-master-core.js';/**@@ -49,7 +53,7 @@ export function registerParsePRDTool(server) {.string().describe('The directory of the project. Must be an absolute path.')}),- execute: async (args, { log, session }) => {+ execute: withNormalizedProjectRoot(async (args, { log, session }) => {const toolName = 'parse_prd';try {log.info(@@ -97,6 +101,6 @@ export function registerParsePRDTool(server) {`Internal tool error (${toolName}): ${error.message}`);}- }+ })});}diff --git a/mcp-server/src/tools/update-subtask.js b/mcp-server/src/tools/update-subtask.jsindex 6671c580..ad3831e4 100644--- a/mcp-server/src/tools/update-subtask.js+++ b/mcp-server/src/tools/update-subtask.js@@ -8,6 +8,7 @@ import { handleApiResult, createErrorResponse } from './utils.js';import { updateSubtaskByIdDirect } from '../core/task-master-core.js';import { findTasksJsonPath } from '../core/utils/path-utils.js';import path from 'path';+import { withNormalizedProjectRoot } from '../core/utils/project-utils.js';/*** Register the update-subtask tool with the MCP server@@ -34,7 +35,7 @@ export function registerUpdateSubtaskTool(server) {.string().describe('The directory of the project. Must be an absolute path.')}),- execute: async (args, { log, session }) => {+ execute: withNormalizedProjectRoot(async (args, { log, session }) => {const toolName = 'update_subtask';try {log.info(`Updating subtask with args: ${JSON.stringify(args)}`);@@ -95,6 +96,6 @@ export function registerUpdateSubtaskTool(server) {`Internal tool error (${toolName}): ${error.message}`);}- }+ })});}diff --git a/mcp-server/src/tools/update-task.js b/mcp-server/src/tools/update-task.jsindex d5eb96c9..a9d06b0e 100644--- a/mcp-server/src/tools/update-task.js+++ b/mcp-server/src/tools/update-task.js@@ -4,11 +4,10 @@*/import { z } from 'zod';-import path from 'path'; // Import pathimport {handleApiResult,createErrorResponse,- getProjectRootFromSession+ withNormalizedProjectRoot} from './utils.js';import { updateTaskByIdDirect } from '../core/task-master-core.js';import { findTasksJsonPath } from '../core/utils/path-utils.js';@@ -40,58 +39,44 @@ export function registerUpdateTaskTool(server) {.string().describe('The directory of the project. Must be an absolute path.')}),- execute: async (args, { log, session }) => {+ execute: withNormalizedProjectRoot(async (args, { log, session }) => {const toolName = 'update_task';try {log.info(`Executing ${toolName} tool with args: ${JSON.stringify(args)}`);- // 1. Get Project Root- const rootFolder = args.projectRoot;- if (!rootFolder || !path.isAbsolute(rootFolder)) {- log.error(- `${toolName}: projectRoot is required and must be absolute.`- );- return createErrorResponse(- 'projectRoot is required and must be absolute.'- );- }- log.info(`${toolName}: Project root: ${rootFolder}`);-- // 2. Resolve Tasks Pathlet tasksJsonPath;try {tasksJsonPath = findTasksJsonPath(- { projectRoot: rootFolder, file: args.file }, // Pass root and optional relative file+ { projectRoot: args.projectRoot, file: args.file },log);log.info(`${toolName}: Resolved tasks path: ${tasksJsonPath}`);} catch (error) {log.error(`${toolName}: Error finding tasks.json: ${error.message}`);return createErrorResponse(- `Failed to find tasks.json within project root '${rootFolder}': ${error.message}`+ `Failed to find tasks.json: ${error.message}`);}// 3. Call Direct Function - Include projectRootconst result = await updateTaskByIdDirect({- tasksJsonPath: tasksJsonPath, // Pass resolved path+ tasksJsonPath: tasksJsonPath,id: args.id,prompt: args.prompt,research: args.research,- projectRoot: rootFolder // <<< Pass projectRoot HERE+ projectRoot: args.projectRoot},log,- { session } // Pass context with session+ { session });// 4. Handle Resultlog.info(`${toolName}: Direct function result: success=${result.success}`);- // Pass the actual data from the result (contains updated task or message)return handleApiResult(result, log, 'Error updating task');} catch (error) {log.error(@@ -101,6 +86,6 @@ export function registerUpdateTaskTool(server) {`Internal tool error (${toolName}): ${error.message}`);}- }+ })});}