Skip to main content
Glama

edit_item

Modify tasks or projects in OmniFocus by updating names, notes, due dates, tags, status, and more. Supports editing via ID or name for flexibility.

Instructions

Edit a task or project in OmniFocus

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addTagsNoTags to add to the task
idNoThe ID of the task or project to edit
itemTypeYesType of item to edit ('task' or 'project')
nameNoThe name of the task or project to edit (as fallback if ID not provided)
newDeferDateNoNew defer date in ISO format (YYYY-MM-DD or full ISO date); set to empty string to clear
newDueDateNoNew due date in ISO format (YYYY-MM-DD or full ISO date); set to empty string to clear
newEstimatedMinutesNoNew estimated minutes
newFlaggedNoSet flagged status (set to false for no flag, true for flag)
newFolderNameNoNew folder to move the project to
newNameNoNew name for the item
newNoteNoNew note for the item
newProjectStatusNoNew status for projects
newSequentialNoWhether the project should be sequential
newStatusNoNew status for tasks (incomplete, completed, dropped)
removeTagsNoTags to remove from the task
replaceTagsNoTags to replace all existing tags with

Implementation Reference

  • MCP tool handler function that validates input, calls the primitive editItem function, handles success/error responses.
    export async function handler(args: z.infer<typeof schema>, extra: RequestHandlerExtra) {
      try {
        // Validate that either id or name is provided
        if (!args.id && !args.name) {
          return {
            content: [{
              type: "text" as const,
              text: "Either id or name must be provided to edit an item."
            }],
            isError: true
          };
        }
        
        // Call the editItem function 
        const result = await editItem(args as EditItemParams);
        
        if (result.success) {
          // Item was edited successfully
          const itemTypeLabel = args.itemType === 'task' ? 'Task' : 'Project';
          let changedText = '';
          
          if (result.changedProperties) {
            changedText = ` (${result.changedProperties})`;
          }
          
          return {
            content: [{
              type: "text" as const,
              text: `✅ ${itemTypeLabel} "${result.name}" updated successfully${changedText}.`
            }]
          };
        } else {
          // Item editing failed
          let errorMsg = `Failed to update ${args.itemType}`;
          
          if (result.error) {
            if (result.error.includes("Item not found")) {
              errorMsg = `${args.itemType.charAt(0).toUpperCase() + args.itemType.slice(1)} not found`;
              if (args.id) errorMsg += ` with ID "${args.id}"`;
              if (args.name) errorMsg += `${args.id ? ' or' : ' with'} name "${args.name}"`;
              errorMsg += '.';
            } else {
              errorMsg += `: ${result.error}`;
            }
          }
          
          return {
            content: [{
              type: "text" as const,
              text: errorMsg
            }],
            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 updating ${args.itemType}: ${error.message}`
          }],
          isError: true
        };
      }
    } 
  • Zod schema defining the input parameters and structure for the edit_item tool.
    export const schema = z.object({
      id: z.string().optional().describe("The ID of the task or project to edit"),
      name: z.string().optional().describe("The name of the task or project to edit (as fallback if ID not provided)"),
      itemType: z.enum(['task', 'project']).describe("Type of item to edit ('task' or 'project')"),
      
      // Common editable fields
      newName: z.string().optional().describe("New name for the item"),
      newNote: z.string().optional().describe("New note for the item"),
      newDueDate: z.string().optional().describe("New due date in ISO format (YYYY-MM-DD or full ISO date); set to empty string to clear"),
      newDeferDate: z.string().optional().describe("New defer date in ISO format (YYYY-MM-DD or full ISO date); set to empty string to clear"),
      newFlagged: z.boolean().optional().describe("Set flagged status (set to false for no flag, true for flag)"),
      newEstimatedMinutes: z.number().optional().describe("New estimated minutes"),
      
      // Task-specific fields
      newStatus: z.enum(['incomplete', 'completed', 'dropped']).optional().describe("New status for tasks (incomplete, completed, dropped)"),
      addTags: z.array(z.string()).optional().describe("Tags to add to the task"),
      removeTags: z.array(z.string()).optional().describe("Tags to remove from the task"),
      replaceTags: z.array(z.string()).optional().describe("Tags to replace all existing tags with"),
      
      // Project-specific fields
      newSequential: z.boolean().optional().describe("Whether the project should be sequential"),
      newFolderName: z.string().optional().describe("New folder to move the project to"),
      newProjectStatus: z.enum(['active', 'completed', 'dropped', 'onHold']).optional().describe("New status for projects")
    });
  • src/server.ts:53-58 (registration)
    Registration of the 'edit_item' tool with the MCP server using its schema and handler.
    server.tool(
      "edit_item",
      "Edit a task or project in OmniFocus",
      editItemTool.schema.shape,
      editItemTool.handler
    );
  • Core primitive function that generates AppleScript and executes it via osascript to perform the actual editing in OmniFocus.
    export async function editItem(params: EditItemParams): Promise<{
      success: boolean, 
      id?: string, 
      name?: string, 
      changedProperties?: string,
      error?: string
    }> {
      let tempFile: string | undefined;
      
      try {
        // Generate AppleScript
        const script = generateAppleScript(params);
        
        console.error("Executing AppleScript for editing (V2)...");
        console.error(`Item type: ${params.itemType}, ID: ${params.id || 'not provided'}, Name: ${params.name || 'not provided'}`);
        
        // Log a preview of the script for debugging (first few lines)
        const scriptPreview = script.split('\n').slice(0, 10).join('\n') + '\n...';
        console.error("AppleScript preview:\n", scriptPreview);
        
        // Write script to temporary file to avoid shell escaping issues
        tempFile = join(tmpdir(), `edit_omnifocus_${Date.now()}.applescript`);
        writeFileSync(tempFile, script);
        
        // Execute AppleScript from file
        const { stdout, stderr } = await execAsync(`osascript ${tempFile}`);
        
        // Clean up temp file
        try {
          unlinkSync(tempFile);
        } catch (cleanupError) {
          console.error("Failed to clean up temp file:", cleanupError);
        }
        
        if (stderr) {
          console.error("AppleScript stderr:", stderr);
        }
        
        console.error("AppleScript stdout:", stdout);
        
        // Parse the result
        try {
          const result = JSON.parse(stdout);
          
          // Return the result
          return {
            success: result.success,
            id: result.id,
            name: result.name,
            changedProperties: result.changedProperties,
            error: result.error
          };
        } catch (parseError) {
          console.error("Error parsing AppleScript result:", parseError);
          return {
            success: false,
            error: `Failed to parse result: ${stdout}`
          };
        }
      } catch (error: any) {
        // Clean up temp file if it exists
        if (tempFile) {
          try {
            unlinkSync(tempFile);
          } catch (cleanupError) {
            // Ignore cleanup errors
          }
        }
        
        console.error("Error in editItem execution:", error);
        
        // Include more detailed error information
        if (error.message && error.message.includes('syntax error')) {
          console.error("This appears to be an AppleScript syntax error. Review the script generation logic.");
        }
        
        return {
          success: false,
          error: error?.message || "Unknown error in editItem"
        };
      }
    }
  • TypeScript interface defining parameters for the editItem primitive function.
    export interface EditItemParams {
      id?: string;                  // ID of the task or project to edit
      name?: string;                // Name of the task or project to edit (as fallback if ID not provided)
      itemType: 'task' | 'project'; // Type of item to edit
      
      // Common editable fields
      newName?: string;             // New name for the item
      newNote?: string;             // New note for the item
      newDueDate?: string;          // New due date in ISO format (empty string to clear)
      newDeferDate?: string;        // New defer date in ISO format (empty string to clear)
      newFlagged?: boolean;         // New flagged status (false to remove flag, true to add flag)
      newEstimatedMinutes?: number; // New estimated minutes
      
      // Task-specific fields
      newStatus?: TaskStatus;       // New status for tasks (incomplete, completed, dropped)
      addTags?: string[];           // Tags to add to the task
      removeTags?: string[];        // Tags to remove from the task
      replaceTags?: string[];       // Tags to replace all existing tags with
      
      // Project-specific fields
      newSequential?: boolean;      // Whether the project should be sequential
      newFolderName?: string;       // New folder to move the project to
      newProjectStatus?: ProjectStatus; // New status for projects
    }
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 offers minimal behavioral disclosure. It states 'Edit' which implies mutation, but doesn't describe permissions needed, whether changes are reversible, error handling (e.g., if ID not found), or response format. For a complex 16-parameter mutation tool, this leaves significant gaps in understanding how it behaves.

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 front-loads the core purpose without unnecessary words. Every word earns its place: 'Edit' (action), 'a task or project' (targets), 'in OmniFocus' (context). No redundancy or fluff, making it easy to parse quickly.

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?

Given high complexity (16 parameters, mutation operation), no annotations, and no output schema, the description is inadequate. It doesn't address behavioral aspects like side effects, error conditions, or what the tool returns. For a powerful edit tool with many parameters, more context is needed to use it effectively and safely.

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 all 16 parameters with clear descriptions and enums. The description adds no parameter-specific information beyond what's in the schema, maintaining the baseline score of 3. It doesn't explain parameter interactions (e.g., how 'replaceTags' relates to 'addTags/removeTags') or provide usage examples.

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 ('Edit') and resource ('a task or project in OmniFocus'), providing specific action and target. It distinguishes from siblings like 'add_omnifocus_task' and 'remove_item' by focusing on modification rather than creation or deletion. However, it doesn't explicitly differentiate from all siblings (e.g., 'batch_add_items' might also involve modifications).

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing item), exclusions (e.g., when batch operations might be better), or comparisons to siblings like 'batch_add_items' for multiple edits. Usage is implied but not explicitly stated.

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