get_activity_logs
Retrieve activity logs from Chronos Protocol with filtering options including activity type, task scope, date range, and result limits for tracking and analysis.
Instructions
Retrieve activity logs with optional filtering
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| activityType | No | Filter by activity type | |
| endDate | No | Filter by end date (ISO 8601 format) | |
| limit | No | Maximum number of logs to return | |
| startDate | No | Filter by start date (ISO 8601 format) | |
| task_scope | No | Filter by task scope |
Implementation Reference
- src/chronos_protocol/server.py:907-913 (handler)MCP tool handler for 'get_activity_logs': parses arguments into filters dict and delegates execution to Database.get_activity_logs method.case TimeTools.GET_ACTIVITY_LOGS.value: filters = {} for key in ["activityType", "task_scope", "startDate", "endDate", "limit"]: if key in arguments: filters[key] = arguments[key] result = time_server.db.get_activity_logs(filters)
- Input schema / JSON Schema definition for the get_activity_logs tool, defining optional filter parameters.inputSchema={ "type": "object", "properties": { "activityType": { "type": "string", "description": "Filter by activity type", }, "task_scope": { "type": "string", "enum": [scope.value for scope in TaskScope], "description": "Filter by task scope", }, "startDate": { "type": "string", "description": "Filter by start date (ISO 8601 format)", }, "endDate": { "type": "string", "description": "Filter by end date (ISO 8601 format)", }, "limit": { "type": "integer", "description": "Maximum number of logs to return", }, }, },
- Core implementation of get_activity_logs: filters, sorts (newest first), limits, and returns list of activity logs from JSON storage.def get_activity_logs(self, filters: Dict[str, Any] = None) -> List[Dict[str, Any]]: """Get activity logs with optional filtering""" logs = self.activity_logs.copy() if filters: if 'activityType' in filters: logs = [log for log in logs if log['activityType'] == filters['activityType']] if 'task_scope' in filters: logs = [log for log in logs if log['task_scope'] == filters['task_scope']] if 'startDate' in filters: start_date = datetime.fromisoformat(filters['startDate'].replace('Z', '+00:00')) logs = [log for log in logs if datetime.fromisoformat(log['startTime'].replace('Z', '+00:00')) >= start_date] if 'endDate' in filters: end_date = datetime.fromisoformat(filters['endDate'].replace('Z', '+00:00')) logs = [log for log in logs if datetime.fromisoformat(log['startTime'].replace('Z', '+00:00')) <= end_date] # Sort by start time (newest first) logs.sort(key=lambda x: x['startTime'], reverse=True) if filters and 'limit' in filters: logs = logs[:filters['limit']] return logs
- src/chronos_protocol/server.py:741-770 (registration)Tool registration in @server.list_tools(): defines name, description, and inputSchema for get_activity_logs.Tool( name=TimeTools.GET_ACTIVITY_LOGS.value, description="Retrieve activity logs with optional filtering", inputSchema={ "type": "object", "properties": { "activityType": { "type": "string", "description": "Filter by activity type", }, "task_scope": { "type": "string", "enum": [scope.value for scope in TaskScope], "description": "Filter by task scope", }, "startDate": { "type": "string", "description": "Filter by start date (ISO 8601 format)", }, "endDate": { "type": "string", "description": "Filter by end date (ISO 8601 format)", }, "limit": { "type": "integer", "description": "Maximum number of logs to return", }, }, }, ),
- Pydantic schema for ActivityLog entries returned by get_activity_logs.class ActivityLog(BaseModel): activityId: str # Changed from timeId for better naming activityType: str task_scope: TaskScope description: Optional[str] = None tags: Optional[List[str]] = None startTime: str endTime: Optional[str] = None duration: Optional[str] = None durationSeconds: Optional[int] = None result: Optional[str] = None notes: Optional[str] = None status: str # "started", "completed"