Skip to main content
Glama

remove_task

Remove tasks from your workspace structure to clean up completed or unnecessary items. This action deletes tasks and their subtasks while preserving completed items in history.

Instructions

Remove a task from the structure (cleanup your workspace). The task remains in completed_tasks history if it was completed. Can remove any task (completed or not). Removing a parent task removes all its subtasks. Use get_big_picture or get_stack_overview to see task IDs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
task_idYesThe ID of the task to remove from the structure

Implementation Reference

  • The MCP tool handler function that executes the remove_task logic by delegating to TaskManager.remove_task.
    async def handle_remove_task(self, task_id: str) -> Dict[str, Any]:
        try:
            result = self.task_manager.remove_task(task_id)
            return result
        except ValueError as e:
            return {"error": str(e)}
  • The Tool object definition in get_tool_definitions, providing name, description, and inputSchema with task_id parameter.
    Tool(
        name="remove_task",
        description="Remove a task from the structure (cleanup your workspace). The task remains in completed_tasks history if it was completed. Can remove any task (completed or not). Removing a parent task removes all its subtasks. Use get_big_picture or get_stack_overview to see task IDs.",
        inputSchema={
            "type": "object",
            "properties": {
                "task_id": {
                    "type": "string",
                    "description": "The ID of the task to remove from the structure",
                }
            },
            "required": ["task_id"],
        },
    ),
  • src/server.py:48-75 (registration)
    The server.call_tool handler_map dictionary registers 'remove_task' by mapping it to the corresponding handler lambda.
    handler_map = {
        "create_new_task": lambda: handlers.handle_create_new_task(
            arguments["title"], arguments["body"]
        ),
        "extend_current_task": lambda: handlers.handle_extend_current_task(
            arguments["title"], arguments["body"]
        ),
        "get_current_task": handlers.handle_get_current_task,
        "get_big_picture": lambda: handlers.handle_get_big_picture(
            arguments.get("format", "text")
        ),
        "complete_current_task": handlers.handle_complete_current_task,
        "get_completed_tasks": lambda: handlers.handle_get_completed_tasks(
            arguments.get("order", "chronological")
        ),
        "update_current_task": lambda: handlers.handle_update_current_task(
            arguments["body"]
        ),
        "get_stack_overview": handlers.handle_get_stack_overview,
        "peek_context": lambda: handlers.handle_peek_context(
            arguments.get("include_body", False)
        ),
        "list_siblings": lambda: handlers.handle_list_siblings(
            arguments.get("include_body", False)
        ),
        "switch_focus": lambda: handlers.handle_switch_focus(arguments["task_id"]),
        "remove_task": lambda: handlers.handle_remove_task(arguments["task_id"]),
    }
  • The core implementation in TaskManager that locates the task by ID (main or subtask), removes it from the structure, clears focus if necessary, and returns a success dict. Note: parent removal cascades by popping the main task.
    def remove_task(self, task_id: str) -> Dict[str, Any]:
        """Remove a task from the structure (but keep in completed_tasks if it was completed)."""
        # Find the task in the structure
        removed_task: Optional[Task] = None
    
        # Check main tasks
        for i, main_task in enumerate(self.global_tasks):
            if main_task.id == task_id:
                removed_task = main_task
                self.global_tasks.pop(i)
    
                # If this was the current task, clear manual focus
                if removed_task == self._manual_current_task:
                    self._manual_current_task = None
    
                return {
                    "success": True,
                    "message": f"Removed task: {removed_task.title}",
                    "task_id": task_id,
                    "was_completed": removed_task.status == TaskStatus.COMPLETED,
                }
    
            # Check subtasks
            for j, sub_task in enumerate(main_task.sub_tasks):
                if sub_task.id == task_id:
                    removed_task = sub_task
                    main_task.sub_tasks.pop(j)
    
                    # If this was the current task, clear manual focus
                    if removed_task == self._manual_current_task:
                        self._manual_current_task = None
    
                    return {
                        "success": True,
                        "message": f"Removed subtask: {removed_task.title}",
                        "task_id": task_id,
                        "was_completed": removed_task.status == TaskStatus.COMPLETED,
                    }
    
        raise ValueError(f"Task with ID '{task_id}' not found in structure")

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/cheezcake/aidderall_mcp'

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