Skip to main content
Glama

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); });

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