Skip to main content
Glama

addToQueue

Add tracks, albums, artists, or playlists to Spotify playback queues using Spotify URIs, IDs, or device-specific commands. Enables precise music control via supported AI assistants.

Instructions

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

Input Schema

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

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "deviceId": { "description": "The Spotify device ID to add the track to", "type": "string" }, "id": { "description": "The Spotify ID of the item to play", "type": "string" }, "type": { "description": "The type of item to play", "enum": [ "track", "album", "artist", "playlist" ], "type": "string" }, "uri": { "description": "The Spotify URI to play (overrides type and id)", "type": "string" } }, "type": "object" }

Implementation Reference

  • The asynchronous handler function for the 'addToQueue' tool. It destructures arguments, constructs the Spotify URI if needed, validates presence, calls handleSpotifyRequest to add the item to the playback queue using SpotifyApi.player.addItemToPlaybackQueue, 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`, }, ], }; },
  • Zod schema definition for the 'addToQueue' tool inputs: optional uri (string), type (enum: track/album/artist/playlist), id (string), deviceId (string).
    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:362-371 (registration)
    The 'addToQueue' tool is registered by inclusion in the exported playTools array, which groups Spotify playback-related tools.
    export const playTools = [ playMusic, pausePlayback, skipToNext, skipToPrevious, createPlaylist, addTracksToPlaylist, resumePlayback, addToQueue, ];
  • src/index.ts:12-14 (registration)
    Bulk registration of all tools (including addToQueue via playTools) to the MCP server instance using server.tool() method in a loop.
    [...readTools, ...playTools, ...albumTools].forEach((tool) => { server.tool(tool.name, tool.description, tool.schema, tool.handler); });

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