add_to_queue
Add tracks to your Spotify playback queue for immediate or upcoming listening. Queue songs during events, build dynamic playlists, add discovery tracks without interrupting current playback, or create collaborative listening sessions.
Instructions
Add a specific track to the user's playback queue for immediate or upcoming playback.
π― USE CASES: β’ Queue up requested songs during parties or events β’ Build dynamic playlists on-the-fly based on mood β’ Add discovery tracks without interrupting current playlist β’ Create collaborative queuing for shared listening sessions β’ Implement "play this next" functionality
π WHAT IT RETURNS: β’ Confirmation that track was added to queue β’ Position of track in the upcoming queue β’ Estimated time until track will play β’ Current queue length and upcoming tracks preview β’ Track information that was successfully queued
π EXAMPLES: β’ "Add 'Bohemian Rhapsody' to my queue" β’ "Queue up the track spotify:track:4uLU6hMCjMI75M1A2tKUQC" β’ "Add this song to play next" β’ "Put 'Sweet Child O Mine' in my queue"
π΅ QUEUE BEHAVIOR: β’ Tracks play in the order they were added β’ Queue plays after current track/playlist ends β’ Maintains queue across device switches β’ Can add multiple tracks for extended queuing β’ Integrates with existing shuffle and repeat settings
β οΈ REQUIREMENTS: β’ Valid Spotify access token with user-modify-playback-state scope β’ Track must be available in user's market β’ Active playback session or available device required
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token | Yes | Spotify access token for authentication | |
| trackUri | Yes | Spotify track URI (e.g., 'spotify:track:4uLU6hMCjMI75M1A2tKUQC') | |
| deviceId | No | Spotify device ID (optional, uses active device if not specified) |
Implementation Reference
- src/mcp/tools/playback.ts:387-390 (handler)MCP tool handler for 'add_to_queue' that validates args and calls SpotifyService.addToQueuehandler: async (args: any, spotifyService: SpotifyService) => { const { token, trackUri, deviceId } = args; return await spotifyService.addToQueue(token, trackUri, deviceId); },
- src/mcp/tools/playback.ts:378-386 (schema)Input schema using Zod for token, trackUri (Spotify track URI), and deviceIdschema: createSchema({ token: commonSchemas.token(), trackUri: z .string() .describe( "Spotify track URI (e.g., 'spotify:track:4uLU6hMCjMI75M1A2tKUQC')" ), deviceId: commonSchemas.deviceId(), }),
- src/mcp/tools/playback.ts:343-391 (registration)Registration of the 'add_to_queue' tool definition within the playbackTools object, including title, description, schema, and handleradd_to_queue: { title: "Add Song to Queue", description: `Add a specific track to the user's playback queue for immediate or upcoming playback. π― USE CASES: β’ Queue up requested songs during parties or events β’ Build dynamic playlists on-the-fly based on mood β’ Add discovery tracks without interrupting current playlist β’ Create collaborative queuing for shared listening sessions β’ Implement "play this next" functionality π WHAT IT RETURNS: β’ Confirmation that track was added to queue β’ Position of track in the upcoming queue β’ Estimated time until track will play β’ Current queue length and upcoming tracks preview β’ Track information that was successfully queued π EXAMPLES: β’ "Add 'Bohemian Rhapsody' to my queue" β’ "Queue up the track spotify:track:4uLU6hMCjMI75M1A2tKUQC" β’ "Add this song to play next" β’ "Put 'Sweet Child O Mine' in my queue" π΅ QUEUE BEHAVIOR: β’ Tracks play in the order they were added β’ Queue plays after current track/playlist ends β’ Maintains queue across device switches β’ Can add multiple tracks for extended queuing β’ Integrates with existing shuffle and repeat settings β οΈ REQUIREMENTS: β’ Valid Spotify access token with user-modify-playback-state scope β’ Track must be available in user's market β’ Active playback session or available device required`, schema: createSchema({ token: commonSchemas.token(), trackUri: z .string() .describe( "Spotify track URI (e.g., 'spotify:track:4uLU6hMCjMI75M1A2tKUQC')" ), deviceId: commonSchemas.deviceId(), }), handler: async (args: any, spotifyService: SpotifyService) => { const { token, trackUri, deviceId } = args; return await spotifyService.addToQueue(token, trackUri, deviceId); }, },
- src/spotify.ts:618-628 (helper)SpotifyService helper method that performs the POST request to Spotify API endpoint /me/player/queue to add the track to queueasync addToQueue( token: string, trackUri: string, deviceId: string | null = null ): Promise<void> { let endpoint = `me/player/queue?uri=${encodeURIComponent(trackUri)}`; if (deviceId) { endpoint += `&device_id=${deviceId}`; } return await this.makeRequest<void>(endpoint, token, {}, "POST"); }