Skip to main content
Glama
hrishirc

Task Orchestration

remove_tasks

Remove tasks from goals by marking them as deleted while keeping them in the system. Specify task IDs and optionally delete child tasks.

Instructions

Soft-delete multiple tasks from a goal. Tasks are marked as deleted but remain in the system. Task IDs use a dot-notation (e.g., "1", "1.1", "1.1.1"). Responses will return simplified task objects without createdAt, updatedAt, or parentId. Soft-deleted tasks are excluded by default from get_tasks results unless includeDeletedTasks is set to true.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
goalIdYesID of the goal to remove tasks from (number)
taskIdsYesIDs of the tasks to remove (array of strings). Example: ["1", "1.1"].
deleteChildrenNoWhether to delete child tasks along with the parent (boolean). Defaults to false. If false, attempting to delete a parent task with existing subtasks will throw an error.

Implementation Reference

  • Core handler function that soft-deletes the specified tasks (and optionally their children), collects removed tasks, updates parent completion statuses, and returns results.
    async removeTasks(
      goalId: number,
      taskIds: string[],
      deleteChildren: boolean = false // New parameter
    ): Promise<{ removedTasks: TaskResponse[]; completedParents: TaskResponse[] }> {
      const plan = await this.getPlan(goalId);
      if (!plan) {
        throw new Error(`No plan found for goal ${goalId}`);
      }
    
      const removedTasks: TaskResponse[] = [];
      const completedParents: TaskResponse[] = [];
      const parentsToCheck: Set<string | null> = new Set();
    
      // Sort taskIds to ensure parent tasks are processed before their subtasks
      const sortedTaskIds = taskIds.sort((a, b) => {
        const aParts = a.split('.').map(Number);
        const bParts = b.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;
      });
    
      // Validate if deletion is allowed based on deleteChildren flag
      for (const taskId of sortedTaskIds) {
        const task = this.tasks.findOne({ goalId, id: taskId });
        if (!task) continue;
    
        const subtasks = this.tasks.find({ goalId, parentId: taskId });
        if (subtasks.length > 0 && !deleteChildren) {
          throw new Error(`Task ${taskId} has subtasks and cannot be deleted without explicitly setting 'deleteChildren' to true.`);
        }
      }
    
      // Soft delete the tasks and all their subtasks
      const softDeleteTaskAndSubtasks = async (taskId: string) => {
        const task = this.tasks.findOne({ goalId, id: taskId });
        if (!task) return;
    
        // Add parent to set for status check later
        if (task.parentId !== null) {
          parentsToCheck.add(task.parentId);
        }
    
        // First soft delete all subtasks (only if deleteChildren is true, which is checked above)
        const subtasks = this.tasks.find({ goalId, parentId: taskId });
        for (const subtask of subtasks) {
          await softDeleteTaskAndSubtasks(subtask.id);
        }
    
        // Then soft delete the task itself
        if (!task.deleted) {
          task.deleted = true;
          task.updatedAt = new Date().toISOString();
          this.tasks.update(task);
          const { createdAt, updatedAt, parentId: _, $loki, meta, ...taskData } = task as LokiTask;
          removedTasks.push(taskData);
        }
      };
    
      for (const taskId of sortedTaskIds) {
        await softDeleteTaskAndSubtasks(taskId);
      }
    
      // Update parent statuses
      for (const parentId of parentsToCheck) {
        if (parentId !== null) {
          const parentTask = this.tasks.findOne({ goalId, id: parentId });
          if (parentTask) {
            // Only consider non-deleted child tasks for parent completion status
            const childTasks = this.tasks.find({ goalId, parentId, deleted: false });
            const allChildrenComplete = childTasks.length > 0 && childTasks.every(task => task.isComplete);
            
            if (allChildrenComplete && !parentTask.isComplete) {
              parentTask.isComplete = true;
              parentTask.updatedAt = new Date().toISOString();
              this.tasks.update(parentTask);
              const { createdAt, updatedAt, parentId: _, $loki, meta, ...taskData } = parentTask as LokiTask;
              completedParents.push(taskData);
            } else if (!allChildrenComplete && parentTask.isComplete) {
              // If a non-deleted child task is marked incomplete, or a new incomplete non-deleted child is added,
              // the parent should also become incomplete.
              parentTask.isComplete = false;
              parentTask.updatedAt = new Date().toISOString();
              this.tasks.update(parentTask);
              const { createdAt, updatedAt, parentId: _, $loki, meta, ...taskData } = parentTask as LokiTask;
              completedParents.push(taskData);
            }
          }
        }
      }
    
      plan.updatedAt = new Date().toISOString();
      await this.save();
      return { removedTasks, completedParents };
    }
  • MCP tool dispatch handler for 'remove_tasks' that extracts parameters, calls storage.removeTasks, and formats the response.
    case 'remove_tasks': {
      const { goalId, taskIds, deleteChildren } = request.params.arguments as { goalId: number; taskIds: string[]; deleteChildren?: boolean };
      const results = await storage.removeTasks(goalId, taskIds, deleteChildren);
    
      const textContent = JSON.stringify(results, null, 2);
      return {
        content: [
          {
            type: 'text',
            text: textContent,
          },
        ],
      };
    }
  • src/index.ts:106-131 (registration)
    Tool registration in the ListTools response, including name, description, and input schema.
    {
      name: 'remove_tasks',
      description: 'Soft-delete multiple tasks from a goal. Tasks are marked as deleted but remain in the system. Task IDs use a dot-notation (e.g., "1", "1.1", "1.1.1"). Responses will return simplified task objects without `createdAt`, `updatedAt`, or `parentId`. Soft-deleted tasks are excluded by default from `get_tasks` results unless `includeDeletedTasks` is set to true.',
      inputSchema: {
        type: 'object',
        properties: {
          goalId: {
            type: 'number',
            description: 'ID of the goal to remove tasks from (number)',
          },
          taskIds: {
            type: 'array',
            items: {
              type: 'string',
            },
            description: 'IDs of the tasks to remove (array of strings). Example: ["1", "1.1"].',
          },
          deleteChildren: {
            type: 'boolean',
            description: 'Whether to delete child tasks along with the parent (boolean). Defaults to false. If false, attempting to delete a parent task with existing subtasks will throw an error.',
            default: false,
          },
        },
        required: ['goalId', 'taskIds'],
      },
    },
  • Input schema definition for the remove_tasks tool, specifying parameters, types, descriptions, and requirements.
    inputSchema: {
      type: 'object',
      properties: {
        goalId: {
          type: 'number',
          description: 'ID of the goal to remove tasks from (number)',
        },
        taskIds: {
          type: 'array',
          items: {
            type: 'string',
          },
          description: 'IDs of the tasks to remove (array of strings). Example: ["1", "1.1"].',
        },
        deleteChildren: {
          type: 'boolean',
          description: 'Whether to delete child tasks along with the parent (boolean). Defaults to false. If false, attempting to delete a parent task with existing subtasks will throw an error.',
          default: false,
        },
      },
      required: ['goalId', 'taskIds'],
    },
