switch_focus
Switch to a specific task by ID to manage priorities or revisit completed work. Maintain focus and context within complex workflows using the hierarchical task management system of the Aidderall MCP Server.
Instructions
Switch focus to ANY task by ID. The primary way to navigate your task workspace - jump between tasks in any order, revisit completed work, or change priorities on the fly. Current task retains its status, target task becomes current. Use get_big_picture or get_stack_overview to see task IDs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task_id | Yes | The ID of the task to switch focus to |
Implementation Reference
- src/handlers.py:219-224 (handler)MCP tool handler function that calls TaskManager.switch_focus and wraps the result or error.async def handle_switch_focus(self, task_id: str) -> Dict[str, Any]: try: result = self.task_manager.switch_focus(task_id) return result except ValueError as e: return {"error": str(e)}
- src/handlers.py:358-371 (schema)Input JSON schema for the switch_focus tool, defining the required 'task_id' parameter.Tool( name="switch_focus", description="Switch focus to ANY task by ID. The primary way to navigate your task workspace - jump between tasks in any order, revisit completed work, or change priorities on the fly. Current task retains its status, target task becomes current. 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 switch focus to", } }, "required": ["task_id"], }, ),
- src/server.py:48-75 (registration)Tool registration in the server.call_tool handler_map dictionary, mapping 'switch_focus' to its 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"]), }
- src/task_manager.py:383-426 (helper)Core implementation in TaskManager that locates the target task, updates task statuses, sets manual focus, and returns confirmation with new focus path.def switch_focus(self, task_id: str) -> Dict[str, Any]: """Switch focus to any pending task by ID.""" # Find the task in the structure target_task: Optional[Task] = None for main_task in self.global_tasks: if main_task.id == task_id and main_task.status != TaskStatus.COMPLETED: target_task = main_task break for sub_task in main_task.sub_tasks: if sub_task.id == task_id and sub_task.status != TaskStatus.COMPLETED: target_task = sub_task break if target_task: break if not target_task: raise ValueError(f"Task with ID '{task_id}' not found or already completed") # If it's already the current task, nothing to do if target_task == self.current_task: return { "success": True, "message": "Task is already the current focus", "task_id": task_id, } # Set old current task to PENDING if self.current_task: self.current_task.status = TaskStatus.PENDING # Set new task to CURRENT target_task.status = TaskStatus.CURRENT # Set the manual current task self._manual_current_task = target_task # Return helpful context about the switch return { "success": True, "message": f"Switched focus to task: {target_task.title}", "task_id": task_id, "new_focus_path": self.get_focus_path(), }