Skip to main content
Glama
MAG-Cie

MCP for Microsoft To Do

bulk_update_categories

Idempotent

Add or remove categories from multiple tasks in one batch operation, reading existing categories first then patching updates, with per-item error handling.

Instructions

Add/remove categories on several tasks in one operation. 2-phase batch: GET to read existing categories, then PATCH with the updated set. Per-item errors, no global fail.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
refsYes
addNo
removeNo
verboseNoIf true: returns full JSON. Otherwise: compact text format (default, saves tokens).

Implementation Reference

  • The core handler function `bulkUpdateCategories` that performs a 2-phase batch: GET existing categories on tasks, then PATCH with the updated set (add/remove). Returns per-item results with error handling.
    export async function bulkUpdateCategories(
      refs: Array<{ listId: string; taskId: string }>,
      changes: { add?: string[]; remove?: string[] }
    ): Promise<Array<BatchResultItem<TodoTask>>> {
      // Phase 1: GET (batch) to fetch current categories
      const getRequests: BatchRequest[] = refs.map((ref, idx) => ({
        id: String(idx),
        method: "GET",
        // No $select: rejected by Graph on this endpoint for personal accounts.
        url: `/me/todo/lists/${enc(ref.listId)}/tasks/${enc(ref.taskId)}`,
      }));
      const getResponses = await graphBatch(getRequests);
      const final: Array<BatchResultItem<TodoTask>> = new Array(refs.length);
    
      // Phase 2: build PATCH requests for successful GETs
      const patchRequests: BatchRequest[] = [];
      for (const r of getResponses) {
        const idx = Number(r.id);
        if (r.status < 200 || r.status >= 300) {
          final[idx] = {
            index: idx,
            status: r.status,
            ok: false,
            error: `GET failed: HTTP ${r.status}`,
          };
          continue;
        }
        const task = r.body as { categories?: string[] };
        const current = new Set(task.categories ?? []);
        for (const c of changes.add ?? []) current.add(c);
        for (const c of changes.remove ?? []) current.delete(c);
        patchRequests.push({
          id: String(idx),
          method: "PATCH",
          url: `/me/todo/lists/${enc(refs[idx].listId)}/tasks/${enc(refs[idx].taskId)}`,
          body: { categories: Array.from(current) },
        });
      }
    
      if (patchRequests.length > 0) {
        const patchResponses = await graphBatch(patchRequests);
        for (const r of patchResponses) {
          const idx = Number(r.id);
          const ok = r.status >= 200 && r.status < 300;
          let error: string | undefined;
          if (!ok) {
            const body = r.body as GraphErrorBody | string | undefined;
            if (typeof body === "object" && body && "error" in body && body.error) {
              error = body.error.code
                ? `${body.error.code}: ${body.error.message ?? "(no message)"}`
                : body.error.message ?? `HTTP ${r.status}`;
            } else if (typeof body === "string") {
              error = body;
            } else {
              error = `HTTP ${r.status}`;
            }
          }
          final[idx] = {
            index: idx,
            status: r.status,
            ok,
            result: ok ? (r.body as TodoTask) : undefined,
            error,
          };
        }
      }
      return final;
    }
  • src/index.ts:1201-1210 (registration)
    Tool call handler case: parses validated args, maps them to the graph.ts function, and formats results using `formatBatchCompact`.
    case "bulk_update_categories": {
      const a = schemas.bulk_update_categories.strict().parse(args);
      const results = await bulkUpdateCategories(
        a.refs.map((r) => ({ listId: r.list_id, taskId: r.task_id })),
        { add: a.add, remove: a.remove }
      );
      return out(results, a.verbose, (rs) =>
        formatBatchCompact(rs, formatTaskCompact)
      );
    }
  • Zod schema definition for `bulk_update_categories` input: refs array (list_id, task_id), optional add/remove string arrays, and verbose flag.
    bulk_update_categories: z.object({
      refs: z
        .array(z.object({ list_id: z.string(), task_id: z.string() }))
        .min(1)
        .max(100),
      add: z.array(z.string()).optional(),
      remove: z.array(z.string()).optional(),
      ...verboseField,
    }),
  • JSON input schema advertised via ListTools for `bulk_update_categories`, with description of the 2-phase batch operation.
    {
      name: "bulk_update_categories",
      description:
        "Add/remove categories on several tasks in one operation. 2-phase batch: GET to read existing categories, then PATCH with the updated set. Per-item errors, no global fail.",
      inputSchema: {
        type: "object",
        properties: {
          refs: {
            type: "array",
            maxItems: 100,
            items: {
              type: "object",
              properties: {
                list_id: { type: "string" },
                task_id: { type: "string" },
              },
              required: ["list_id", "task_id"],
            },
          },
          add: { type: "array", items: { type: "string" } },
          remove: { type: "array", items: { type: "string" } },
          ...verboseJsonProp,
        },
        required: ["refs"],
      },
  • Annotation entry marking `bulk_update_categories` as WRITE_UPDATE (idempotent, non-destructive, open-world) with display title.
      bulk_update_categories: { ...WRITE_UPDATE, title: "Bulk update task categories" },
      export_tasks_ics:       { ...READ,         title: "Export tasks as iCalendar (.ics)" },
    };
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description discloses the 2-phase batch process (GET then PATCH) and partial error handling ('Per-item errors, no global fail'), adding significant behavioral context beyond the annotations. Annotations only indicate idempotency and non-destructive nature.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences with no fluff. The first sentence states the purpose, and the second adds critical process and error details. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (batch, 2-phase, error handling, no output schema), the description covers the process and error behavior. It also mentions the verbose flag for output format. Missing minor details like idempotency implications or ordering, but overall sufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is only 25% (only 'verbose' has a description). The description mentions 'add' and 'remove' categories but does not clarify the structure of 'refs' (list_id, task_id) or how add/remove interact. The low coverage demands more detailed parameter explanation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (Add/remove categories) on multiple tasks ('several tasks in one operation'), which distinguishes it from siblings like 'update_task' (single task) or 'list_tasks_by_category' (read-only).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for bulk category updates but does not explicitly state when to use versus alternatives or when not to use. It provides context ('add/remove categories on several tasks') but lacks exclusion guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MAG-Cie/mcp-microsoft-todo'

If you have feedback or need assistance with the MCP directory API, please join our Discord server