search_tasks
Searches for a specified term in task titles across all Microsoft To Do lists. Returns matching tasks with options to include completed tasks and control result count.
Instructions
Search a term in the titles of tasks across ALL lists (case-sensitive). By default excludes completed tasks.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | 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:550-570 (handler)The core handler function `searchTasks` that executes the tool logic. It searches a term in titles of non-completed tasks across all lists, using $filter contains() on the Graph API.
export async function searchTasks( query: string, opts: { topPerList?: number; includeCompleted?: boolean } = {} ): Promise<SearchResult[]> { const lists = await listTaskLists(); const escaped = query.replace(/'/g, "''"); const filterParts = [`contains(title,'${escaped}')`]; if (!opts.includeCompleted) filterParts.push("status ne 'completed'"); const filter = filterParts.join(" and "); const perList = await fetchTasksAcrossLists(lists, { filter, top: opts.topPerList ?? 25, }); return perList.flatMap(({ list, tasks }) => tasks.map((task) => ({ list: { id: list.id, displayName: list.displayName }, task, })) ); } - src/index.ts:202-207 (schema)Zod schema for 'search_tasks' input validation. Defines: query (required string), top_per_list (positive int, max 100), include_completed (boolean), and verbose field.
search_tasks: z.object({ query: z.string().min(1), top_per_list: z.number().int().positive().max(100).optional(), include_completed: z.boolean().optional(), ...verboseField, }),