Skip to main content
Glama

get_forecast_tasks

Retrieve tasks from OmniFocus by filtering due or deferred tasks within a specified date range. Customize results by selecting days ahead, hiding completed tasks, or focusing solely on deferred items.

Instructions

Get tasks from OmniFocus forecast perspective (due/deferred tasks in date range)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysNoNumber of days to look ahead for forecast (default: 7)
hideCompletedNoSet to false to show completed tasks in forecast (default: true)
includeDeferredOnlyNoSet to true to show only deferred tasks becoming available (default: false)

Implementation Reference

  • MCP tool handler function that calls the primitive getForecastTasks and formats response as text content
    export async function handler(args: z.infer<typeof schema>, extra: RequestHandlerExtra) {
      try {
        const result = await getForecastTasks({
          days: args.days || 7,
          hideCompleted: args.hideCompleted !== false, // Default to true
          includeDeferredOnly: args.includeDeferredOnly || false
        });
        
        return {
          content: [{
            type: "text" as const,
            text: result
          }]
        };
      } catch (err: unknown) {
        const errorMessage = err instanceof Error ? err.message : 'Unknown error occurred';
        return {
          content: [{
            type: "text" as const,
            text: `Error getting forecast tasks: ${errorMessage}`
          }],
          isError: true
        };
      }
    }
  • Zod schema defining input parameters for the get_forecast_tasks tool: days, hideCompleted, includeDeferredOnly
    export const schema = z.object({
      days: z.number().min(1).max(30).optional().describe("Number of days to look ahead for forecast (default: 7)"),
      hideCompleted: z.boolean().optional().describe("Set to false to show completed tasks in forecast (default: true)"),
      includeDeferredOnly: z.boolean().optional().describe("Set to true to show only deferred tasks becoming available (default: false)")
    });
  • src/server.ts:113-118 (registration)
    Registration of the get_forecast_tasks tool on the MCP server using its schema and handler
    server.tool(
      "get_forecast_tasks",
      "Get tasks from OmniFocus forecast perspective (due/deferred tasks in date range)", 
      getForecastTasksTool.schema.shape,
      getForecastTasksTool.handler
    );
  • Core helper function that executes OmniFocus forecast script and formats the task output into markdown with dates, summaries, and task details
    export async function getForecastTasks(options: GetForecastTasksOptions = {}): Promise<string> {
      const { days = 7, hideCompleted = true, includeDeferredOnly = false } = options;
      
      try {
        // Execute the forecast tasks script
        const result = await executeOmniFocusScript('@forecastTasks.js', { 
          days: days,
          hideCompleted: hideCompleted,
          includeDeferredOnly: includeDeferredOnly
        });
        
        if (typeof result === 'string') {
          return result;
        }
        
        // If result is an object, format it
        if (result && typeof result === 'object') {
          const data = result as any;
          
          if (data.error) {
            throw new Error(data.error);
          }
          
          // Format the forecast tasks
          let output = `# 📅 FORECAST - Next ${days} days\n\n`;
          
          if (data.tasksByDate && typeof data.tasksByDate === 'object') {
            const dates = Object.keys(data.tasksByDate).sort();
            
            if (dates.length === 0) {
              output += "🎉 No tasks due in the forecast period - enjoy the calm!\n";
            } else {
              const today = new Date();
              today.setHours(0, 0, 0, 0);
              
              dates.forEach(dateStr => {
                const tasks = data.tasksByDate[dateStr];
                if (!tasks || tasks.length === 0) return;
                
                const taskDate = new Date(dateStr);
                const isToday = taskDate.getTime() === today.getTime();
                const isTomorrow = taskDate.getTime() === today.getTime() + 24 * 60 * 60 * 1000;
                const isOverdue = taskDate < today;
                
                let dateHeader = '';
                if (isOverdue) {
                  dateHeader = `## ⚠️ OVERDUE - ${taskDate.toLocaleDateString()}`;
                } else if (isToday) {
                  dateHeader = `## 🔥 TODAY - ${taskDate.toLocaleDateString()}`;
                } else if (isTomorrow) {
                  dateHeader = `## ⏰ TOMORROW - ${taskDate.toLocaleDateString()}`;
                } else {
                  const dayOfWeek = taskDate.toLocaleDateString('en-US', { weekday: 'long' });
                  dateHeader = `## 📅 ${dayOfWeek} - ${taskDate.toLocaleDateString()}`;
                }
                
                output += `${dateHeader}\n`;
                
                tasks.forEach((task: any) => {
                  const flagSymbol = task.flagged ? '🚩 ' : '';
                  const projectStr = task.projectName ? ` (${task.projectName})` : ' (Inbox)';
                  const statusStr = task.taskStatus !== 'Available' ? ` [${task.taskStatus}]` : '';
                  const estimateStr = task.estimatedMinutes ? ` ⏱${task.estimatedMinutes}m` : '';
                  const typeIndicator = task.isDue ? '📅' : '🚀'; // Due vs Deferred
                  
                  output += `• ${typeIndicator} ${flagSymbol}${task.name}${projectStr}${statusStr}${estimateStr}\n`;
                  
                  if (task.note && task.note.trim()) {
                    output += `  📝 ${task.note.trim()}\n`;
                  }
                });
                
                output += '\n';
              });
              
              // Summary
              const totalTasks = dates.reduce((sum, date) => sum + data.tasksByDate[date].length, 0);
              output += `📊 **Summary**: ${totalTasks} task${totalTasks === 1 ? '' : 's'} in forecast\n`;
            }
          } else {
            output += "No forecast data available\n";
          }
          
          return output;
        }
        
        return "Unexpected result format from OmniFocus";
        
      } catch (error) {
        console.error("Error in getForecastTasks:", error);
        throw new Error(`Failed to get forecast tasks: ${error instanceof Error ? error.message : 'Unknown error'}`);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions retrieving tasks from a 'forecast perspective' but doesn't disclose behavioral traits such as whether this is a read-only operation, potential rate limits, authentication needs, or what the output format looks like. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the purpose ('Get tasks from OmniFocus forecast perspective') and adds necessary context ('due/deferred tasks in date range'). There is zero waste, and every word earns its place, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is adequate but incomplete. It covers the basic purpose and hints at parameters, but lacks details on behavioral aspects like output format or operational constraints. Without annotations or output schema, more context would be helpful for full understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear descriptions for all three parameters (days, hideCompleted, includeDeferredOnly). The description adds minimal value beyond the schema by hinting at 'date range' and 'due/deferred tasks', but doesn't provide additional syntax or format details. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and resource 'tasks from OmniFocus forecast perspective', specifying it retrieves 'due/deferred tasks in date range'. It distinguishes from siblings like get_flagged_tasks or get_inbox_tasks by focusing on forecast perspective, though it doesn't explicitly name alternatives. This is clear but lacks explicit sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for retrieving forecast tasks within a date range, which suggests when to use it (e.g., for planning upcoming work). However, it doesn't provide explicit guidance on when not to use it or name alternatives like get_custom_perspective_tasks for other views. Usage is contextually implied but not detailed.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jqlts1/omnifocus-mcp-enhanced'

If you have feedback or need assistance with the MCP directory API, please join our Discord server