Skip to main content
Glama

edit_item

Modify tasks or projects in OmniFocus by updating names, notes, due dates, flags, statuses, tags, or folder locations to streamline task management and enhance productivity.

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

  • The registered handler function for the 'edit_item' tool. Validates inputs, calls the primitive editItem, and formats 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 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:62-67 (registration)
    Registers the 'edit_item' tool on the MCP server using the schema and handler from editItemTool.
    server.tool(
      "edit_item",
      "Edit a task or project in OmniFocus",
      editItemTool.schema.shape,
      editItemTool.handler
    );
  • Core helper 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
    }> {
      try {
        // Generate AppleScript
        const script = generateAppleScript(params);
        
        console.error("Executing AppleScript for editing...");
        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);
        
        // Execute AppleScript directly
        const { stdout, stderr } = await execAsync(`osascript -e '${script}'`);
        
        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) {
        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"
        };
      }
    } 
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but only states the basic purpose. It doesn't mention that this is a mutation operation (implied by 'Edit'), what permissions are needed, whether changes are reversible, error conditions, or what happens when multiple parameters are provided simultaneously (e.g., addTags vs replaceTags).

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 states the core purpose without unnecessary words. It's appropriately sized for a tool with comprehensive schema documentation, though it could benefit from additional context about usage and behavior.

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 complex mutation tool with 16 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what the tool returns, error handling, or behavioral nuances. The agent must rely entirely on the input schema for understanding, which lacks context about how the edit operation actually works in practice.

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 all parameters are documented in the schema itself. The description adds no additional parameter information beyond what's in the schema. According to scoring rules, when schema coverage is high (>80%), the baseline is 3 even with no param info in description.

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 action ('Edit') and target ('a task or project in OmniFocus'), providing specific verb+resource. However, it doesn't distinguish this from sibling tools like 'remove_item' or 'add_omnifocus_task' beyond the basic edit vs add/remove distinction, missing opportunities to clarify scope boundaries.

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 (like needing an existing item ID), when to choose edit over remove+add, or how it differs from batch operations available in sibling tools like 'batch_add_items' or 'batch_remove_items'.

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/jqlts1/omnifocus-mcp-enhanced'

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