listTasks
Retrieve hierarchical task structures by listing root tasks or filtering by parentId to display direct child tasks for organized task orchestration.
Instructions
List tasks from hierarchical structure, optionally filtered by parentId. Returns root tasks if no parentId specified, or direct children of specified parent task.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| parentId | No | Filter tasks by parent ID to get direct children (optional, returns root tasks if not specified) |
Implementation Reference
- src/task.ts:575-591 (handler)Core implementation of listTasks: reads tasks from storage and returns root tasks or direct children of the specified parentId.export function listTasks(params?: { parentId?: string }): Task[] { const tasks = readTasks() if (!params?.parentId) { // Return root level tasks return tasks } // Find the parent task and return its direct children const parentTask = findTaskById(tasks, params.parentId) if (!parentTask) { // Return empty array for non-existent parent (graceful handling) return [] } return parentTask.tasks }
- src/tools.ts:167-174 (schema)Zod input schema for the listTasks tool defining optional parentId parameter.inputSchema: { parentId: z .string() .describe( "Filter tasks by parent ID to get direct children (optional, returns root tasks if not specified)", ) .optional(), },
- src/tools.ts:162-209 (registration)Registers the listTasks tool with the MCP server, including description, input schema, and error-handling wrapper that calls the core listTasks function.server.registerTool( "listTasks", { description: "List tasks from hierarchical structure, optionally filtered by parentId. Returns root tasks if no parentId specified, or direct children of specified parent task.", inputSchema: { parentId: z .string() .describe( "Filter tasks by parent ID to get direct children (optional, returns root tasks if not specified)", ) .optional(), }, }, (args) => { try { const tasks = listTasks(args) return { content: [ { text: JSON.stringify({ tasks }, null, 2), type: "text", }, ], } } catch (error) { return { content: [ { text: JSON.stringify( { error: { code: "TASK_LIST_ERROR", message: error instanceof Error ? error.message : "Unknown error", }, }, null, 2, ), type: "text", }, ], isError: true, } } }, )