Skip to main content
Glama
marcelmarais

Spotify MCP Server

by marcelmarais

addToQueue

Add tracks, albums, artists, or playlists to your Spotify playback queue using Spotify URIs or IDs. Control playback by specifying target devices.

Instructions

Adds a track, album, artist or playlist to the playback queue

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uriNoThe Spotify URI to play (overrides type and id)
typeNoThe type of item to play
idNoThe Spotify ID of the item to play
deviceIdNoThe Spotify device ID to add the track to

Implementation Reference

  • The handler function for the 'addToQueue' tool. Parses arguments to construct a Spotify URI, validates input, adds the item to the playback queue using the Spotify API via handleSpotifyRequest, and returns a success message.
    handler: async (args) => {
      const { uri, type, id, deviceId } = args;
    
      let spotifyUri = uri;
      if (!spotifyUri && type && id) {
        spotifyUri = `spotify:${type}:${id}`;
      }
    
      if (!spotifyUri) {
        return {
          content: [
            {
              type: 'text',
              text: 'Error: Must provide either a URI or both a type and ID',
              isError: true,
            },
          ],
        };
      }
    
      await handleSpotifyRequest(async (spotifyApi) => {
        await spotifyApi.player.addItemToPlaybackQueue(
          spotifyUri,
          deviceId || '',
        );
      });
    
      return {
        content: [
          {
            type: 'text',
            text: `Added item ${spotifyUri} to queue`,
          },
        ],
      };
    },
  • Tool name, description, and Zod input schema definition for 'addToQueue', supporting uri, type/id, or deviceId parameters.
    name: 'addToQueue',
    description: 'Adds a track, album, artist or playlist to the playback queue',
    schema: {
      uri: z
        .string()
        .optional()
        .describe('The Spotify URI to play (overrides type and id)'),
      type: z
        .enum(['track', 'album', 'artist', 'playlist'])
        .optional()
        .describe('The type of item to play'),
      id: z.string().optional().describe('The Spotify ID of the item to play'),
      deviceId: z
        .string()
        .optional()
        .describe('The Spotify device ID to add the track to'),
    },
  • src/play.ts:499-510 (registration)
    'addToQueue' is registered by inclusion in the exported 'playTools' array of Spotify playback tools.
    export const playTools = [
      playMusic,
      pausePlayback,
      skipToNext,
      skipToPrevious,
      createPlaylist,
      addTracksToPlaylist,
      resumePlayback,
      addToQueue,
      setVolume,
      adjustVolume,
    ];
  • src/index.ts:12-14 (registration)
    Final registration of all tools including 'playTools' (with 'addToQueue') to the MCP server using server.tool().
    [...readTools, ...playTools, ...albumTools].forEach((tool) => {
      server.tool(tool.name, tool.description, tool.schema, tool.handler);
    });
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 states the action ('adds') but lacks details on permissions, side effects (e.g., whether it affects current playback), rate limits, or error handling. This is a significant gap for a mutation tool without annotation support.

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 directly states the tool's function without unnecessary words. It is front-loaded with the core action and resources, making it easy to parse quickly.

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?

Given the tool's complexity as a mutation operation with no annotations and no output schema, the description is incomplete. It fails to address behavioral aspects like success/failure responses, interaction with other playback tools, or device requirements, leaving the agent with insufficient context for reliable use.

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 schema description coverage is 100%, so the input schema already documents all parameters thoroughly. The description adds no additional semantic context beyond implying that 'uri' can override 'type' and 'id', which is already covered in the schema. 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 verb ('adds') and the resources ('track, album, artist or playlist') along with the target ('playback queue'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'playMusic' or 'getQueue', which might handle similar media operations but with different functions.

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, such as 'playMusic' for immediate playback or 'getQueue' for viewing the queue. There's no mention of prerequisites, exclusions, or contextual cues, leaving usage decisions ambiguous for the agent.

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

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