getTask
Retrieve task details using a specific task ID for efficient task management and orchestration within the task-orchestrator-mcp server.
Instructions
Get a task by its ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Task ID |
Implementation Reference
- src/task.ts:555-568 (handler)Core handler function that retrieves a task by its ID. Loads all tasks from storage, uses findTaskById helper to locate the task recursively in the hierarchy, and returns it or throws appropriate errors.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:117-159 (registration)Registration of the 'getTask' MCP tool using server.registerTool, including schema, description, and thin wrapper handler that calls the core getTask function.// 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/tools.ts:122-124 (schema)Zod input schema for the getTask tool, requiring a single 'id' string parameter.inputSchema: { id: z.string().describe("Task ID"), },
- src/task.ts:33-44 (helper)Recursive helper function used by getTask to search for 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 }