add_tracks_to_playlist
Enhance your Spotify playlists by adding up to 100 tracks using the specified track URIs. Simplify playlist management directly through the Spotify MCP Server integration.
Instructions
Add tracks to a playlist.
Args:
playlist_id: Playlist ID
track_uris: List of track URIs (up to 100)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| playlist_id | Yes | ||
| track_uris | Yes |
Implementation Reference
- The core handler function decorated with @mcp.tool() for FastMCP registration. Converts track IDs to URIs if necessary and uses Spotify API to add tracks to the specified playlist. Includes error handling with custom Spotify error conversion.@mcp.tool() @log_tool_execution def add_tracks_to_playlist(playlist_id: str, track_uris: list[str]) -> dict[str, str]: """Add tracks to a playlist. Args: playlist_id: Playlist ID track_uris: List of track URIs (up to 100) """ try: # Convert track IDs to URIs if needed uris = [ uri if uri.startswith("spotify:track:") else f"spotify:track:{uri}" for uri in track_uris ] logger.info(f"🎧 Adding {len(uris)} tracks to playlist {playlist_id}") spotify_client.playlist_add_items(playlist_id, uris) return {"status": "success", "message": f"Added {len(uris)} tracks to playlist"} except SpotifyException as e: raise convert_spotify_error(e) from e
- src/spotify_mcp/fastmcp_server.py:462-462 (registration)FastMCP tool registration decorator applied to the add_tracks_to_playlist handler function.@mcp.tool()