list_tasks_by_category
Lists all tasks containing a specified category across every list in Microsoft To Do, using an OData filter.
Instructions
List ALL tasks containing a given category, across every list. OData filter: categories/any(c: c eq '...').
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | Yes | ||
| top_per_list | No | ||
| include_completed | No | ||
| verbose | No | If true: returns full JSON. Otherwise: compact text format (default, saves tokens). |
Implementation Reference
- src/graph.ts:880-899 (handler)Actual implementation of listTasksByCategory. Fetches all task lists, builds an OData filter for the given category (and optionally excludes completed tasks), then fetches tasks across all lists via fetchTasksAcrossLists.
export async function listTasksByCategory( category: string, opts: { topPerList?: number; includeCompleted?: boolean } = {} ): Promise<SearchResult[]> { const lists = await listTaskLists(); const escaped = category.replace(/'/g, "''"); const filterParts = [`categories/any(c: c eq '${escaped}')`]; if (!opts.includeCompleted) filterParts.push("status ne 'completed'"); const filter = filterParts.join(" and "); const perList = await fetchTasksAcrossLists(lists, { filter, top: opts.topPerList ?? 50, }); return perList.flatMap(({ list, tasks }) => tasks.map((task) => ({ list: { id: list.id, displayName: list.displayName }, task, })) ); } - src/index.ts:326-331 (schema)Zod schema for list_tasks_by_category input validation: requires a 'category' string, with optional 'top_per_list' (positive int ≤100), 'include_completed' (boolean), and verbose fields.
list_tasks_by_category: z.object({ category: z.string().min(1), top_per_list: z.number().int().positive().max(100).optional(), include_completed: z.boolean().optional(), ...verboseField, }),