batch_create_tasks
Create up to 100 tasks in a single batch call to Microsoft Graph, auto-chunked for reliability. Reduces API calls compared to individual task creation.
Instructions
Create several tasks in a single HTTP call via Microsoft Graph $batch (up to 100 items, auto-chunked by 20). Returns: status + result OR error per item, in order. More efficient than N create_task calls.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| items | Yes | ||
| verbose | No | If true: returns full JSON. Otherwise: compact text format (default, saves tokens). |
Implementation Reference
- src/graph.ts:759-774 (handler)Core handler function that builds batch POST requests for creating tasks via Microsoft Graph $batch API. Maps each item to a request with URL `/me/todo/lists/{listId}/tasks`, calls graphBatch, and parses responses.
export async function batchCreateTasks( items: Array<{ listId: string; task: CreateTaskInput }> ): Promise<Array<BatchResultItem<TodoTask>>> { const requests: BatchRequest[] = items.map((item, idx) => { const payload = buildTaskPayload(item.task); if (!payload.importance) payload.importance = "normal"; return { id: String(idx), method: "POST", url: `/me/todo/lists/${enc(item.listId)}/tasks`, body: payload, }; }); const responses = await graphBatch(requests); return parseBatchResponses<TodoTask>(responses, items.length); } - src/index.ts:264-275 (schema)Zod schema for batch_create_tasks defining input validation: items array (min 1, max 100) with list_id, title, and optional taskBaseFields.
batch_create_tasks: z.object({ items: z .array( z.object({ list_id: z.string(), title: z.string(), ...taskBaseFields, }) ) .min(1) .max(100), ...verboseField, - src/index.ts:762-785 (registration)MCP tool registration block listing the name 'batch_create_tasks', description, and JSON Schema input definition (items array with list_id, title, and taskBaseJsonProps).
{ name: "batch_create_tasks", description: "Create several tasks in a single HTTP call via Microsoft Graph $batch (up to 100 items, auto-chunked by 20). Returns: status + result OR error per item, in order. More efficient than N create_task calls.", inputSchema: { type: "object", properties: { items: { type: "array", maxItems: 100, items: { type: "object", properties: { list_id: { type: "string" }, title: { type: "string" }, ...taskBaseJsonProps, }, required: ["list_id", "title"], }, }, ...verboseJsonProp, }, required: ["items"], }, - src/index.ts:481-481 (registration)Tool metadata entry setting the title to 'Batch create tasks' with WRITE_CREATE category flags.
batch_create_tasks: { ...WRITE_CREATE, title: "Batch create tasks" }, - src/index.ts:1126-1147 (helper)Switch-case handler that parses args with the schema, transforms snake_case input to camelCase, calls batchCreateTasks from graph.ts, and formats the output.
case "batch_create_tasks": { const a = schemas.batch_create_tasks.strict().parse(args); const items: Array<{ listId: string; task: CreateTaskInput }> = a.items.map( (it) => ({ listId: it.list_id, task: { title: it.title, body: it.body, importance: it.importance, dueDateTime: it.due_date, timeZone: it.time_zone, categories: it.categories, recurrence: it.recurrence as PatternedRecurrence | undefined, isReminderOn: it.is_reminder_on, reminderDateTime: it.reminder_date_time, reminderTimeZone: it.reminder_time_zone, }, }) ); const results = await batchCreateTasks(items); return out(results, a.verbose, (rs) => formatBatchCompact(rs, formatTaskCompact)); }