Skip to main content
Glama
davehenke

rekordbox-mcp

add_track_to_playlist

Idempotent

Add a track to an existing rekordbox playlist by specifying playlist and track IDs. Modifies the rekordbox database directly.

Instructions

Add a track to an existing playlist.

⚠️ CAUTION: This modifies your rekordbox database!

Args: playlist_id: ID of the playlist to modify track_id: ID of the track to add

Returns: Result of the operation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
playlist_idYes
track_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The @mcp.tool decorator registers the 'add_track_to_playlist' tool with MCP/FastMCP, including annotations for behavior hints.
    @mcp.tool(
        annotations={
            "readOnlyHint": False,
            "destructiveHint": False,
            "idempotentHint": True
        }
    )
  • The primary handler function for the 'add_track_to_playlist' MCP tool. Ensures database connection, calls the database helper, handles errors, and formats the response.
    async def add_track_to_playlist(
        playlist_id: str,
        track_id: str
    ) -> Dict[str, Any]:
        """
        Add a track to an existing playlist.
        
        ⚠️ CAUTION: This modifies your rekordbox database!
        
        Args:
            playlist_id: ID of the playlist to modify
            track_id: ID of the track to add
            
        Returns:
            Result of the operation
        """
        await ensure_database_connected()
        
        try:
            success = await db.add_track_to_playlist(playlist_id, track_id)
            if success:
                return {
                    "status": "success",
                    "message": f"Added track {track_id} to playlist {playlist_id}",
                    "playlist_id": playlist_id,
                    "track_id": track_id
                }
            else:
                return {
                    "status": "error",
                    "message": "Failed to add track to playlist"
                }
        except Exception as e:
            return {
                "status": "error",
                "message": f"Failed to add track to playlist: {str(e)}"
            }
  • The RekordboxDatabase class method that implements the core logic for adding a track to a playlist, including backup, pyrekordbox operations, commit/rollback, and logging.
    async def add_track_to_playlist(self, playlist_id: str, track_id: str) -> bool:
        """
        Add a track to an existing playlist.
        
        Args:
            playlist_id: ID of the playlist
            track_id: ID of the track to add
            
        Returns:
            True if successful
        """
        if not self.db:
            raise RuntimeError("Database not connected")
        
        try:
            # Create backup before mutation
            await self._create_backup()
            
            # Verify playlist and track exist
            playlist_int_id = int(playlist_id)
            track_int_id = int(track_id)
            
            # Add track to playlist using pyrekordbox
            self.db.add_to_playlist(playlist_int_id, track_int_id)
            
            # Commit changes
            self.db.commit()
            
            logger.info(f"Added track {track_id} to playlist {playlist_id}")
            return True
            
        except Exception as e:
            logger.error(f"Failed to add track {track_id} to playlist {playlist_id}: {e}")
            # Rollback on error
            if hasattr(self.db, 'rollback'):
                self.db.rollback()
            raise RuntimeError(f"Failed to add track to playlist: {str(e)}")
Behavior4/5

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

The description adds valuable behavioral context beyond annotations: the CAUTION warning about database modification provides important safety context that annotations don't explicitly cover. Annotations indicate readOnlyHint=false (mutation), idempotentHint=true (safe to retry), and destructiveHint=false (non-destructive), but the description's warning about database modification adds practical implementation awareness.

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 well-structured with clear sections (description, caution, args, returns) and uses only essential sentences. The warning is appropriately placed and formatted. However, the 'Returns' section is redundant given the presence of an output schema, slightly reducing efficiency.

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

Completeness4/5

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

For a mutation tool with good annotations (readOnlyHint=false, idempotentHint=true, destructiveHint=false) and an output schema, the description provides adequate context. The caution warning addresses the key behavioral risk, and parameter documentation covers basics. The main gap is lack of sibling differentiation, but overall it's reasonably complete for this complexity level.

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

Parameters3/5

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

With 0% schema description coverage, the description provides basic parameter documentation in the Args section, explaining what playlist_id and track_id represent. However, it doesn't provide format details, validation rules, or examples that would compensate for the complete lack of schema descriptions. The baseline is 3 since it covers the basic semantics but minimally.

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 action ('Add a track') and target resource ('to an existing playlist'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from its sibling 'add_tracks_to_playlist' (singular vs. plural), which could cause confusion about when to use each tool.

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 like 'add_tracks_to_playlist' or 'create_playlist'. It mentions the tool modifies 'an existing playlist' but doesn't specify prerequisites, constraints, or when other tools might be more appropriate.

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