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
| Name | Required | Description | Default |
|---|---|---|---|
| instance_id | Yes | ID of the instance requesting work |
Implementation Reference
- src/index.ts:220-253 (handler)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"] } },
- src/index.ts:21-28 (schema)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[]; }