omnifocus-mcp
Version:
Model Context Protocol (MCP) server that integrates with OmniFocus for AI assistant interaction
35 lines (34 loc) • 1.21 kB
JavaScript
import { executeOmniFocusScript } from '../../utils/scriptExecution.js';
export async function listPerspectives(params = {}) {
const { includeBuiltIn = true, includeCustom = true } = params;
try {
// Execute the OmniJS script to list perspectives
// This uses the built-in OmniFocus JavaScript API
const result = await executeOmniFocusScript('@listPerspectives.js');
if (result.error) {
return {
success: false,
error: result.error
};
}
// Filter perspectives based on parameters
let perspectives = result.perspectives || [];
if (!includeBuiltIn) {
perspectives = perspectives.filter((p) => p.type !== 'builtin');
}
if (!includeCustom) {
perspectives = perspectives.filter((p) => p.type !== 'custom');
}
return {
success: true,
perspectives: perspectives
};
}
catch (error) {
console.error('Error listing perspectives:', error);
return {
success: false,
error: error instanceof Error ? error.message : 'Unknown error occurred'
};
}
}