expand_task
Break down complex GitHub tasks into manageable subtasks with AI analysis, dependency detection, and implementation recommendations for better project management.
Instructions
Break down a complex task into smaller, manageable subtasks with AI-powered analysis, dependency detection, and implementation recommendations
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskTitle | Yes | ||
| taskDescription | Yes | ||
| currentComplexity | Yes | ||
| maxSubtasks | Yes | ||
| maxDepth | Yes | ||
| targetComplexity | Yes | ||
| includeEstimates | Yes | ||
| includeDependencies | Yes | ||
| includeAcceptanceCriteria | Yes | ||
| projectType | No | ||
| teamSkills | No |
Input Schema (JSON Schema)
{
"properties": {
"currentComplexity": {
"type": "number"
},
"includeAcceptanceCriteria": {
"type": "string"
},
"includeDependencies": {
"type": "string"
},
"includeEstimates": {
"type": "string"
},
"maxDepth": {
"type": "string"
},
"maxSubtasks": {
"type": "string"
},
"projectType": {
"type": "string"
},
"targetComplexity": {
"type": "string"
},
"taskDescription": {
"type": "string"
},
"taskTitle": {
"type": "string"
},
"teamSkills": {
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"taskTitle",
"taskDescription",
"currentComplexity",
"maxSubtasks",
"maxDepth",
"targetComplexity",
"includeEstimates",
"includeDependencies",
"includeAcceptanceCriteria"
],
"type": "object"
}
Implementation Reference
- Main handler function executeExpandTask that implements the core logic of the expand_task tool, including task breakdown, enhancement, dependency detection, metrics calculation, and response formatting.async function executeExpandTask(args: ExpandTaskArgs): Promise<MCPResponse> { const taskService = new TaskGenerationService(); try { // Create a mock parent task const parentTask = { id: 'parent-task', title: args.taskTitle, description: args.taskDescription, complexity: args.currentComplexity as TaskComplexity, estimatedHours: args.currentComplexity * 4, // Simple estimation priority: TaskPriority.MEDIUM, status: TaskStatus.PENDING, dependencies: [], acceptanceCriteria: [], tags: [], aiGenerated: false, subtasks: [], createdAt: new Date().toISOString(), updatedAt: new Date().toISOString() }; // Generate subtasks using AI const subtasks = await taskService.expandTaskIntoSubtasks({ task: parentTask, maxDepth: args.maxDepth, autoEstimate: args.includeEstimates }); // Enhance subtasks with additional details const enhancedSubtasks = enhanceSubtasks(subtasks, args); // Detect dependencies if requested const dependencies = args.includeDependencies ? detectSubtaskDependencies(enhancedSubtasks) : []; // Calculate metrics const metrics = calculateSubtaskMetrics(enhancedSubtasks, parentTask); // Generate recommendations const recommendations = generateSubtaskRecommendations(enhancedSubtasks, args, metrics); // Format response const summary = formatTaskExpansion( parentTask, enhancedSubtasks, dependencies, metrics, recommendations, args ); return ToolResultFormatter.formatSuccess('expand_task', { summary, parentTask, subtasks: enhancedSubtasks, dependencies, metrics, recommendations }); } catch (error) { process.stderr.write(`Error in expand_task tool: ${error}\n`); return ToolResultFormatter.formatSuccess('expand_task', { error: `Failed to expand task: ${error instanceof Error ? error.message : 'Unknown error'}`, success: false }); } }
- Zod schema definition for expand_task tool input validation, defining parameters like taskTitle, taskDescription, complexity scores, and various flags for subtask generation options.// Schema for expand_task tool const expandTaskSchema = z.object({ taskTitle: z.string().min(3).describe('Title of the task to expand'), taskDescription: z.string().min(10).describe('Detailed description of the task'), currentComplexity: z.number().min(1).max(10).describe('Current complexity score of the task'), maxSubtasks: z.number().min(2).max(15).default(8).describe('Maximum number of subtasks to create'), maxDepth: z.number().min(1).max(3).default(2).describe('Maximum depth of subtask breakdown'), targetComplexity: z.number().min(1).max(5).default(3).describe('Target complexity for each subtask'), includeEstimates: z.boolean().default(true).describe('Whether to include effort estimates for subtasks'), includeDependencies: z.boolean().default(true).describe('Whether to identify dependencies between subtasks'), includeAcceptanceCriteria: z.boolean().default(true).describe('Whether to generate acceptance criteria for subtasks'), projectType: z.string().optional().describe('Type of project (web-app, mobile-app, api, etc.)'), teamSkills: z.array(z.string()).optional().describe('Team skills to consider for subtask assignment') });
- src/infrastructure/tools/ToolRegistry.ts:132-200 (registration)ToolRegistry class registers the expand_task tool (imported from ToolSchemas) among AI task management tools in the registerBuiltInTools method, making it available for list_tools and execution.private registerBuiltInTools(): void { // Register roadmap and planning tools this.registerTool(createRoadmapTool); this.registerTool(planSprintTool); this.registerTool(getMilestoneMetricsTool); this.registerTool(getSprintMetricsTool); this.registerTool(getOverdueMilestonesTool); this.registerTool(getUpcomingMilestonesTool); // Register project tools this.registerTool(createProjectTool); this.registerTool(listProjectsTool); this.registerTool(getProjectTool); this.registerTool(updateProjectTool); this.registerTool(deleteProjectTool); // Register milestone tools this.registerTool(createMilestoneTool); this.registerTool(listMilestonesTool); this.registerTool(updateMilestoneTool); this.registerTool(deleteMilestoneTool); // Register issue tools this.registerTool(createIssueTool); this.registerTool(listIssuesTool); this.registerTool(getIssueTool); this.registerTool(updateIssueTool); // Register sprint tools this.registerTool(createSprintTool); this.registerTool(listSprintsTool); this.registerTool(getCurrentSprintTool); this.registerTool(updateSprintTool); this.registerTool(addIssuesToSprintTool); this.registerTool(removeIssuesFromSprintTool); // Register project field tools this.registerTool(createProjectFieldTool); this.registerTool(listProjectFieldsTool); this.registerTool(updateProjectFieldTool); // Register project view tools this.registerTool(createProjectViewTool); this.registerTool(listProjectViewsTool); this.registerTool(updateProjectViewTool); // Register project item tools this.registerTool(addProjectItemTool); this.registerTool(removeProjectItemTool); this.registerTool(listProjectItemsTool); // Register field value tools this.registerTool(setFieldValueTool); this.registerTool(getFieldValueTool); // Register label tools this.registerTool(createLabelTool); this.registerTool(listLabelsTool); // Register AI task management tools this.registerTool(addFeatureTool); this.registerTool(generatePRDTool); this.registerTool(parsePRDTool); this.registerTool(getNextTaskTool); this.registerTool(analyzeTaskComplexityTool); this.registerTool(expandTaskTool); this.registerTool(enhancePRDTool); this.registerTool(createTraceabilityMatrixTool); }
- src/index.ts:374-375 (registration)In the main MCP server, the executeToolHandler switch statement directly invokes executeExpandTask for the expand_task tool name.case "expand_task": return await executeExpandTask(args);
- Helper function enhanceSubtasks called by the handler to add acceptance criteria, tags, adjust complexity, and set priorities for generated subtasks.function enhanceSubtasks(subtasks: any[], args: ExpandTaskArgs) { return subtasks.map((subtask, index) => { // Generate acceptance criteria if requested const acceptanceCriteria = args.includeAcceptanceCriteria ? generateAcceptanceCriteria(subtask) : []; // Assign appropriate tags const tags = generateSubtaskTags(subtask, args.projectType); // Adjust complexity to target if needed const adjustedComplexity = Math.min(subtask.complexity, args.targetComplexity); return { ...subtask, id: `subtask-${index + 1}`, complexity: adjustedComplexity, estimatedHours: adjustedComplexity * 2, // Subtasks are smaller acceptanceCriteria, tags, priority: index < 2 ? 'high' : 'medium', // First few subtasks are high priority status: 'pending' }; }); }