Skip to main content
Glama

add_to_playlist

Add tracks to a Spotify playlist by providing the playlist ID and track IDs. This tool enables playlist management through the Spotify MCP server.

Instructions

Add tracks to a playlist
Args:
    playlist_id: Spotify playlist ID
    track_ids: List of track IDs to add

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
playlist_idYes
track_idsYes

Implementation Reference

  • main.py:188-196 (handler)
    MCP tool handler and registration for add_to_playlist. This is the entrypoint function executed when the tool is called, delegating to the SpotifyClient.
    @mcp.tool()
    async def add_to_playlist(playlist_id: str, track_ids: list[str]) -> str:
        """
        Add tracks to a playlist
        Args:
            playlist_id: Spotify playlist ID
            track_ids: List of track IDs to add
        """
        return await client.add_to_playlist(playlist_id, track_ids)
  • Core helper function in SpotifyClient that implements the logic: converts track IDs to Spotify URIs and adds items to the playlist using spotipy.Spotify.playlist_add_items.
    async def add_to_playlist(self, playlist_id: str, track_ids: list[str]) -> str:
        """
        Add tracks to a playlist
        - playlist_id: Spotify playlist ID
        - track_ids: List of track IDs to add
        """
        try:
            # Convert track IDs to full URIs
            track_uris = [f"spotify:track:{track_id}" for track_id in track_ids]
            self.sp.playlist_add_items(playlist_id, track_uris)
            return "Tracks added to playlist successfully"
        except Exception as e:
            return f"Error adding tracks to playlist: {str(e)}"
  • main.py:5-5 (helper)
    Instantiation of the global SpotifyClient instance used by all tool handlers.
    client = SpotifyClient()
  • main.py:4-4 (registration)
    Initialization of the FastMCP server instance where tools are registered.
    mcp = FastMCP("spotify")
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It states the action ('Add tracks') but doesn't disclose critical behaviors: whether this requires specific permissions, if there are rate limits, how duplicates are handled, or what happens on success/failure. For a mutation tool with zero annotation coverage, this is inadequate.

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 brief and front-loaded with the core purpose in the first sentence. The 'Args' section is efficiently structured. However, the second sentence ('Args:...') could be integrated more smoothly, and there's room to add crucial behavioral details without sacrificing conciseness.

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

Completeness2/5

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

For a mutation tool with 2 parameters, 0% schema coverage, no annotations, and no output schema, the description is incomplete. It lacks essential context: error handling, return values, permissions needed, rate limits, and differentiation from sibling tools. The agent would struggle to use this tool correctly without additional information.

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 includes an 'Args' section that names both parameters ('playlist_id', 'track_ids') and provides basic semantic context (e.g., 'Spotify playlist ID'). However, with 0% schema description coverage, it doesn't fully compensate by explaining format requirements (e.g., URI vs ID), constraints (max tracks per call), or examples. The baseline is 3 since it adds some meaning beyond the bare schema.

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 tracks to') and resource ('a playlist'), making the purpose immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'add_to_queue' or 'reorder_queue', which also involve adding/managing tracks in different contexts.

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. It doesn't mention prerequisites (like needing playlist ownership or Spotify Premium), nor does it contrast with similar tools like 'add_to_queue' (for immediate playback) or 'start_playlist_playback' (for playing entire playlists).

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

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