get_next_task
Retrieve the next pending task from TaskFlow MCP to manage workflow progression, displaying progress and requiring user approval between task completions.
Instructions
Given a 'requestId', return the next pending task (not done yet). If all tasks are completed, it will indicate that no more tasks are left and that you must ask the user what to do next.
A progress table showing the current status of all tasks will be displayed with each response.
If the same task is returned again or if no new task is provided after a task was marked as done, you MUST NOT proceed. In such a scenario, you must prompt the user for approval before calling 'get_next_task' again. Do not skip the user's approval step. In other words:
After calling 'mark_task_done', do not call 'get_next_task' again until the user has given approval for the completed task.
If 'get_next_task' returns 'all_tasks_done', it means all tasks have been completed. At this point, confirm with the user that all tasks have been completed, and optionally add more tasks via 'add_tasks_to_request' or 'plan_task'.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| requestId | Yes |
Implementation Reference
- src/tools/TaskFlowTools.ts:568-570 (handler)The MCP tool handler function for 'get_next_task', which delegates to the TaskFlowService's getNextTask method.async get_next_task(args: any) { return service.getNextTask(String(args.requestId)); },
- src/server/TaskFlowServer.ts:64-89 (registration)Registration of the 'get_next_task' tool (as GET_NEXT_TASK_TOOL) in the MCP server's ListTools response.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, ],
- src/tools/TaskFlowTools.ts:106-113 (schema)Input schema definition for the 'get_next_task' tool.inputSchema: { type: "object", properties: { requestId: { type: "string" }, }, required: ["requestId"], }, };
- Core service method implementing the logic to retrieve the next pending task, generate progress table, and apply prompts.public async getNextTask(requestId: string) { await this.loadTasks(); const req = this.getRequest(requestId); if (!req) return { status: "error", message: "Request not found" }; if (req.completed) { return { status: "already_completed", message: "Request already completed." }; } const nextTask = req.tasks.find((t) => !t.done); if (!nextTask) { const allDone = req.tasks.every((t) => t.done); if (allDone && !req.completed) { const progressTable = formatTaskProgressTableForRequest(req); return { status: "all_tasks_done", message: `All tasks have been completed. Awaiting completion approval.\n${progressTable}`, }; } return { status: "no_next_task", message: "No undone tasks found." }; } const progressTable = formatTaskProgressTableForRequest(req); const enhancedDescription = this.applyPromptsToTaskDescription(nextTask.description, this.data.prompts); return { status: "next_task", task: { id: nextTask.id, title: nextTask.title, description: enhancedDescription, ...(this.data.prompts?.instructions && { instructions: this.data.prompts.instructions }) }, message: `Next task is ready. Task approval will be required after completion.\n${progressTable}`, }; }
- Zod/JSON schema definition for 'get_next_task' input validation (referenced but inline used in tool).get_next_task: { type: "object", properties: { requestId: { type: "string" } }, required: ["requestId"], },