list_tasks
Retrieve tasks from a Microsoft To Do list using filters, ordering, and pagination to manage and view task data.
Instructions
List the tasks of a To Do list. Supports OData filter, $orderby, $top, and pagination.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| list_id | Yes | ||
| filter | No | ||
| top | No | ||
| orderby | No | ||
| verbose | No | If true: returns full JSON. Otherwise: compact text format (default, saves tokens). | |
| paginate | No | If true: follows @odata.nextLink up to 20 pages (≈2000 items max). Default false. Use sparingly — large result sets may exhaust the LLM context window. |
Implementation Reference
- src/index.ts:977-990 (handler)The CallTool handler for 'list_tasks' — parses args via Zod schema, calls the graph helper listTasks(), and formats the output (compact text or JSON depending on verbose flag).
case "list_tasks": { const a = schemas.list_tasks.strict().parse(args); const tasks = await listTasks(a.list_id, { filter: a.filter, top: a.top, orderby: a.orderby, paginate: a.paginate, }); return out(tasks, a.verbose, (ts) => ts.length === 0 ? t.noTasks : `${t.tasks(ts.length)}\n${ts.map(formatTaskCompact).join("\n")}` ); } - src/index.ts:146-159 (schema)Zod input schema for 'list_tasks' — validates list_id (required string), optional filter (OData), top, orderby, verbose, and paginate fields.
list_tasks: z.object({ list_id: z.string().describe("ID of the To Do list"), filter: z .string() .optional() .describe("OData filter, e.g. \"status ne 'completed'\""), top: z.number().int().positive().max(100).optional(), orderby: z .string() .optional() .describe("OData $orderby, e.g. 'dueDateTime/dateTime asc'"), ...verboseField, ...paginateField, }), - src/index.ts:507-523 (registration)MCP tool registration in the ListTools handler — advertises the 'list_tasks' tool with its name, description, and JSON Schema inputSchema.
{ name: "list_tasks", description: "List the tasks of a To Do list. Supports OData filter, $orderby, $top, and pagination.", inputSchema: { type: "object", properties: { list_id: { type: "string" }, filter: { type: "string" }, top: { type: "number" }, orderby: { type: "string" }, ...verboseJsonProp, ...paginateJsonProp, }, required: ["list_id"], }, }, - src/graph.ts:389-409 (handler)The actual Graph API helper function 'listTasks' — builds OData query params and calls GET /me/todo/lists/{listId}/tasks on Microsoft Graph.
export async function listTasks( listId: string, opts: { filter?: string; top?: number; orderby?: string; paginate?: boolean; } = {} ): Promise<TodoTask[]> { // Note: Microsoft Graph rejects $select on /me/todo/lists/{id}/tasks for personal // accounts (RequestBroker--ParseUri 400). $filter / $top / $orderby work fine. const qs = buildOData({ filter: opts.filter, top: opts.top, orderby: opts.orderby, }); const path = `/me/todo/lists/${enc(listId)}/tasks${qs}`; if (opts.paginate) return paginateAll<TodoTask>(path); const data = await graphFetch<GraphCollection<TodoTask>>(path); return data.value; } - src/formatters.ts:37-56 (helper)Compact text formatter for a single task — used in the list_tasks handler to produce token-efficient output.
export function formatTaskCompact(t: TodoTask): string { const parts: string[] = [t.id]; if (t.importance === "high") parts.push("[!]"); else if (t.importance === "low") parts.push("[?]"); const sm = STATUS_MARKER[t.status]; if (sm) parts.push(sm); parts.push(JSON.stringify(t.title)); if (t.dueDateTime) parts.push(`due:${formatGraphDate(t.dueDateTime.dateTime)}`); if (t.isReminderOn && t.reminderDateTime) parts.push(`rem:${formatGraphDate(t.reminderDateTime.dateTime)}`); if (t.recurrence) parts.push(`rec:${t.recurrence.pattern.type}`); if (t.categories?.length) parts.push(`cat:${t.categories.join(",")}`); const bodyContent = t.body?.content?.trim(); if (bodyContent) { const truncated = bodyContent.length > 100 ? bodyContent.slice(0, 100) + "…" : bodyContent; parts.push(`body:${JSON.stringify(truncated.replace(/\s+/g, " "))}`); } return parts.join(" "); }