Skip to main content
Glama

add_to_playlist

Add tracks to Spotify playlists for music curation, playlist growth, and collaborative music sharing. Supports single or multiple track additions to owned or collaborative playlists.

Instructions

Add one or more tracks to any existing playlist that the user owns or can modify.

🎯 USE CASES: • Build and curate playlist collections with discovered music • Add recommended tracks from discovery algorithms • Collaborate on shared playlists with friends • Create themed collections by adding related songs • Maintain dynamic playlists that evolve with listening habits

📝 WHAT IT RETURNS: • Confirmation of successful track additions • Updated playlist length and total duration • New track positions within the playlist • Snapshot ID for tracking playlist changes • Error details for any tracks that couldn't be added

🔍 EXAMPLES: • "Add 'Bohemian Rhapsody' to my Rock Classics playlist" • "Put these 5 songs into my workout playlist" • "Add track spotify:track:4uLU6hMCjMI75M1A2tKUQC to favorites" • "Include all these discovered songs in my new releases list"

🎵 ADDITION FEATURES: • Add single tracks or multiple tracks at once • Tracks appear at the end of existing playlist • Maintains playlist order and structure • Supports bulk additions for efficiency • Perfect for playlist curation and growth

💡 CURATION TIPS: • Add tracks that fit the playlist theme or mood • Consider track flow and transitions • Test songs before adding to public playlists • Use bulk additions for efficiency • Regular playlist maintenance keeps content fresh

⚠️ REQUIREMENTS: • Valid Spotify access token with playlist-modify scopes • User must own playlist or have collaborative access • Tracks must be available in user's market

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tokenYesSpotify access token for authentication
playlistIdYesSpotify playlist ID or URI
trackUrisYesArray of Spotify track URIs

Implementation Reference

  • The handler function that executes the tool logic by calling SpotifyService.addTracksToPlaylist with the provided arguments.
    handler: async (args: any, spotifyService: SpotifyService) => {
      const { token, playlistId, trackUris } = args;
      return await spotifyService.addTracksToPlaylist(
        token,
        playlistId,
        trackUris
      );
    },
  • The input schema defining parameters: token, playlistId, and trackUris.
    schema: createSchema({
      token: commonSchemas.token(),
      playlistId: commonSchemas.spotifyId("playlist"),
      trackUris: commonSchemas.trackUris(),
    }),
  • The tool definition object for 'add_to_playlist' exported as part of playlistTools, which is included in allTools.
      add_to_playlist: {
        title: "Add Tracks to Playlist",
        description: `Add one or more tracks to any existing playlist that the user owns or can modify.
    
    🎯 USE CASES:
    • Build and curate playlist collections with discovered music
    • Add recommended tracks from discovery algorithms
    • Collaborate on shared playlists with friends
    • Create themed collections by adding related songs
    • Maintain dynamic playlists that evolve with listening habits
    
    📝 WHAT IT RETURNS:
    • Confirmation of successful track additions
    • Updated playlist length and total duration
    • New track positions within the playlist
    • Snapshot ID for tracking playlist changes
    • Error details for any tracks that couldn't be added
    
    🔍 EXAMPLES:
    • "Add 'Bohemian Rhapsody' to my Rock Classics playlist"
    • "Put these 5 songs into my workout playlist"
    • "Add track spotify:track:4uLU6hMCjMI75M1A2tKUQC to favorites"
    • "Include all these discovered songs in my new releases list"
    
    🎵 ADDITION FEATURES:
    • Add single tracks or multiple tracks at once
    • Tracks appear at the end of existing playlist
    • Maintains playlist order and structure
    • Supports bulk additions for efficiency
    • Perfect for playlist curation and growth
    
    💡 CURATION TIPS:
    • Add tracks that fit the playlist theme or mood
    • Consider track flow and transitions
    • Test songs before adding to public playlists
    • Use bulk additions for efficiency
    • Regular playlist maintenance keeps content fresh
    
    ⚠️ REQUIREMENTS:
    • Valid Spotify access token with playlist-modify scopes
    • User must own playlist or have collaborative access
    • Tracks must be available in user's market`,
        schema: createSchema({
          token: commonSchemas.token(),
          playlistId: commonSchemas.spotifyId("playlist"),
          trackUris: commonSchemas.trackUris(),
        }),
        handler: async (args: any, spotifyService: SpotifyService) => {
          const { token, playlistId, trackUris } = args;
          return await spotifyService.addTracksToPlaylist(
            token,
            playlistId,
            trackUris
          );
        },
      },
  • The SpotifyService method that makes the POST request to Spotify API to add tracks to the specified playlist.
    async addTracksToPlaylist(
      token: string,
      playlistId: string,
      trackUris: string | string[]
    ): Promise<{ snapshot_id: string }> {
      const id = this.extractId(playlistId);
      const data = {
        uris: Array.isArray(trackUris) ? trackUris : [trackUris],
      };
      return await this.makeRequest<{ snapshot_id: string }>(
        `playlists/${id}/tracks`,
        token,
        {},
        "POST",
        data
      );
    }
  • Aggregation of all tools including playlistTools (containing add_to_playlist) into allTools used by ToolRegistrar for MCP registration.
    export const allTools: ToolsRegistry = {
      ...albumTools,
    
      ...artistTools,
    
      ...trackTools,
    
      ...playlistTools,
    
      ...playbackTools,
    
      ...userTools,
    
      ...searchTools,
    };
Behavior5/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 thoroughly describes behavioral traits: it returns confirmation, updated playlist details, and error information; adds tracks to the end of playlists; supports bulk additions; and outlines prerequisites like authentication and access rights. This covers mutation effects, output format, and operational constraints effectively.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is structured with clear sections (USE CASES, WHAT IT RETURNS, etc.), which aids readability. However, it is overly verbose with repetitive or tangential content (e.g., 'CURATION TIPS' and 'ADDITION FEATURES' include non-essential advice like 'Test songs before adding'), reducing efficiency. Some sentences do not earn their place for core tool understanding.

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

Completeness4/5

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

Given no annotations and no output schema, the description compensates well by detailing return values (confirmation, playlist updates, errors) and behavioral aspects. It covers authentication needs, access requirements, and market restrictions. However, it could be more concise and lacks sibling tool differentiation, slightly impacting completeness for a mutation tool with rich context.

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?

Schema description coverage is 100%, with parameters 'token', 'playlistId', and 'trackUris' well-documented in the schema. The description adds minimal extra semantics (e.g., 'Spotify access token' and 'Spotify playlist ID or URI' are restated), but it implies usage context through examples and requirements. This meets the baseline for high schema coverage without significant enhancement.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool adds tracks to existing playlists, specifying 'one or more tracks' and 'any existing playlist that the user owns or can modify.' It distinguishes from sibling tools like 'create_playlist' (which creates new playlists) and 'remove_from_playlist' (which removes tracks), making the purpose specific and differentiated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool through 'USE CASES' (e.g., building playlists, adding recommended tracks) and 'REQUIREMENTS' (e.g., valid Spotify token, user ownership/access). However, it lacks explicit guidance on when not to use it or direct alternatives (e.g., vs. 'add_to_queue' for immediate playback), though the use cases imply curation scenarios.

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/latiftplgu/Spotify-OAuth-MCP-server'

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