Skip to main content
Glama

get_next_task

Fetch the next pending task for a request via TaskFlow MCP, display progress, and handle task completion with user approval. Ensures task flow integrity by requiring confirmation before proceeding.

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 'approve_task_completion' is called by the user.

  • 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 'plan_task'.

Input Schema

NameRequiredDescriptionDefault
requestIdYes

Input Schema (JSON Schema)

{ "properties": { "requestId": { "type": "string" } }, "required": [ "requestId" ], "type": "object" }

Implementation Reference

  • The MCP tool handler function for 'get_next_task'. Extracts the requestId from arguments and delegates to TaskFlowService.getNextTask().
    async get_next_task(args: any) { return service.getNextTask(String(args.requestId)); },
  • Core implementation logic in TaskFlowService that loads tasks, finds the next undone task for the given requestId, applies prompts, generates progress table, and returns task details or completion status.
    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}`, }; }
  • JSON Schema definition for validating input to the 'get_next_task' tool (requires 'requestId').
    get_next_task: { type: "object", properties: { requestId: { type: "string" } }, required: ["requestId"], },
  • Tool object definition exported as GET_NEXT_TASK_TOOL, including name, detailed description, and input schema. Used for MCP tool registration.
    export const GET_NEXT_TASK_TOOL: Tool = { name: "get_next_task", description: "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.\n\n" + "A progress table showing the current status of all tasks will be displayed with each response.\n\n" + "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.\n" + "In other words:\n" + "- After calling 'mark_task_done', do not call 'get_next_task' again until the user has given approval for the completed task.\n" + "- 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'.", inputSchema: { type: "object", properties: { requestId: { type: "string" }, }, required: ["requestId"], }, };
  • Server registration of the 'get_next_task' tool in the ListToolsRequestSchema handler's tools array.
    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, ], }));

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pinkpixel-dev/taskflow-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server