addToQueue
Add tracks, albums, artists, or playlists to your Spotify playback queue using Spotify URIs or IDs. Control playback by specifying device targets.
Instructions
Adds a track, album, artist or playlist to the playback queue
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uri | No | The Spotify URI to play (overrides type and id) | |
| type | No | The type of item to play | |
| id | No | The Spotify ID of the item to play | |
| deviceId | No | The Spotify device ID to add the track to |
Implementation Reference
- src/play.ts:324-359 (handler)Handler function that destructures args, constructs Spotify URI from type/id if uri not provided, validates presence of uri, uses handleSpotifyRequest to call Spotify API's addItemToPlaybackQueue, and returns 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:309-323 (schema)Zod input schema for addToQueue tool defining optional parameters: uri (Spotify URI), type (track/album/artist/playlist), id (Spotify ID), deviceId (target device).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/index.ts:12-14 (registration)Registers all tools from readTools, playTools (which includes addToQueue), and albumTools by spreading the arrays and calling server.tool() with name, description, schema, and handler for each.[...readTools, ...playTools, ...albumTools].forEach((tool) => { server.tool(tool.name, tool.description, tool.schema, tool.handler); });