get_time_tracked
Retrieve tracked time for tasks within a specified date range using user ID. Supports time management and project analytics via ClickUp's task management API.
Instructions
Get time tracked for tasks
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end_date | No | End date (ISO 8601) | |
| start_date | No | Start date (ISO 8601) | |
| user_id | No | User ID |
Implementation Reference
- src/clickup_mcp/tools.py:1072-1116 (handler)The core handler function that implements the get_time_tracked tool. It queries the ClickUp time_entries API endpoint with date range and optional user filter, aggregates the total duration from entries, converts to hours, and returns a summary including total time, number of entries, and period.async def get_time_tracked( self, user_id: Optional[int] = None, start_date: Optional[str] = None, end_date: Optional[str] = None, ) -> Dict[str, Any]: """Get time tracked for tasks.""" # If no dates provided, default to last 7 days if not start_date: start_date = (datetime.now() - timedelta(days=7)).isoformat() if not end_date: end_date = datetime.now().isoformat() start_ts = int(datetime.fromisoformat(start_date.replace("Z", "+00:00")).timestamp() * 1000) end_ts = int(datetime.fromisoformat(end_date.replace("Z", "+00:00")).timestamp() * 1000) # Get time entries params = { "start_date": str(start_ts), "end_date": str(end_ts), } if user_id: params["assignee"] = str(user_id) workspace_id = self.client.config.default_workspace_id if not workspace_id: workspaces = await self.client.get_workspaces() workspace_id = workspaces[0].id data = await self.client._request( "GET", f"/team/{workspace_id}/time_entries", params=params ) total_ms = sum(entry.get("duration", 0) for entry in data.get("data", [])) total_hours = total_ms / (1000 * 60 * 60) return { "total_milliseconds": total_ms, "total_hours": round(total_hours, 2), "entries": len(data.get("data", [])), "period": { "start": start_date, "end": end_date, }, }
- src/clickup_mcp/tools.py:368-379 (schema)Defines the input schema and description for the get_time_tracked tool used in MCP tool registration.Tool( name="get_time_tracked", description="Get time tracked for tasks", inputSchema={ "type": "object", "properties": { "user_id": {"type": "integer", "description": "User ID"}, "start_date": {"type": "string", "description": "Start date (ISO 8601)"}, "end_date": {"type": "string", "description": "End date (ISO 8601)"}, }, }, ),
- src/clickup_mcp/tools.py:23-57 (registration)Registers the get_time_tracked handler method in the internal _tools dictionary of ClickUpTools class for dynamic tool invocation.self._tools: Dict[str, Callable] = { "create_task": self.create_task, "get_task": self.get_task, "update_task": self.update_task, "delete_task": self.delete_task, "list_tasks": self.list_tasks, "search_tasks": self.search_tasks, "get_subtasks": self.get_subtasks, "get_task_comments": self.get_task_comments, "create_task_comment": self.create_task_comment, "get_task_status": self.get_task_status, "update_task_status": self.update_task_status, "get_assignees": self.get_assignees, "assign_task": self.assign_task, "list_spaces": self.list_spaces, "list_folders": self.list_folders, "list_lists": self.list_lists, "find_list_by_name": self.find_list_by_name, # Bulk operations "bulk_update_tasks": self.bulk_update_tasks, "bulk_move_tasks": self.bulk_move_tasks, # Time tracking "get_time_tracked": self.get_time_tracked, "log_time": self.log_time, # Templates "create_task_from_template": self.create_task_from_template, "create_task_chain": self.create_task_chain, # Analytics "get_team_workload": self.get_team_workload, "get_task_analytics": self.get_task_analytics, # User management "list_users": self.list_users, "get_current_user": self.get_current_user, "find_user_by_name": self.find_user_by_name, }
- src/clickup_mcp/server.py:41-45 (registration)MCP server registration of list_tools handler that exposes all tool definitions (including get_time_tracked) to the MCP protocol.@self.server.list_tools() async def list_tools() -> List[Tool]: """List all available tools.""" return self.tools.get_tool_definitions()