get_library_stats
Retrieve detailed statistics for your rekordbox music library, including track counts, playlist data, and session history, using the MCP server query tool.
Instructions
Get comprehensive library statistics.
Returns: Dictionary containing various library statistics
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- rekordbox_mcp/server.py:322-335 (handler)The MCP tool handler function for 'get_library_stats', decorated with @mcp.tool(). It checks database connection and delegates to the RekordboxDatabase.get_library_stats() method.@mcp.tool() async def get_library_stats() -> Dict[str, Any]: """ Get comprehensive library statistics. Returns: Dictionary containing various library statistics """ if not db: raise RuntimeError("Database not initialized.") stats = await db.get_library_stats() return stats
- rekordbox_mcp/database.py:430-461 (helper)The supporting method in RekordboxDatabase class that computes and returns comprehensive library statistics including total tracks, playtime, average BPM, and top genres.async def get_library_stats(self) -> Dict[str, Any]: """ Get comprehensive library statistics. Returns: Dictionary containing various statistics """ if not self.db: raise RuntimeError("Database not connected") all_content = list(self.db.get_content()) active_content = [c for c in all_content if getattr(c, 'rb_local_deleted', 0) == 0] # Calculate statistics total_tracks = len(active_content) total_playtime = sum(getattr(c, 'Length', 0) or 0 for c in active_content) avg_bpm = sum((getattr(c, 'BPM', 0) or 0) / 100.0 for c in active_content) / total_tracks if total_tracks > 0 else 0 # Genre distribution genres = {} for content in active_content: genre = getattr(content, 'GenreName', '') or "Unknown" genres[genre] = genres.get(genre, 0) + 1 return { "total_tracks": total_tracks, "total_playtime_seconds": total_playtime, "average_bpm": round(avg_bpm, 2), "genre_distribution": dict(sorted(genres.items(), key=lambda x: x[1], reverse=True)[:10]), "database_path": str(self.database_path), "connection_status": "connected" }