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
| Name | Required | Description | Default |
|---|---|---|---|
| deviceId | No | The Spotify device ID to add the track to | |
| id | No | The Spotify ID of the item to play | |
| type | No | The type of item to play | |
| uri | No | The 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
- src/play.ts:324-359 (handler)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`, }, ], }; },
- src/play.ts:307-323 (schema)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); });