Skip to main content
Glama
davehenke

rekordbox-mcp

analyze_library

Analyze your rekordbox library by grouping tracks and aggregating data to identify patterns in genres, artists, years, keys, or ratings.

Instructions

Analyze library with grouping and aggregation.

Args: group_by: Field to group by (genre, key, year, artist, rating) aggregate_by: Aggregation method (count, playCount, totalTime) top_n: Number of top results to return

Returns: Analysis results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
group_byNogenre
aggregate_byNocount
top_nNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registration and handler for the 'analyze_library' MCP tool. Decorated with @mcp.tool(), defines input parameters via type hints, and delegates execution to RekordboxDatabase.analyze_library.
    @mcp.tool()
    async def analyze_library(
        group_by: str = "genre",
        aggregate_by: str = "count",
        top_n: int = 10
    ) -> Dict[str, Any]:
        """
        Analyze library with grouping and aggregation.
        
        Args:
            group_by: Field to group by (genre, key, year, artist, rating)
            aggregate_by: Aggregation method (count, playCount, totalTime)
            top_n: Number of top results to return
            
        Returns:
            Analysis results
        """
        if not db:
            raise RuntimeError("Database not initialized.")
        
        analysis = await db.analyze_library(group_by, aggregate_by, top_n)
        return analysis
  • Core implementation of library analysis: loads all active tracks, groups by specified field (genre, key, etc.), aggregates count/playCount/totalTime, sorts top N by aggregate, returns structured results.
    async def analyze_library(self, group_by: str, aggregate_by: str, top_n: int) -> Dict[str, Any]:
        """Analyze library with grouping and aggregation."""
        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]
        groups = {}
        
        for content in active_content:
            # Get grouping key
            if group_by == "genre":
                key = getattr(content, 'GenreName', '') or "Unknown"
            elif group_by == "key":
                key = getattr(content, 'KeyName', '') or "Unknown"
            elif group_by == "year":
                key = str(getattr(content, 'ReleaseYear', '') or "Unknown")
            elif group_by == "artist":
                key = getattr(content, 'ArtistName', '') or "Unknown"
            elif group_by == "rating":
                key = str(getattr(content, 'Rating', 0) or 0)
            else:
                key = "Unknown"
            
            if key not in groups:
                groups[key] = {"count": 0, "playCount": 0, "totalTime": 0}
            
            groups[key]["count"] += 1
            groups[key]["playCount"] += getattr(content, 'DJPlayCount', 0) or 0
            groups[key]["totalTime"] += getattr(content, 'Length', 0) or 0
        
        # Sort by the requested aggregation
        sorted_groups = sorted(groups.items(), key=lambda x: x[1][aggregate_by], reverse=True)
        
        return {
            "group_by": group_by,
            "aggregate_by": aggregate_by,
            "results": dict(sorted_groups[:top_n]),
            "total_groups": len(groups)
        }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions grouping/aggregation but doesn't specify whether this is a read-only operation (likely, but not stated), what permissions are required, whether it's resource-intensive, or how results are formatted beyond 'Analysis results.' The description lacks crucial behavioral context for a tool with three parameters.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and well-structured. The first sentence states the core purpose, followed by clear sections for Args and Returns. Each section is concise and informative without unnecessary elaboration. Every sentence earns its place, though the Returns section could be slightly more specific.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, grouping/aggregation logic) and the presence of an output schema (which handles return values), the description is minimally adequate. However, with no annotations and incomplete behavioral context, it leaves gaps about operation characteristics. The parameter explanations help, but overall completeness is limited.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant value beyond the input schema, which has 0% description coverage. It explains the meaning of all three parameters: 'group_by' (with specific field examples), 'aggregate_by' (with method examples), and 'top_n' (purpose). This compensates well for the schema's lack of descriptions, though it doesn't provide format details or constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Analyze library with grouping and aggregation.' This specifies the verb ('analyze'), resource ('library'), and core functionality. It distinguishes from siblings like 'get_library_stats' or 'get_most_played_tracks' by emphasizing grouping/aggregation analysis rather than basic retrieval.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention when this analysis is appropriate compared to sibling tools like 'get_library_stats' (which might provide summary statistics) or 'get_most_played_tracks' (which might focus on specific metrics). There's no context about prerequisites or typical use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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