Skip to main content
Glama

get_next_task

Retrieve the next pending task for a given requestId from the MCP TaskManager. View task progress and ensure user approval for completion before proceeding. Suitable for queue-based task management.

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

  • Core handler function that finds the next pending task for a request, handles completion states, and returns a formatted progress table.
    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, }; }
  • Entry point in the callTool switch statement that parses input parameters 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); }
  • Zod input schema defining the required 'requestId' string parameter for the tool.
    const GetNextTaskSchema = z.object({ requestId: z.string(), });
  • index.ts:150-154 (registration)
    Tool registration entry in the listTools method, specifying name, description, and input schema.
    { name: "get_next_task", description: "Get the next pending task for a request.", inputSchema: GetNextTaskSchema, },

Other Tools

Related Tools

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