Skip to main content
Glama
superseoworld

MCP Spotify Server

add_tracks_to_playlist

Add tracks to a Spotify playlist using track URIs and specify playlist ID. Insert tracks at a specific position if needed.

Instructions

Add one or more tracks to a playlist

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe Spotify ID or URI of the playlist
urisYesArray of Spotify track URIs to add
positionNoOptional. The position to insert the tracks (zero-based)

Implementation Reference

  • The core handler function implementing add_tracks_to_playlist by extracting playlist ID, preparing data with URIs and optional position, and making a POST request to Spotify API endpoint /playlists/{id}/tracks.
    async addTracksToPlaylist(args: AddTracksToPlaylistArgs) {
      const playlistId = this.extractPlaylistId(args.id);
      const { uris, position } = args;
    
      const data = {
        uris,
        ...(position !== undefined && { position })
      };
    
      return this.api.makeRequest(
        `/playlists/${playlistId}/tracks`,
        'POST',
        data
      );
    }
  • TypeScript interface defining the input parameters for the addTracksToPlaylist handler: playlist ID, array of track URIs, and optional insert position.
    export interface AddTracksToPlaylistArgs {
      id: string;
      uris: string[];
      position?: number;
    }
  • src/index.ts:557-580 (registration)
    MCP tool registration in listTools response, defining the name, description, and inputSchema matching the handler args.
    {
      name: 'add_tracks_to_playlist',
      description: 'Add one or more tracks to a playlist',
      inputSchema: {
        type: 'object',
        properties: {
          id: {
            type: 'string',
            description: 'The Spotify ID or URI of the playlist'
          },
          uris: {
            type: 'array',
            items: { type: 'string' },
            description: 'Array of Spotify track URIs to add'
          },
          position: {
            type: 'number',
            description: 'Optional. The position to insert the tracks (zero-based)',
            minimum: 0
          }
        },
        required: ['id', 'uris']
      },
    },
  • src/index.ts:861-867 (registration)
    Dispatch logic in the main CallToolRequest handler switch statement: validates required args and delegates to playlistsHandler.addTracksToPlaylist
    case 'add_tracks_to_playlist': {
      const args = this.validateArgs<AddTracksToPlaylistArgs>(request.params.arguments, ['id', 'uris']);
      const result = await this.playlistsHandler.addTracksToPlaylist(args);
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • Helper method used by addTracksToPlaylist (and others) to normalize playlist ID from Spotify URI or plain ID.
    private extractPlaylistId(id: string): string {
      return id.startsWith('spotify:playlist:') ? id.split(':')[2] : id;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'add' implies a write operation, the description doesn't mention authentication requirements, rate limits, error conditions, or what happens when tracks already exist in the playlist. This leaves significant behavioral gaps.

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

Conciseness5/5

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

The description is a single, efficient sentence that communicates the core functionality without any wasted words. It's appropriately sized for a straightforward tool and gets directly to the point.

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 no annotations and no output schema, the description is insufficient. It doesn't explain what the tool returns, error conditions, authentication requirements, or how it differs from similar tools. Given the complexity of modifying Spotify playlists, more context is needed.

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?

With 100% schema description coverage, the schema already documents all three parameters thoroughly. The description mentions 'one or more tracks' which aligns with the 'uris' array parameter, but adds no additional semantic context beyond what the schema provides. This meets the baseline for high schema coverage.

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') and resources ('one or more tracks to a playlist'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'modify_playlist' or 'remove_tracks_from_playlist', but the verb 'add' provides reasonable distinction.

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 like 'modify_playlist' or 'remove_tracks_from_playlist'. There's no mention of prerequisites, constraints, or typical use cases beyond the basic action.

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

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