Skip to main content
Glama

get_task_by_id

Retrieve detailed information about a specific task in OmniFocus using either its ID or name, enabling precise task management and tracking.

Instructions

Get information about a specific task by ID or name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskIdNoThe ID of the task to retrieve
taskNameNoThe name of the task to retrieve (alternative to taskId)

Implementation Reference

  • The MCP tool handler for 'get_task_by_id'. Validates input, calls the primitive getTaskById, formats the task information into a markdown-like text response, and handles errors.
    export async function handler(args: z.infer<typeof schema>, extra: RequestHandlerExtra) {
      try {
        // Validate that either taskId or taskName is provided
        if (!args.taskId && !args.taskName) {
          return {
            content: [{
              type: "text" as const,
              text: "Error: Either taskId or taskName must be provided."
            }],
            isError: true
          };
        }
    
        // Call the getTaskById function 
        const result = await getTaskById(args as GetTaskByIdParams);
        
        if (result.success && result.task) {
          const task = result.task;
          
          // Format task information for display
          let infoText = `📋 **Task Information**\n`;
          infoText += `• **Name**: ${task.name}\n`;
          infoText += `• **ID**: ${task.id}\n`;
          
          if (task.note) {
            infoText += `• **Note**: ${task.note}\n`;
          }
          
          if (task.parentId && task.parentName) {
            infoText += `• **Parent Task**: ${task.parentName} (${task.parentId})\n`;
          }
          
          if (task.projectId && task.projectName) {
            infoText += `• **Project**: ${task.projectName} (${task.projectId})\n`;
          }
          
          infoText += `• **Has Children**: ${task.hasChildren ? `Yes (${task.childrenCount} subtasks)` : 'No'}\n`;
          
          return {
            content: [{
              type: "text" as const,
              text: infoText
            }]
          };
        } else {
          // Task retrieval failed
          return {
            content: [{
              type: "text" as const,
              text: `Failed to retrieve task: ${result.error}`
            }],
            isError: true
          };
        }
      } catch (err: unknown) {
        const error = err as Error;
        console.error(`Tool execution error: ${error.message}`);
        return {
          content: [{
            type: "text" as const,
            text: `Error retrieving task: ${error.message}`
          }],
          isError: true
        };
      }
    }
  • Zod schema defining the input parameters for the get_task_by_id tool: optional taskId or taskName.
    export const schema = z.object({
      taskId: z.string().optional().describe("The ID of the task to retrieve"),
      taskName: z.string().optional().describe("The name of the task to retrieve (alternative to taskId)")
    });
  • src/server.ts:84-89 (registration)
    Registration of the 'get_task_by_id' tool in the MCP server, specifying name, description, schema, and handler.
    server.tool(
      "get_task_by_id",
      "Get information about a specific task by ID or name",
      getTaskByIdTool.schema.shape,
      getTaskByIdTool.handler
    );
  • Core helper function that generates and executes AppleScript to retrieve task details from OmniFocus by ID or name, returning structured task information or error.
    export async function getTaskById(params: GetTaskByIdParams): Promise<{success: boolean, task?: TaskInfo, error?: string}> {
      try {
        // Validate parameters
        if (!params.taskId && !params.taskName) {
          return {
            success: false,
            error: "Either taskId or taskName must be provided"
          };
        }
    
        // Generate AppleScript
        const script = generateGetTaskScript(params);
        
        console.error("Executing getTaskById AppleScript...");
        
        // Execute AppleScript
        const { stdout, stderr } = await execAsync(`osascript -e '${script}'`);
        
        if (stderr) {
          console.error("AppleScript stderr:", stderr);
        }
        
        console.error("AppleScript stdout:", stdout);
        
        // Parse the result
        try {
          const result = JSON.parse(stdout);
          
          if (result.success) {
            return {
              success: true,
              task: result.task as TaskInfo
            };
          } else {
            return {
              success: false,
              error: result.error
            };
          }
        } catch (parseError) {
          console.error("Error parsing AppleScript result:", parseError);
          return {
            success: false,
            error: `Failed to parse result: ${stdout}`
          };
        }
      } catch (error: any) {
        console.error("Error in getTaskById:", error);
        return {
          success: false,
          error: error?.message || "Unknown error in getTaskById"
        };
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states this is a 'Get' operation, implying it's read-only, but doesn't clarify aspects like authentication needs, error handling (e.g., what happens if the task doesn't exist), rate limits, or response format. For a tool with no annotation coverage, this is a significant gap in transparency.

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 core purpose ('Get information about a specific task') and adds necessary detail ('by ID or name'). There is no wasted verbiage or redundancy, 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.

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete for a tool that retrieves task information. It doesn't explain what information is returned (e.g., task details, status, metadata), potential errors, or how to handle the 'ID or name' choice. For a read operation with no structured output documentation, this leaves critical gaps for the agent.

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?

The schema description coverage is 100%, with clear descriptions for both parameters ('taskId' and 'taskName'), so the schema does the heavy lifting. The description adds marginal value by noting that 'taskName' is an 'alternative to taskId', but doesn't provide additional semantics like format examples or usage constraints beyond what's in the schema. This meets the baseline for high schema coverage.

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 information') and resource ('specific task'), making the purpose understandable. It specifies retrieval by 'ID or name', which adds useful detail. However, it doesn't distinguish this tool from potential sibling tools that might also retrieve tasks (e.g., 'get_tasks_by_tag' or 'filter_tasks'), so it doesn't reach the highest score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get_tasks_by_tag' or 'filter_tasks', nor does it specify prerequisites or exclusions (e.g., whether it works for all tasks or only certain types). This leaves the agent with minimal context for selection.

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