Skip to main content
Glama

get_history_stats

Analyze DJ history sessions by retrieving total plays, trends, and performance statistics from rekordbox databases. Gain insights for track selection and playlist optimization.

Instructions

Get comprehensive statistics about DJ history sessions.

Returns: Statistics about all history sessions including totals and trends

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler decorated with @mcp.tool(). Ensures database is connected and calls RekordboxDatabase.get_history_stats(), returning model_dump() as dict.
    @mcp.tool() async def get_history_stats() -> Dict[str, Any]: """ Get comprehensive statistics about DJ history sessions. Returns: Statistics about all history sessions including totals and trends """ await ensure_database_connected() stats = await db.get_history_stats() return stats.model_dump()
  • Pydantic BaseModel defining the output schema/structure of HistoryStats used by the tool.
    class HistoryStats(BaseModel): """ Statistics about DJ history sessions. """ total_sessions: int = Field(0, ge=0, description="Total number of sessions") total_tracks_played: int = Field(0, ge=0, description="Total tracks across all sessions") total_hours_played: float = Field(0.0, ge=0, description="Total hours of DJ sets") most_played_track: Optional[Dict[str, Any]] = Field(None, description="Most played track across sessions") favorite_genres: List[Dict[str, Any]] = Field(default_factory=list, description="Top genres by play count") sessions_by_month: Dict[str, int] = Field(default_factory=dict, description="Sessions grouped by month") avg_session_length: float = Field(0.0, ge=0, description="Average session length in minutes")
  • Supporting method in RekordboxDatabase class that implements the core logic: fetches history sessions, computes totals, averages, and monthly groupings.
    async def get_history_stats(self) -> HistoryStats: """ Get comprehensive statistics about DJ history sessions. Returns: Statistics about all history sessions """ if not self.db: raise RuntimeError("Database not connected") try: # Get all sessions (not folders) sessions = await self.get_history_sessions(include_folders=False) # Calculate basic stats total_sessions = len(sessions) total_tracks_played = sum(s.track_count for s in sessions) total_minutes = sum(s.duration_minutes for s in sessions if s.duration_minutes) total_hours_played = total_minutes / 60 if total_minutes > 0 else 0.0 avg_session_length = total_minutes / total_sessions if total_sessions > 0 else 0.0 # Group sessions by month sessions_by_month = {} for session in sessions: if session.date_created: try: # Extract year-month from date string date_part = session.date_created[:7] # "2025-08" sessions_by_month[date_part] = sessions_by_month.get(date_part, 0) + 1 except: pass # For more detailed stats, we'd need to analyze all tracks # This is a basic implementation return HistoryStats( total_sessions=total_sessions, total_tracks_played=total_tracks_played, total_hours_played=round(total_hours_played, 1), sessions_by_month=sessions_by_month, avg_session_length=round(avg_session_length, 1), favorite_genres=[], # Would require analyzing all session tracks most_played_track=None # Would require counting track occurrences ) except Exception as e: logger.error(f"Failed to get history stats: {e}") return HistoryStats()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/davehenke/rekordbox-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server