list-tasks
View all tasks from Todo.txt files with optional filters for priority, context, project, or metadata to organize and manage your task list.
Instructions
List all tasks, optionally filtered by priority, context, project, or metadata.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No |
Implementation Reference
- src/tools.ts:120-147 (handler)Executes the list-tasks tool: loads tasks, applies optional filters (priority, context, project, extensions), and formats the results as a text block.async ({ filter }) => { const tasks = await loadTasks(); let filteredTasks = tasks; if (filter) { if (filter.priority) { filteredTasks = filteredTasks.filter(task => task.priority() === filter.priority); } if (filter.context) { filteredTasks = filteredTasks.filter(task => filter.context && task.contexts().includes(filter.context)); } if (filter.project) { filteredTasks = filteredTasks.filter(task => filter.project && task.projects().includes(filter.project)); } if (filter.extensions) { filteredTasks = filteredTasks.filter(task => { const extensions = task.extensions(); return Object.entries(filter.extensions || {}).every(([key, value]) => extensions.some(ext => ext.key === key && ext.value === value) ); }); } } return { content: [ { type: "text", text: filteredTasks.map(task => task.toString()).join("\n") }, ], }; }
- src/tools.ts:112-119 (schema)Zod input schema defining optional filter object for priority, context, project, and extensions.{ filter: z.object({ priority: z.string().optional(), context: z.string().optional(), project: z.string().optional(), extensions: z.record(z.string(), z.string()).optional(), }).optional(), },
- src/tools.ts:109-148 (registration)Registers the 'list-tasks' tool on the MCP server with name, description, input schema, and handler function.server.tool( "list-tasks", "List all tasks, optionally filtered by priority, context, project, or metadata.", { filter: z.object({ priority: z.string().optional(), context: z.string().optional(), project: z.string().optional(), extensions: z.record(z.string(), z.string()).optional(), }).optional(), }, async ({ filter }) => { const tasks = await loadTasks(); let filteredTasks = tasks; if (filter) { if (filter.priority) { filteredTasks = filteredTasks.filter(task => task.priority() === filter.priority); } if (filter.context) { filteredTasks = filteredTasks.filter(task => filter.context && task.contexts().includes(filter.context)); } if (filter.project) { filteredTasks = filteredTasks.filter(task => filter.project && task.projects().includes(filter.project)); } if (filter.extensions) { filteredTasks = filteredTasks.filter(task => { const extensions = task.extensions(); return Object.entries(filter.extensions || {}).every(([key, value]) => extensions.some(ext => ext.key === key && ext.value === value) ); }); } } return { content: [ { type: "text", text: filteredTasks.map(task => task.toString()).join("\n") }, ], }; } );
- index.ts:32-35 (helper)Helper function to load tasks from the todo.txt file, used by the list-tasks handler.async function loadTasks() { const content = await fs.readFile(TODO_FILE_PATH, "utf-8"); return content.split("\n").filter(Boolean).map((line) => new Item(line)); }