UNPKG

omnifocus-mcp-enhanced

Version:

🚀 NEW: Native Custom Perspective Access! Enhanced MCP server with OmniFocus custom perspective support, hierarchical task display, AI-optimized tool selection, and comprehensive task management

67 lines (66 loc) • 2.85 kB
import { z } from 'zod'; import { addSubtask } from '../primitives/addSubtask.js'; export const schema = z.object({ name: z.string().describe("The name of the subtask"), parentTaskId: z.string().optional().describe("The ID of the parent task"), parentTaskName: z.string().optional().describe("The name of the parent task (alternative to parentTaskId)"), note: z.string().optional().describe("Additional notes for the subtask"), dueDate: z.string().optional().describe("The due date of the subtask in ISO format (YYYY-MM-DD or full ISO date)"), deferDate: z.string().optional().describe("The defer date of the subtask in ISO format (YYYY-MM-DD or full ISO date)"), flagged: z.boolean().optional().describe("Whether the subtask is flagged or not"), estimatedMinutes: z.number().optional().describe("Estimated time to complete the subtask, in minutes"), tags: z.array(z.string()).optional().describe("Tags to assign to the subtask") }); export async function handler(args, extra) { try { // Validate that either parentTaskId or parentTaskName is provided if (!args.parentTaskId && !args.parentTaskName) { return { content: [{ type: "text", text: "Error: Either parentTaskId or parentTaskName must be provided for subtask creation." }], isError: true }; } // Call the addSubtask function const result = await addSubtask(args); if (result.success) { // Subtask was added successfully const parentRef = args.parentTaskId || args.parentTaskName; 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", text: `✅ Subtask "${args.name}" created successfully under parent task "${parentRef}"${dueDateText}${tagText}.` }] }; } else { // Subtask creation failed return { content: [{ type: "text", text: `Failed to create subtask: ${result.error}` }], isError: true }; } } catch (err) { const error = err; console.error(`Tool execution error: ${error.message}`); return { content: [{ type: "text", text: `Error creating subtask: ${error.message}` }], isError: true }; } }