Skip to main content
Glama

batch_remove_items

Remove multiple tasks or projects from OmniFocus in one operation using this tool. Streamline task management by efficiently clearing unwanted items in bulk.

Instructions

Remove multiple tasks or projects from OmniFocus in a single operation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
itemsYesArray of items (tasks or projects) to remove

Implementation Reference

  • MCP tool handler that validates input params, calls the batchRemoveItems primitive function, processes results, and returns formatted text response with success/failure details.
    export async function handler(args: z.infer<typeof schema>, extra: RequestHandlerExtra) {
      try {
        // Validate that each item has at least an ID or name
        for (const item of args.items) {
          if (!item.id && !item.name) {
            return {
              content: [{
                type: "text" as const,
                text: "Each item must have either id or name provided to remove it."
              }],
              isError: true
            };
          }
        }
        
        // Call the batchRemoveItems function
        const result = await batchRemoveItems(args.items as BatchRemoveItemsParams[]);
        
        if (result.success) {
          const successCount = result.results.filter(r => r.success).length;
          const failureCount = result.results.filter(r => !r.success).length;
          
          let message = `✅ Successfully removed ${successCount} items.`;
          
          if (failureCount > 0) {
            message += ` ⚠️ Failed to remove ${failureCount} items.`;
          }
          
          // Include details about removed items
          const details = result.results.map((item, index) => {
            if (item.success) {
              const itemType = args.items[index].itemType;
              return `- ✅ ${itemType}: "${item.name}"`;
            } else {
              const itemType = args.items[index].itemType;
              const identifier = args.items[index].id || args.items[index].name;
              return `- ❌ ${itemType}: ${identifier} - Error: ${item.error}`;
            }
          }).join('\n');
          
          return {
            content: [{
              type: "text" as const,
              text: `${message}\n\n${details}`
            }]
          };
        } else {
          // Batch operation failed completely
          return {
            content: [{
              type: "text" as const,
              text: `Failed to process batch removal: ${result.error}`
            }],
            isError: true
          };
        }
      } catch (err: unknown) {
        const error = err as Error;
        console.error(`Tool execution error: ${error.message}`);
        return {
          content: [{
            type: "text" as const,
            text: `Error processing batch removal: ${error.message}`
          }],
          isError: true
        };
      }
    } 
  • Zod schema defining the input structure: array of items each with optional id/name and required itemType (task/project).
    export const schema = z.object({
      items: z.array(z.object({
        id: z.string().optional().describe("The ID of the task or project to remove"),
        name: z.string().optional().describe("The name of the task or project to remove (as fallback if ID not provided)"),
        itemType: z.enum(['task', 'project']).describe("Type of item to remove ('task' or 'project')")
      })).describe("Array of items (tasks or projects) to remove")
    });
  • src/server.ts:67-72 (registration)
    Registers the batch_remove_items tool on the MCP server, providing name, description, schema, and handler from the definitions module.
    server.tool(
      "batch_remove_items",
      "Remove multiple tasks or projects from OmniFocus in a single operation",
      batchRemoveItemsTool.schema.shape,
      batchRemoveItemsTool.handler
    );
  • Core batch removal logic: iterates over items, calls removeItem for each, collects individual results into BatchResult, handles per-item and overall errors.
    export async function batchRemoveItems(items: BatchRemoveItemsParams[]): Promise<BatchResult> {
      try {
        // Results array to track individual operation outcomes
        const results: ItemResult[] = [];
        
        // Process each item in sequence
        for (const item of items) {
          try {
            // Remove item
            const itemResult = await removeItem(item);
            results.push({
              success: itemResult.success,
              id: itemResult.id,
              name: itemResult.name,
              error: itemResult.error
            });
          } catch (itemError: any) {
            // Handle individual item errors
            results.push({
              success: false,
              error: itemError.message || "Unknown error processing item"
            });
          }
        }
        
        // Determine overall success (true if at least one item was removed successfully)
        const overallSuccess = results.some(result => result.success);
        
        return {
          success: overallSuccess,
          results: results
        };
      } catch (error: any) {
        console.error("Error in batchRemoveItems:", error);
        return {
          success: false,
          results: [],
          error: error.message || "Unknown error in batchRemoveItems"
        };
      }
    } 
Behavior2/5

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

With no annotations provided, the description carries full burden but only states it's a removal operation. It doesn't disclose critical behavioral traits like whether removal is permanent/reversible, permissions required, rate limits, error behavior for partial failures, or what happens to dependent items. The description is minimal and lacks necessary context for a destructive operation.

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?

The description is a single, efficient sentence that directly states the tool's purpose with zero wasted words. It's appropriately sized and front-loaded, making it easy to understand immediately.

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

Completeness2/5

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

For a destructive batch operation with no annotations and no output schema, the description is inadequate. It doesn't explain what 'remove' means (delete, archive, etc.), return values, error handling, or important constraints. Given the complexity and lack of structured data, more completeness is needed.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema fully documents the 'items' parameter and its nested properties. The description adds no additional parameter semantics beyond implying batch removal, which is already clear from the name and schema. Baseline 3 is appropriate when schema does all the work.

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

Purpose4/5

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

The description clearly states the verb ('remove') and resource ('multiple tasks or projects from OmniFocus'), specifying it's a batch operation. It distinguishes from the sibling 'remove_item' by emphasizing 'multiple... in a single operation', but doesn't explicitly name that sibling for full differentiation.

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 when removing multiple items at once versus single items, but doesn't explicitly state when to use this tool versus 'remove_item' or other alternatives. No guidance on prerequisites, error handling, or specific scenarios is provided.

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

Related 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/themotionmachine/OmniFocus-MCP'

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