Skip to main content
Glama
hrishirc

Task Orchestration

get_tasks

Retrieve tasks for a specific goal with flexible options for subtask inclusion, task filtering, and detail level control.

Instructions

Get tasks for a goal. Task IDs use a dot-notation (e.g., "1", "1.1", "1.1.1"). When includeSubtasks is specified, responses will return hierarchical task objects. Otherwise, simplified task objects without createdAt, updatedAt, or parentId will be returned.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
goalIdYesID of the goal to get tasks for (number)
taskIdsNoOptional: IDs of tasks to fetch (array of strings). If null or empty, all tasks for the goal will be fetched.
includeSubtasksNoLevel of subtasks to include: "none" (only top-level tasks), "first-level" (top-level tasks and their direct children), or "recursive" (all nested subtasks). Defaults to "none".none
includeDeletedTasksNoWhether to include soft-deleted tasks in the results (boolean). Defaults to false.

Implementation Reference

  • The MCP CallToolRequestSchema handler case for 'get_tasks': extracts parameters from request, calls storage.getTasks with appropriate arguments, maps the fetched tasks to TaskResponse format (excluding internal fields like timestamps and parentId), stringifies to JSON, and returns as text content.
    case 'get_tasks': {
      const { goalId, taskIds, includeSubtasks = 'none', includeDeletedTasks = false } = request.params.arguments as { 
        goalId: number; 
        taskIds?: string[];
        includeSubtasks?: 'none' | 'first-level' | 'recursive';
        includeDeletedTasks?: boolean;
      };
    
      // If taskIds are provided, fetch specific tasks. Otherwise, fetch all tasks for the goal.
      const fetchedTasks: TaskResponse[] = await storage.getTasks(goalId, taskIds && taskIds.length > 0 ? taskIds : undefined, includeSubtasks, includeDeletedTasks);
      
      // Map Task objects to TaskResponse objects to match the schema description
      const taskResponses: TaskResponse[] = fetchedTasks.map(task => ({
        id: task.id,
        goalId: task.goalId,
        title: task.title,
        description: task.description,
        isComplete: task.isComplete,
        deleted: task.deleted,
      }));
    
      const textContent = JSON.stringify(taskResponses, null, 2);
      return {
        content: [
          {
            type: 'text',
            text: textContent,
          },
        ],
      };
    }
  • src/index.ts:132-163 (registration)
    Tool registration in ListToolsRequestSchema handler: defines name 'get_tasks', description, and detailed inputSchema for parameters like goalId, optional taskIds, includeSubtasks levels, and includeDeletedTasks.
    {
      name: 'get_tasks',
      description: 'Get tasks for a goal. Task IDs use a dot-notation (e.g., "1", "1.1", "1.1.1"). When `includeSubtasks` is specified, responses will return hierarchical task objects. Otherwise, simplified task objects without `createdAt`, `updatedAt`, or `parentId` will be returned.',
      inputSchema: {
        type: 'object',
        properties: {
          goalId: {
            type: 'number',
            description: 'ID of the goal to get tasks for (number)',
          },
          taskIds: {
            type: 'array',
            items: {
              type: 'string',
            },
            description: 'Optional: IDs of tasks to fetch (array of strings). If null or empty, all tasks for the goal will be fetched.',
          },
          includeSubtasks: {
            type: 'string',
            description: 'Level of subtasks to include: "none" (only top-level tasks), "first-level" (top-level tasks and their direct children), or "recursive" (all nested subtasks). Defaults to "none".',
            enum: ['none', 'first-level', 'recursive'],
            default: 'none',
          },
          includeDeletedTasks: {
            type: 'boolean',
            description: 'Whether to include soft-deleted tasks in the results (boolean). Defaults to false.',
            default: false,
          },
        },
        required: ['goalId'],
      },
    },
  • Storage helper method implementing the core getTasks logic: retrieves tasks from LokiDB for the goal, optionally filters deleted tasks, handles fetching specific taskIds or all tasks, recursively or partially includes subtasks based on includeSubtasks parameter, deduplicates, sorts hierarchically by task ID, and maps to clean TaskResponse objects excluding internal fields.
    async getTasks(
      goalId: number,
      taskIds?: string[],
      includeSubtasks: 'none' | 'first-level' | 'recursive' = 'none',
      includeDeletedTasks: boolean = false
    ): Promise<TaskResponse[]> {
      let tasksToConsider = this.tasks.find({ goalId });
    
      // Filter out deleted tasks unless explicitly requested
      if (!includeDeletedTasks) {
        tasksToConsider = tasksToConsider.filter(task => !task.deleted);
      }
    
      let resultTasks: LokiTask[] = [];
    
      if (taskIds && taskIds.length > 0) {
        // If specific taskIds are provided, start with those tasks
        const initialTasks = tasksToConsider.filter(task => taskIds.includes(task.id));
        resultTasks.push(...initialTasks);
    
        if (includeSubtasks === 'first-level') {
          // Add direct children of the initial tasks
          for (const task of initialTasks) {
            const directChildren = tasksToConsider.filter(child => child.parentId === task.id);
            resultTasks.push(...directChildren);
          }
        } else if (includeSubtasks === 'recursive') {
          // Add all recursive children of the initial tasks
          const addRecursiveChildren = (parentTaskId: string) => {
            const children = tasksToConsider.filter(child => child.parentId === parentTaskId);
            for (const child of children) {
              resultTasks.push(child);
              addRecursiveChildren(child.id);
            }
          };
          for (const task of initialTasks) {
            addRecursiveChildren(task.id);
          }
        }
      } else {
        // If no specific taskIds are provided, fetch tasks based on includeSubtasks
        if (includeSubtasks === 'none') {
          resultTasks = tasksToConsider.filter(task => task.parentId === null);
        } else if (includeSubtasks === 'first-level') {
          const topLevelTasks = tasksToConsider.filter(task => task.parentId === null);
          resultTasks.push(...topLevelTasks);
          for (const task of topLevelTasks) {
            const directChildren = tasksToConsider.filter(child => child.parentId === task.id);
            resultTasks.push(...directChildren);
          }
        } else if (includeSubtasks === 'recursive') {
          // For recursive and no specific taskIds, return all tasks (already filtered by deleted status)
          resultTasks = tasksToConsider;
        }
      }
    
      // Remove duplicates and sort
      const uniqueResultTasks = Array.from(new Set(resultTasks));
      
      // Sort based on task ID structure
      uniqueResultTasks.sort((a, b) => {
        const aParts = a.id.split('.').map(Number);
        const bParts = b.id.split('.').map(Number);
    
        for (let i = 0; i < Math.min(aParts.length, bParts.length); i++) {
          if (aParts[i] !== bParts[i]) {
            return aParts[i] - bParts[i];
          }
        }
        return aParts.length - bParts.length;
      });
    
      const mapToTaskResponse = (task: LokiTask): TaskResponse => {
        const { createdAt, updatedAt, parentId: _, $loki, meta, ...taskResponse } = task as LokiTask;
        return taskResponse;
      };
    
      return uniqueResultTasks.map(mapToTaskResponse);
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds useful context beyond the input schema: it explains the dot-notation for task IDs and describes how 'includeSubtasks' affects response structure (hierarchical vs. simplified objects). However, it lacks details on permissions, rate limits, or error handling, leaving gaps for a mutation-free but data-retrieval tool.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded, with the core purpose stated first. Both sentences add value: the first explains task ID format, and the second details response variations based on 'includeSubtasks.' There's no wasted text, though it could be slightly more structured (e.g., bullet points for clarity).

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 (4 parameters, no output schema, no annotations), the description is partially complete. It covers key behavioral aspects like response formatting but omits details on permissions, error cases, or output structure. Without an output schema, more guidance on return values would be beneficial, but it's adequate for basic usage.

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%, so the input schema fully documents all parameters. The description adds marginal value by clarifying the dot-notation format for task IDs and the effect of 'includeSubtasks' on response objects, but it doesn't provide additional syntax or meaning beyond what the schema already covers. 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 tool's purpose: 'Get tasks for a goal.' It specifies the verb ('Get') and resource ('tasks for a goal'), making the action unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'add_tasks' or 'remove_tasks' beyond the basic verb distinction, which prevents a perfect 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 (e.g., 'add_tasks' for adding tasks or 'complete_task_status' for updating status) or clarify scenarios where this tool is preferred. Usage is implied only by the action 'Get,' with no explicit context or exclusions provided.

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

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/hrishirc/task-orchestrator'

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