get_subtasks
Retrieve subtasks associated with a specific parent task ID to efficiently manage and organize task hierarchies in a locally-hosted task management system.
Instructions
Get subtasks for a given parent task ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| parent_id | Yes |
Implementation Reference
- server.py:89-89 (registration)Registration and handler for the MCP tool 'get_subtasks' using @mcp.tool() decorator.@mcp.tool()
- server.py:89-93 (handler)The executing handler function for 'get_subtasks', which calls TaskService to fetch subtasks by parent_id.@mcp.tool() async def get_subtasks(parent_id: str) -> list[dict[str, Any]]: """Get subtasks for a given parent task ID.""" return service.get_all_tasks(parent_id=parent_id)
- Core logic for retrieving subtasks: TaskService.get_all_tasks filters by parent_id and fetches from repository.def get_all_tasks(self, include_completed: bool = False, parent_id: Optional[str] = None, tags: List[str] = None) -> List[Dict[str, Any]]: """Get all tasks with optional filtering and their subtasks.""" # Get tasks from database tasks = self.repository.get_todos(include_completed, parent_id, tags) # Only add subtasks for top-level tasks if parent_id is None: for task in tasks: self._recursively_add_subtasks(task) return tasks