Skip to main content
Glama

add_omnifocus_task

Create and manage tasks in OmniFocus by specifying details like name, due date, notes, tags, and project. Assign tasks to projects, set deadlines, and organize with subtasks for efficient productivity.

Instructions

Add a new task to OmniFocus

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deferDateNoThe defer date of the task in ISO format (YYYY-MM-DD or full ISO date)
dueDateNoThe due date of the task in ISO format (YYYY-MM-DD or full ISO date)
estimatedMinutesNoEstimated time to complete the task, in minutes
flaggedNoWhether the task is flagged or not
nameYesThe name of the task
noteNoAdditional notes for the task
parentTaskIdNoThe ID of the parent task to create this task as a subtask
parentTaskNameNoThe name of the parent task to create this task as a subtask (alternative to parentTaskId)
projectNameNoThe name of the project to add the task to (will add to inbox if not specified)
tagsNoTags to assign to the task

Implementation Reference

  • MCP tool handler for 'add_omnifocus_task' that validates input, calls primitive implementation, and returns formatted success/error response.
    export async function handler(args: z.infer<typeof schema>, extra: RequestHandlerExtra) {
      try {
        // Call the addOmniFocusTask function 
        const result = await addOmniFocusTask(args as AddOmniFocusTaskParams);
        
        if (result.success) {
          // Task was added successfully
          let locationText;
          if (args.parentTaskId || args.parentTaskName) {
            const parentRef = args.parentTaskId || args.parentTaskName;
            locationText = `as a subtask of "${parentRef}"`;
          } else if (args.projectName) {
            locationText = `in project "${args.projectName}"`;
          } else {
            locationText = "in your inbox";
          }
            
          let tagText = args.tags && args.tags.length > 0
            ? ` with tags: ${args.tags.join(', ')}`
            : "";
            
          let dueDateText = args.dueDate
            ? ` due on ${new Date(args.dueDate).toLocaleDateString()}`
            : "";
            
          return {
            content: [{
              type: "text" as const,
              text: `✅ Task "${args.name}" created successfully ${locationText}${dueDateText}${tagText}.`
            }]
          };
        } else {
          // Task creation failed
          return {
            content: [{
              type: "text" as const,
              text: `Failed to create task: ${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 creating task: ${error.message}`
          }],
          isError: true
        };
      }
    } 
  • Zod schema defining the input parameters for the add_omnifocus_task tool.
    export const schema = z.object({
      name: z.string().describe("The name of the task"),
      note: z.string().optional().describe("Additional notes for the task"),
      dueDate: z.string().optional().describe("The due date of the task in ISO format (YYYY-MM-DD or full ISO date)"),
      deferDate: z.string().optional().describe("The defer date of the task in ISO format (YYYY-MM-DD or full ISO date)"),
      flagged: z.boolean().optional().describe("Whether the task is flagged or not"),
      estimatedMinutes: z.number().optional().describe("Estimated time to complete the task, in minutes"),
      tags: z.array(z.string()).optional().describe("Tags to assign to the task"),
      projectName: z.string().optional().describe("The name of the project to add the task to (will add to inbox if not specified)"),
      parentTaskId: z.string().optional().describe("The ID of the parent task to create this task as a subtask"),
      parentTaskName: z.string().optional().describe("The name of the parent task to create this task as a subtask (alternative to parentTaskId)")
    });
  • src/server.ts:41-46 (registration)
    Registration of the 'add_omnifocus_task' tool in the MCP server using schema and handler from definitions.
    server.tool(
      "add_omnifocus_task",
      "Add a new task to OmniFocus",
      addOmniFocusTaskTool.schema.shape,
      addOmniFocusTaskTool.handler
    );
  • Core helper function implementing OmniFocus task creation via AppleScript execution, including validation and error handling.
    export async function addOmniFocusTask(params: AddOmniFocusTaskParams): Promise<{success: boolean, taskId?: string, error?: string}> {
      try {
        // Validate parent task parameters
        const validation = await validateParentTaskParams(params);
        if (!validation.valid) {
          return {
            success: false,
            error: validation.error
          };
        }
    
        // Generate AppleScript
        const script = generateAppleScript(params);
        
        console.error("Executing AppleScript directly...");
        
        // 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,
            taskId: result.taskId,
            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 addOmniFocusTask:", error);
        return {
          success: false,
          error: error?.message || "Unknown error in addOmniFocusTask"
        };
      }
    } 
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. It states 'Add a new task' which implies a write operation, but doesn't describe what happens on success/failure, whether tasks are immediately visible, if there are rate limits, or authentication requirements. The description lacks crucial behavioral context for a mutation tool.

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 and gets straight to the point with zero wasted content.

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 mutation tool with 10 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what happens after task creation, error conditions, or how this tool fits within the broader OmniFocus workflow. The agent would need to infer too much about this write operation's behavior and consequences.

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 already documents all 10 parameters thoroughly. The description adds no additional parameter information beyond what's in the schema. This meets the baseline of 3 since the schema does the heavy lifting, but the description doesn't compensate with any higher-level semantic context about parameter relationships or usage patterns.

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 ('Add') and resource ('new task to OmniFocus'), making the purpose immediately understandable. It distinguishes from siblings like 'add_project' by specifying 'task' rather than 'project', though it doesn't explicitly contrast with other task-related tools like 'edit_item' or 'batch_add_items'.

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 like 'edit_item' for modifying existing tasks, 'batch_add_items' for multiple tasks, or 'add_project' for creating projects instead. It also doesn't mention prerequisites or contextual constraints for task creation.

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