Skip to main content
Glama

add_to_queue

Add a specific track to the playback queue for immediate or upcoming playback, enabling dynamic playlist building, collaborative listening, or "play this next" functionality. Returns queue position, track details, and estimated play time.

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

TableJSON Schema
NameRequiredDescriptionDefault
deviceIdNoSpotify device ID (optional, uses active device if not specified)
tokenYesSpotify access token for authentication
trackUriYesSpotify track URI (e.g., 'spotify:track:4uLU6hMCjMI75M1A2tKUQC')

Implementation Reference

  • MCP tool handler for 'add_to_queue' that delegates to SpotifyService.addToQueue
    handler: async (args: any, spotifyService: SpotifyService) => { const { token, trackUri, deviceId } = args; return await spotifyService.addToQueue(token, trackUri, deviceId); },
  • Input schema validation for add_to_queue tool using Zod
    schema: createSchema({ token: commonSchemas.token(), trackUri: z .string() .describe( "Spotify track URI (e.g., 'spotify:track:4uLU6hMCjMI75M1A2tKUQC')" ), deviceId: commonSchemas.deviceId(), }),
  • Registration of playbackTools (containing add_to_queue) into the central allTools registry used by ToolRegistrar
    export const allTools: ToolsRegistry = { ...albumTools, ...artistTools, ...trackTools, ...playlistTools, ...playbackTools, ...userTools, ...searchTools, };
  • Core implementation in SpotifyService that performs the API POST request to add track to queue
    async 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"); }

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/latiftplgu/Spotify-OAuth-MCP-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server