Skip to main content
Glama

add_track_to_playlist

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

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)}")

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