Skip to main content
Glama

get_next_task

Retrieve the next pending task from a request queue to continue workflow execution, displaying progress status and requiring approval before proceeding after task completion.

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 wait for the request completion approval.

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 but not yet approved, you MUST NOT proceed. In such a scenario, you must prompt the user for approval via 'approve_task_completion' 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, you must not start a new request or do anything else until the user decides to 'approve_request_completion' or possibly add more tasks via 'request_planning'.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
requestIdYes

Implementation Reference

  • The core handler function that implements the logic for getting the next pending task in a request, including status checks and progress table formatting.
    public async getNextTask(requestId: string) { const request = this.data.requests.find((r) => r.requestId === requestId); if (!request) { throw new Error("Request not found"); } const nextTask = request.tasks.find((t) => !t.done); const allTasksDone = request.tasks.every((t) => t.approved); await this.saveTasks(); if (allTasksDone) { return { message: "All tasks are done! Awaiting request completion approval.\n" + this.formatTaskProgressTable(requestId), taskId: null, allTasksDone: true, }; } if (!nextTask) { return { message: "All tasks are done but some need approval.\n" + this.formatTaskProgressTable(requestId), taskId: null, allTasksDone: false, }; } return { message: `Next task: ${nextTask.title}\n${nextTask.description}\n` + this.formatTaskProgressTable(requestId), taskId: nextTask.id, allTasksDone: false, }; }
  • Zod schema defining the input structure for the get_next_task tool (requires requestId string).
    const GetNextTaskSchema = z.object({ requestId: z.string(), });
  • index.ts:151-155 (registration)
    Registration of the get_next_task tool in the listTools() method, including name, description, and schema reference.
    name: "get_next_task", description: "Get the next pending task for a request.", inputSchema: GetNextTaskSchema, }, {
  • Dispatcher handler in callTool() that validates input using the schema and delegates to the getNextTask method.
    case "get_next_task": { const parsed = GetNextTaskSchema.safeParse(parameters); if (!parsed.success) { throw new Error(`Invalid parameters: ${parsed.error}`); } return this.getNextTask(parsed.data.requestId); }

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/Rudra-ravi/mcp-taskmanager'

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