get_recent_sessions
Retrieve recent DJ session history from rekordbox databases within a specified timeframe, defaulting to the last 30 days.
Instructions
Get recent DJ history sessions within the specified number of days.
Args: days: Number of days to look back (default: 30)
Returns: List of recent history sessions
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | No |
Implementation Reference
- rekordbox_mcp/server.py:405-432 (handler)The core handler function for the 'get_recent_sessions' MCP tool. It ensures database connection, calculates a cutoff date based on the 'days' parameter, fetches all history sessions, filters recent ones by date_created, sorts them descending by date, and returns their dictionary representations using model_dump().@mcp.tool() async def get_recent_sessions(days: int = 30) -> List[Dict[str, Any]]: """ Get recent DJ history sessions within the specified number of days. Args: days: Number of days to look back (default: 30) Returns: List of recent history sessions """ await ensure_database_connected() from datetime import datetime, timedelta cutoff_date = datetime.now() - timedelta(days=days) cutoff_str = cutoff_date.strftime("%Y-%m-%d") sessions = await db.get_history_sessions(include_folders=False) # Filter by date recent_sessions = [ s for s in sessions if s.date_created and s.date_created >= cutoff_str ] # Sort by date, most recent first recent_sessions.sort(key=lambda x: x.date_created or "", reverse=True) return [session.model_dump() for session in recent_sessions]
- rekordbox_mcp/models.py:94-114 (schema)Pydantic BaseModel defining the structure of HistorySession objects returned by the tool. Each session in the output list conforms to this schema, providing fields like id, name, date_created, track_count, etc.class HistorySession(BaseModel): """ Rekordbox DJ history session model. """ id: str = Field(..., description="Unique history session identifier") name: str = Field(..., description="Session name (usually date)") parent_id: Optional[str] = Field(None, description="Parent folder ID") is_folder: bool = Field(False, description="Whether this is a folder") date_created: Optional[str] = Field(None, description="Date session was created") track_count: int = Field(0, ge=0, description="Number of tracks in session") duration_minutes: Optional[int] = Field(None, description="Total session duration in minutes") @field_validator('date_created', mode='before') @classmethod def validate_date(cls, v): """Convert datetime objects to strings.""" if hasattr(v, 'strftime'): # datetime object return v.strftime("%Y-%m-%d %H:%M:%S") return str(v) if v is not None else None