getTask
Retrieve a specific task by its ID from the task orchestration server to view details or manage workflow.
Instructions
Get a task by its ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Task ID |
Implementation Reference
- src/tools.ts:117-159 (registration)Registration of the MCP 'getTask' tool using server.registerTool. Defines the tool name, description, input schema requiring a task ID string, and a handler function that calls the underlying getTask implementation, formats the response as JSON, and handles errors.// Register getTask tool server.registerTool( "getTask", { description: "Get a task by its ID", inputSchema: { id: z.string().describe("Task ID"), }, }, (args) => { try { const task = getTask(args.id) return { content: [ { text: JSON.stringify({ task }, null, 2), type: "text", }, ], } } catch (error) { return { content: [ { text: JSON.stringify( { error: { code: "TASK_NOT_FOUND", message: error instanceof Error ? error.message : "Unknown error", }, }, null, 2, ), type: "text", }, ], isError: true, } } }, )
- src/task.ts:555-568 (handler)Core handler function for retrieving a task by ID. Validates input, loads all tasks from storage, searches recursively using findTaskById, throws appropriate errors if invalid ID or not found, returns the Task object.export function getTask(id: string): Task { if (!id || typeof id !== "string") { throw new Error(ERROR_MESSAGES.INVALID_TASK_ID) } const tasks = readTasks() const task = findTaskById(tasks, id) if (!task) { throw new Error(ERROR_MESSAGES.TASK_NOT_FOUND(id)) } return task }
- src/tools.ts:120-125 (schema)Input schema definition for the getTask tool using Zod: requires 'id' as a string with description.{ description: "Get a task by its ID", inputSchema: { id: z.string().describe("Task ID"), }, },
- src/task.ts:33-44 (helper)Recursive helper function to find a task by ID in the nested task hierarchy.export function findTaskById(tasks: Task[], id: string): Task | undefined { for (const task of tasks) { if (task.id === id) { return task } const found = findTaskById(task.tasks, id) if (found) { return found } } return undefined }