Skip to main content
Glama
davehenke

rekordbox-mcp

get_session_tracks

Retrieve all tracks from a specific DJ history session in rekordbox, including performance context, by providing the session identifier.

Instructions

Get all tracks from a specific DJ history session.

Args: session_id: The session's unique identifier

Returns: List of tracks in the session with performance context

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Registration and handler for the MCP tool 'get_session_tracks'. This function is decorated with @mcp.tool(), making it the entry point for the tool. It ensures the database is connected, delegates to the database layer, and serializes the results to dictionaries.
    @mcp.tool()
    async def get_session_tracks(session_id: str) -> List[Dict[str, Any]]:
        """
        Get all tracks from a specific DJ history session.
        
        Args:
            session_id: The session's unique identifier
            
        Returns:
            List of tracks in the session with performance context
        """
        await ensure_database_connected()
        
        tracks = await db.get_session_tracks(session_id)
        return [track.model_dump() for track in tracks]
  • Core implementation of fetching session tracks from the rekordbox database using pyrekordbox. Queries history_songs table, matches with content tracks, constructs HistoryTrack objects preserving play order.
    async def get_session_tracks(self, session_id: str) -> List[HistoryTrack]:
        """
        Get all tracks from a specific DJ history session.
        
        Args:
            session_id: The session's unique identifier
            
        Returns:
            List of tracks in the session with performance context
        """
        if not self.db:
            raise RuntimeError("Database not connected")
        
        try:
            # Get songs for this session
            history_songs = list(self.db.get_history_songs(HistoryID=int(session_id)))
            active_songs = [s for s in history_songs if getattr(s, 'rb_local_deleted', 0) == 0]
            
            # Get all content to match against
            all_content = list(self.db.get_content())
            active_content = [c for c in all_content if getattr(c, 'rb_local_deleted', 0) == 0]
            content_lookup = {str(c.ID): c for c in active_content}
            
            # Build tracks list maintaining session order
            tracks = []
            sorted_songs = sorted(active_songs, key=lambda x: x.TrackNo)
            
            for song in sorted_songs:
                content_id = str(song.ContentID)
                if content_id in content_lookup:
                    content = content_lookup[content_id]
                    
                    # Extract track info using same logic as _content_to_track
                    bmp_value = getattr(content, 'BPM', 0) or 0
                    bpm_float = float(bmp_value) / 100.0 if bmp_value else 0.0
                    
                    artist_name = getattr(content, 'ArtistName', '') or ""
                    album_name = getattr(content, 'AlbumName', '') or ""
                    genre_name = getattr(content, 'GenreName', '') or ""
                    key_name = getattr(content, 'KeyName', '') or ""
                    
                    tracks.append(HistoryTrack(
                        id=str(content.ID),
                        title=content.Title or "",
                        artist=artist_name,
                        album=album_name,
                        genre=genre_name,
                        bpm=bpm_float,
                        key=key_name,
                        length=int(getattr(content, 'Length', 0) or 0),
                        track_number=song.TrackNo,
                        history_id=session_id,
                        play_order=song.TrackNo
                    ))
            
            return tracks
            
        except Exception as e:
            logger.error(f"Failed to get session tracks for session {session_id}: {e}")
            return []
  • Pydantic model defining the structure of a track within a history session, used for output typing and validation. This serves as the output schema for the tool.
    class HistoryTrack(BaseModel):
        """
        Track within a DJ history session with performance context.
        """
        
        # Track basic info (from Track model)
        id: str = Field(..., description="Track identifier")
        title: str = Field("", description="Track title")
        artist: str = Field("", description="Artist name")
        album: Optional[str] = Field(None, description="Album name")
        genre: Optional[str] = Field(None, description="Genre")
        bpm: float = Field(0.0, ge=0, description="Beats per minute")
        key: Optional[str] = Field(None, description="Musical key")
        length: int = Field(0, ge=0, description="Track length in seconds")
        
        # History-specific context
        track_number: int = Field(..., ge=1, description="Position in DJ set")
        history_id: str = Field(..., description="History session ID")
        play_order: Optional[int] = Field(None, description="Order played in session")
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. It states it 'Get[s] all tracks' and returns a 'List of tracks in the session with performance context,' which hints at read-only behavior and output format. However, it lacks details on permissions, rate limits, pagination, error handling, or what 'performance context' entails (e.g., timestamps, ratings). For a tool with no annotation coverage, this is insufficient.

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 front-loaded with the core purpose in the first sentence, followed by structured 'Args' and 'Returns' sections. It's efficient with no redundant information. However, the 'Args' and 'Returns' formatting, while clear, could be slightly more integrated into a single narrative flow, preventing a perfect 5.

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 has an output schema (which likely defines the return structure), the description doesn't need to detail return values extensively. However, with no annotations and only basic parameter documentation, it lacks completeness for behavioral aspects like error cases or usage constraints. It's adequate but has clear gaps, making it a minimum viable description.

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 meaningful context for the single parameter: 'session_id: The session's unique identifier.' Since schema description coverage is 0% (the schema only has a title 'Session Id'), this compensates well by explaining the parameter's purpose. With 0 parameters, the baseline would be 4, but here it effectively documents the one parameter, earning a 4.

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 verb ('Get') and resource ('all tracks from a specific DJ history session'), making the purpose unambiguous. It distinguishes from siblings like 'get_history_sessions' (which lists sessions) and 'get_track_details' (which gets details for individual tracks). However, it doesn't explicitly differentiate from 'get_playlist_tracks' (which also gets tracks from a collection), so it's not a perfect 5.

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

Usage Guidelines3/5

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

The description implies usage context by specifying 'from a specific DJ history session,' suggesting this is for retrieving tracks associated with a historical session rather than a playlist or other collection. However, it doesn't explicitly state when to use this versus alternatives like 'get_playlist_tracks' or 'get_recent_sessions,' nor does it mention prerequisites or exclusions.

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