add_subtasks
Break down complex tasks into manageable subtasks within TaskFlow MCP to track progress and ensure all components are completed before marking tasks as done.
Instructions
Add subtasks to an existing task. Provide 'requestId', 'taskId', and 'subtasks' array.
Subtasks are smaller units of work that make up a task. All subtasks must be completed before a task can be marked as done.
A progress table will be displayed showing the updated task with its subtasks.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| requestId | Yes | ||
| taskId | Yes | ||
| subtasks | Yes |
Implementation Reference
- src/tools/TaskFlowTools.ts:600-602 (handler)MCP tool handler function for 'add_subtasks' that parses arguments and delegates execution to TaskFlowService.addSubtasks method.async add_subtasks(args: any) { const { requestId, taskId, subtasks } = args ?? {}; return service.addSubtasks(String(requestId), String(taskId), subtasks ?? []);
- Core service method implementing the logic to add subtasks to a specific task in a request: validates, generates IDs with TaskFactory, persists to file, generates progress table.public async addSubtasks( requestId: string, taskId: string, subtasks: { title: string; description: string }[] ) { await this.loadTasks(); const req = this.getRequest(requestId); if (!req) return { status: "error", message: "Request not found" }; const task = req.tasks.find((t) => t.id === taskId); if (!task) return { status: "error", message: "Task not found" }; if (task.done) return { status: "error", message: "Cannot add subtasks to completed task" }; const factory = new TaskFactory({ value: this.globalIdCounter }); const newSubtasks = subtasks.map((s) => factory.createSubtask(s)); this.globalIdCounter = factory["counterRef"].value; task.subtasks.push(...newSubtasks); await this.saveTasks(); const progressTable = formatTaskProgressTableForRequest(req); return { status: "subtasks_added", message: `Added ${newSubtasks.length} new subtasks to task ${taskId}.\n${progressTable}`, newSubtasks: newSubtasks.map((s) => ({ id: s.id, title: s.title, description: s.description })), }; }
- src/tools/TaskFlowTools.ts:236-261 (schema)Tool definition including name, description, and input JSON schema for validation in MCP.export const ADD_SUBTASKS_TOOL: Tool = { name: "add_subtasks", description: "Add subtasks to an existing task. Provide 'requestId', 'taskId', and 'subtasks' array.\n\n" + "Subtasks are smaller units of work that make up a task. All subtasks must be completed before a task can be marked as done.\n\n" + "A progress table will be displayed showing the updated task with its subtasks.", inputSchema: { type: "object", properties: { requestId: { type: "string" }, taskId: { type: "string" }, subtasks: { type: "array", items: { type: "object", properties: { title: { type: "string" }, description: { type: "string" }, }, required: ["title", "description"], }, }, }, required: ["requestId", "taskId", "subtasks"], }, };
- src/server/TaskFlowServer.ts:63-91 (registration)Server registration of all tools including ADD_SUBTASKS_TOOL in the listTools handler, making it discoverable via MCP.this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ PLAN_TASK_TOOL, GET_NEXT_TASK_TOOL, MARK_TASK_DONE_TOOL, OPEN_TASK_DETAILS_TOOL, LIST_REQUESTS_TOOL, ADD_TASKS_TO_REQUEST_TOOL, UPDATE_TASK_TOOL, DELETE_TASK_TOOL, ADD_SUBTASKS_TOOL, MARK_SUBTASK_DONE_TOOL, UPDATE_SUBTASK_TOOL, DELETE_SUBTASK_TOOL, EXPORT_TASK_STATUS_TOOL, ADD_NOTE_TOOL, UPDATE_NOTE_TOOL, DELETE_NOTE_TOOL, ADD_DEPENDENCY_TOOL, GET_PROMPTS_TOOL, SET_PROMPTS_TOOL, UPDATE_PROMPTS_TOOL, REMOVE_PROMPTS_TOOL, ARCHIVE_COMPLETED_REQUESTS_TOOL, LIST_ARCHIVED_REQUESTS_TOOL, RESTORE_ARCHIVED_REQUEST_TOOL, ], }));
- Additional JSON schema definition for add_subtasks input validation (jsonSchemas.add_subtasks).add_subtasks: { type: "object", properties: { requestId: { type: "string" }, taskId: { type: "string" }, subtasks: { type: "array", items: subtaskJson }, }, required: ["requestId", "taskId", "subtasks"], },