UNPKG

omnifocus-mcp

Version:

Model Context Protocol (MCP) server that integrates with OmniFocus for AI assistant interaction

47 lines (46 loc) 1.68 kB
import { z } from 'zod'; import { createTag } from '../primitives/createTag.js'; export const schema = z.object({ name: z.string().describe("Name of the tag to create"), parentTagName: z.string().optional().describe("Name of an existing tag to nest the new tag under. Ignored if parentTagID is provided."), parentTagID: z.string().optional().describe("ID of an existing tag to nest the new tag under. Takes precedence over parentTagName.") }); export async function handler(args, extra) { try { const result = await createTag({ name: args.name, parentTagName: args.parentTagName, parentTagID: args.parentTagID }); if (result.success) { const nested = args.parentTagID || args.parentTagName; const location = nested ? ` under "${args.parentTagName ?? args.parentTagID}"` : ''; return { content: [{ type: "text", text: `Created tag "${result.name}"${location} (id: ${result.tagId})` }] }; } else { return { content: [{ type: "text", text: `Failed to create tag: ${result.error}` }], isError: true }; } } catch (err) { const error = err; console.error(`Error creating tag: ${error.message}`); return { content: [{ type: "text", text: `Error creating tag: ${error.message}` }], isError: true }; } }