diff --git a/mcp-server/src/core/direct-functions/show-task.js b/mcp-server/src/core/direct-functions/show-task.js index 9e1faed8..062ef428 100644 --- a/mcp-server/src/core/direct-functions/show-task.js +++ b/mcp-server/src/core/direct-functions/show-task.js @@ -3,7 +3,10 @@ * Direct function implementation for showing task details */ -import { findTaskById } from '../../../../scripts/modules/utils.js'; +import { + findTaskById, + readComplexityReport +} from '../../../../scripts/modules/utils.js'; import { readJSON } from '../../../../scripts/modules/utils.js'; import { getCachedOrExecute } from '../../tools/utils.js'; import { @@ -17,12 +20,13 @@ import { * @param {Object} args - Command arguments * @param {string} args.tasksJsonPath - Explicit path to the tasks.json file. * @param {string} args.id - The ID of the task or subtask to show. + * @param {string} args.reportPath - Explicit path to the complexity report file. * @param {Object} log - Logger object * @returns {Promise} - Task details result { success: boolean, data?: any, error?: { code: string, message: string }, fromCache: boolean } */ export async function showTaskDirect(args, log) { // Destructure expected args - const { tasksJsonPath, id } = args; + const { tasksJsonPath, reportPath, id } = args; if (!tasksJsonPath) { log.error('showTaskDirect called without tasksJsonPath'); @@ -51,7 +55,7 @@ export async function showTaskDirect(args, log) { } // Generate cache key using the provided task path and ID - const cacheKey = `showTask:${tasksJsonPath}:${taskId}`; + const cacheKey = `showTask:${tasksJsonPath}:${taskId}:${reportPath}`; // Define the action function to be executed on cache miss const coreShowTaskAction = async () => { @@ -76,8 +80,11 @@ export async function showTaskDirect(args, log) { }; } + // Read the complexity report + const complexityReport = readComplexityReport(reportPath); + // Find the specific task - const task = findTaskById(data.tasks, taskId); + const task = findTaskById(data.tasks, taskId, complexityReport); if (!task) { disableSilentMode(); // Disable before returning diff --git a/mcp-server/src/tools/get-task.js b/mcp-server/src/tools/get-task.js index 8e8b8a79..880cf18e 100644 --- a/mcp-server/src/tools/get-task.js +++ b/mcp-server/src/tools/get-task.js @@ -10,7 +10,10 @@ import { getProjectRootFromSession } from './utils.js'; import { showTaskDirect } from '../core/task-master-core.js'; -import { findTasksJsonPath } from '../core/utils/path-utils.js'; +import { + findTasksJsonPath, + findComplexityReportPath +} from '../core/utils/path-utils.js'; /** * Custom processor function that removes allTasks from the response @@ -41,6 +44,12 @@ export function registerShowTaskTool(server) { parameters: z.object({ id: z.string().describe('Task ID to get'), file: z.string().optional().describe('Absolute path to the tasks file'), + complexityReport: z + .string() + .optional() + .describe( + 'Path to the complexity report file (relative to project root or absolute)' + ), projectRoot: z .string() .describe('The directory of the project. Must be an absolute path.') @@ -89,10 +98,22 @@ export function registerShowTaskTool(server) { log.info(`Attempting to use tasks file path: ${tasksJsonPath}`); + // Resolve the path to complexity report + let complexityReportPath; + try { + complexityReportPath = findComplexityReportPath( + rootFolder, + args.complexityReport, + log + ); + } catch (error) { + log.error(`Error finding complexity report: ${error.message}`); + } const result = await showTaskDirect( { // Pass the explicitly resolved path tasksJsonPath: tasksJsonPath, + reportPath: complexityReportPath, // Pass other relevant args id: args.id }, diff --git a/mcp-server/src/tools/get-tasks.js b/mcp-server/src/tools/get-tasks.js index 9b63a211..445e20c1 100644 --- a/mcp-server/src/tools/get-tasks.js +++ b/mcp-server/src/tools/get-tasks.js @@ -91,9 +91,6 @@ export function registerListTasksTool(server) { ); } catch (error) { log.error(`Error finding complexity report: ${error.message}`); - return createErrorResponse( - `Failed to find complexity report: ${error.message}` - ); } const result = await listTasksDirect( {