Skip to main content
Glama

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
NameRequiredDescriptionDefault
playlist_idYes
track_urisYes

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
  • FastMCP tool registration decorator applied to the add_tracks_to_playlist handler function.
    @mcp.tool()

Other Tools

Related 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/jamiew/spotify-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server