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
35 lines (34 loc) • 1.68 kB
JavaScript
import { z } from 'zod';
import { getCustomPerspectiveTasks } from '../primitives/getCustomPerspectiveTasks.js';
export const schema = z.object({
perspectiveName: z.string().describe("Exact name of the OmniFocus custom perspective (e.g., '今日工作安排', '今日复盘', '本周项目'). This is NOT a tag name."),
hideCompleted: z.boolean().optional().describe("Whether to hide completed tasks. Set to false to show all tasks including completed ones (default: true)"),
limit: z.number().optional().describe("Maximum number of tasks to return in flat view mode (default: 1000, ignored in hierarchy mode)"),
showHierarchy: z.boolean().optional().describe("Display tasks in hierarchical tree structure showing parent-child relationships. Use this when user wants '层级显示' or 'tree view' (default: false)")
});
export async function handler(args, extra) {
try {
const result = await getCustomPerspectiveTasks({
perspectiveName: args.perspectiveName,
hideCompleted: args.hideCompleted !== false, // Default to true
limit: args.limit || 1000,
showHierarchy: args.showHierarchy || false // Default to false
});
return {
content: [{
type: "text",
text: result
}]
};
}
catch (err) {
const errorMessage = err instanceof Error ? err.message : 'Unknown error occurred';
return {
content: [{
type: "text",
text: `Error getting custom perspective tasks: ${errorMessage}`
}],
isError: true
};
}
}