Skip to main content
Glama
jamiew

Spotify MCP Server

add_tracks_to_playlist

Add multiple songs to a Spotify playlist using track URIs. Specify playlist ID and up to 100 track URIs to expand your music collection.

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'add_tracks_to_playlist' tool. It is registered via the @mcp.tool() decorator and implements adding tracks to a Spotify playlist by converting IDs to URIs if necessary and calling the Spotify API's playlist_add_items method. Includes logging and proper error handling.
    @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
  • The @mcp.tool() decorator registers the add_tracks_to_playlist function as an MCP tool in the FastMCP server.
    @mcp.tool()
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the action 'Add tracks' but fails to cover critical aspects like authentication requirements, rate limits, error handling, or whether the operation is idempotent. This leaves significant gaps in understanding the tool's behavior.

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 parameter details in a structured 'Args:' section. It avoids unnecessary words, though the parameter explanations could be slightly more detailed without sacrificing brevity.

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's moderate complexity (2 parameters, no annotations, but with an output schema), the description is minimally adequate. It covers the basic action and parameters but lacks behavioral context and usage guidelines. The presence of an output schema reduces the need to describe return values, but overall completeness is limited.

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?

The description adds basic semantics by naming the parameters and noting the limit 'up to 100' for track_uris, which is not in the schema (0% coverage). However, it does not explain the format of 'playlist_id' or 'track_uris' (e.g., URI structure), leaving some ambiguity. Given the low schema coverage, this partial compensation results in a baseline score.

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 'Add' and the resource 'tracks to a playlist', making the purpose specific and understandable. However, it does not explicitly differentiate from sibling tools like 'add_to_queue' or 'modify_playlist_details', which could cause confusion in selection.

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?

No guidance is provided on when to use this tool versus alternatives such as 'add_to_queue' or 'modify_playlist_details'. The description lacks context about prerequisites or scenarios, leaving the agent to infer usage based on tool names alone.

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

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