UNPKG

omnifocus-mcp

Version:

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

35 lines (34 loc) 1.4 kB
import { getPerspectiveView } from '../tools/primitives/getPerspectiveView.js'; import { listPerspectives } from '../tools/primitives/listPerspectives.js'; export async function readPerspective(uri, variables, logger) { const name = String(variables.name); logger.debug("resource:perspective", `Reading perspective: ${name}`); const result = await getPerspectiveView({ perspectiveName: name }); const data = result.success ? { items: result.items ?? [] } : { error: result.error }; return { contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify(data, null, 2) }] }; } export async function listAllPerspectives() { const result = await listPerspectives({ includeBuiltIn: true, includeCustom: true }); if (!result.success || !result.perspectives) return []; return result.perspectives.map((p) => ({ uri: `omnifocus://perspective/${encodeURIComponent(p.name)}`, name: p.name })); } export async function completePerspectiveName(value) { const result = await listPerspectives({ includeBuiltIn: true, includeCustom: true }); if (!result.success || !result.perspectives) return []; return result.perspectives .map((p) => p.name) .filter((name) => name.toLowerCase().includes(value.toLowerCase())); }