Skip to main content
Glama
davehenke

rekordbox-mcp

get_history_stats

Retrieve comprehensive statistics and trends from DJ history sessions stored in rekordbox databases to analyze performance patterns.

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler for 'get_history_stats': ensures database connection, calls RekordboxDatabase.get_history_stats(), and serializes the result to a dictionary.
    @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()
  • Core implementation of history statistics computation: aggregates data from history sessions including totals, hours played, monthly breakdown, and averages.
    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()
  • Pydantic schema defining the HistoryStats model used for input/output validation and type safety in the get_history_stats 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")
  • FastMCP tool registration decorator that registers the get_history_stats function as an MCP tool.
    @mcp.tool()
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions returning 'statistics about all history sessions including totals and trends', which implies a read-only operation with aggregated data, but lacks details on permissions, rate limits, data freshness, or error handling. This is a significant gap for a tool with no annotation coverage.

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 concise and front-loaded, with the first sentence stating the core purpose and the second providing additional return details. Both sentences earn their place by clarifying scope and output, though it could be slightly more structured (e.g., separating purpose from returns more clearly).

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 complexity (statistical analysis with no parameters) and the presence of an output schema, the description is minimally adequate. It covers what the tool does and hints at the return content, but without annotations and with sibling tools that might overlap, more context on uniqueness or behavioral traits would improve completeness.

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 tool has 0 parameters, and schema description coverage is 100%, so no parameter documentation is needed. The description doesn't add parameter-specific information, but with no parameters, a baseline of 4 is appropriate as there's nothing to compensate for.

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 with a specific verb ('Get') and resource ('comprehensive statistics about DJ history sessions'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'get_history_sessions' or 'get_recent_sessions', which prevents a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives. With sibling tools like 'get_history_sessions', 'get_recent_sessions', and 'search_history_sessions' available, there's no indication of whether this tool is for aggregated data, specific timeframes, or other contexts, leaving usage unclear.

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