Skip to main content
Glama
davehenke

rekordbox-mcp

get_library_stats

Retrieve comprehensive statistics from your rekordbox DJ library to analyze track counts, playlist data, and session history for better music management.

Instructions

Get comprehensive library statistics.

Returns: Dictionary containing various library statistics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler for 'get_library_stats'. Decorated with @mcp.tool() for registration. Delegates to database helper and returns stats.
    @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
  • Database class method that implements the core logic for computing library statistics including track count, playtime, BPM, and genre distribution.
    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"
        }

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