addToQueue
Adds Spotify tracks, albums, artists, or playlists to your current playback queue. Specify the item by URI, type and ID, or target a specific device.
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/write.ts:138-173 (handler)The handler function that validates input, constructs Spotify URI if needed, and adds the item to the playback queue using Spotify API.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/write.ts:123-137 (schema)Zod schema for input parameters: uri (optional Spotify URI), type (optional enum), id (optional ID), deviceId (optional).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)Dynamic registration of all tools (including addToQueue via writeTools) to the MCP server by calling server.tool() for each tool object.[...playTools, ...readTools, ...writeTools].forEach((tool) => { server.tool(tool.name, tool.description, tool.schema, tool.handler); });
- src/write.ts:238-243 (registration)The addToQueue tool is included in the writeTools array, which is imported and registered in src/index.ts.export const writeTools = [ addToQueue, addTracksToPlaylist, createPlaylist, removeTracksFromPlaylist, ];