Behavior4/5

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

With no annotations provided, the description carries the full burden and does so effectively. It discloses key behavioral traits: the soft-delete mechanism (tasks remain in system), the dot-notation for task IDs, the simplified response format (excluding specific fields), and how soft-deleted tasks are handled in 'get_tasks' (excluded by default unless a parameter is set). It does not cover aspects like error handling or permissions, but provides substantial context beyond basic functionality.

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 appropriately sized and front-loaded, starting with the core action and key details (soft-delete, task ID format, response format). Every sentence adds value, with no redundant or unnecessary information, making it efficient and easy to parse.

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

Completeness4/5

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

Given the tool's complexity (mutation with soft-delete behavior), no annotations, and no output schema, the description is largely complete. It explains the operation, task ID format, response format, and interaction with 'get_tasks'. However, it lacks details on error scenarios (e.g., what happens if 'goalId' is invalid) and does not describe the output structure beyond mentioning simplified objects, which could be improved since there's no output schema.

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 schema already documents all parameters thoroughly. The description adds minimal parameter semantics beyond the schema, such as mentioning 'task IDs use a dot-notation' which aligns with the schema's example, but does not provide additional meaning or usage details for parameters like 'goalId' or 'deleteChildren'. 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.

Purpose5/5

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

The description clearly states the specific action ('soft-delete multiple tasks from a goal'), distinguishes it from permanent deletion by explaining tasks are 'marked as deleted but remain in the system', and differentiates from siblings like 'get_tasks' by focusing on removal rather than retrieval or creation.

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

Usage Guidelines4/5

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

The description provides clear context on when to use this tool (for soft-deleting tasks) and implicitly suggests alternatives by mentioning 'get_tasks' with 'includeDeletedTasks' for viewing deleted tasks. However, it does not explicitly state when NOT to use it or compare it directly to other sibling tools like 'add_tasks' or 'complete_task_status'.

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