Skip to main content
Glama

get_next_task

Retrieve the next available task for an instance from the MCP Orchestrator Server, enabling task management and workflow coordination across multiple instances.

Instructions

Get the next available task

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instance_idYesID of the instance requesting work

Implementation Reference

  • Executes the get_next_task tool: finds the next pending task whose dependencies are all completed, marks it as in_progress, assigns it to the given instance_id, saves tasks, and returns the task JSON.
    case "get_next_task": { const { instance_id } = request.params.arguments as { instance_id: string }; debug(`Instance ${instance_id} requesting next task`); // Find a pending task with no incomplete dependencies const availableTask = Object.values(tasks).find(task => { if (task.status !== 'pending') return false; if (!task.dependencies) return true; return task.dependencies.every(depId => tasks[depId]?.status === 'completed'); }); if (!availableTask) { debug('No tasks available'); return { content: [{ type: "text", text: JSON.stringify({ status: 'no_tasks' }, null, 2) }] }; } availableTask.status = 'in_progress'; availableTask.assignedTo = instance_id; saveTasks(); debug(`Assigned task ${availableTask.id} to instance ${instance_id}`); return { content: [{ type: "text", text: JSON.stringify(availableTask, null, 2) }] }; }
  • src/index.ts:403-415 (registration)
    Registers the get_next_task tool in the listTools response, providing name, description, and inputSchema requiring instance_id.
    name: "get_next_task", description: "Get the next available task", inputSchema: { type: "object", properties: { instance_id: { type: "string", description: "ID of the instance requesting work" } }, required: ["instance_id"] } },
  • TypeScript interface defining the Task structure used by get_next_task and other task tools.
    interface Task { id: string; description: string; status: 'pending' | 'in_progress' | 'completed'; assignedTo?: string; result?: string; dependencies?: string[]; }

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/mokafari/orchestrator-server'

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