get_top_rated_tracks
Retrieve a list of the highest-rated tracks from your rekordbox library, customizable by limit for efficient track selection and management.
Instructions
Get the highest rated tracks in the library.
Args: limit: Maximum number of tracks to return
Returns: List of top rated tracks
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No |
Implementation Reference
- rekordbox_mcp/server.py:169-184 (handler)MCP tool handler for 'get_top_rated_tracks', registered via @mcp.tool() decorator. Fetches top rated tracks from database and serializes to dicts for MCP response.@mcp.tool() async def get_top_rated_tracks(limit: int = 20) -> List[Dict[str, Any]]: """ Get the highest rated tracks in the library. Args: limit: Maximum number of tracks to return Returns: List of top rated tracks """ if not db: raise RuntimeError("Database not initialized.") tracks = await db.get_top_rated_tracks(limit) return [track.model_dump() for track in tracks]
- rekordbox_mcp/database.py:322-332 (helper)Database class helper method implementing the core logic: retrieves all active tracks, sorts by rating (desc) then DJPlayCount (desc), limits to N, converts to Track models.async def get_top_rated_tracks(self, limit: int = 20) -> List[Track]: """Get the highest rated tracks.""" 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] # Sort by rating descending, then by play count sorted_content = sorted(active_content, key=lambda x: (getattr(x, 'Rating', 0) or 0, getattr(x, 'DJPlayCount', 0) or 0), reverse=True) return [self._content_to_track(content) for content in sorted_content[:limit]]