SpotifyQueue
Control your Spotify playback queue by adding tracks or viewing upcoming songs through the Spotify MCP Server.
Instructions
Manage the playback queue - get the queue or add tracks.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Action to perform: 'add' or 'get'. | |
| track_id | No | Track ID to add to queue (required for add action) |
Implementation Reference
- src/spotify_mcp/server.py:176-207 (handler)Main execution handler for the SpotifyQueue tool within the @server.call_tool() function. Dispatches based on 'action' to either add a track to the queue or retrieve the current queue using the spotify_client.case "Queue": logger.info(f"Queue operation with arguments: {arguments}") action = arguments.get("action") match action: case "add": track_id = arguments.get("track_id") if not track_id: logger.error("track_id is required for add to queue.") return [types.TextContent( type="text", text="track_id is required for add action" )] spotify_client.add_to_queue(track_id) return [types.TextContent( type="text", text=f"Track added to queue successfully." )] case "get": queue = spotify_client.get_queue() return [types.TextContent( type="text", text=json.dumps(queue, indent=2) )] case _: return [types.TextContent( type="text", text=f"Unknown queue action: {action}. Supported actions are: add, remove, and get." )]
- src/spotify_mcp/server.py:76-80 (schema)Pydantic schema definition for SpotifyQueue tool inputs, used to generate the tool schema via ToolModel.as_tool().class Queue(ToolModel): """Manage the playback queue - get the queue or add tracks.""" action: str = Field(description="Action to perform: 'add' or 'get'.") track_id: Optional[str] = Field(default=None, description="Track ID to add to queue (required for add action)")
- src/spotify_mcp/server.py:101-106 (registration)Registration of the SpotifyQueue tool (as Queue.as_tool()) in the @server.list_tools() handler.tools = [ Playback.as_tool(), Search.as_tool(), Queue.as_tool(), GetInfo.as_tool(), ]
- SpotifyClient helper method called by SpotifyQueue 'get' action to fetch and parse the current playback queue.def get_queue(self, device=None): """Returns the current queue of tracks.""" queue_info = self.sp.queue() self.logger.info(f"currently playing keys {queue_info['currently_playing'].keys()}") queue_info['currently_playing'] = self.get_current_track() queue_info['queue'] = [utils.parse_track(track) for track in queue_info.pop('queue')] return queue_info
- SpotifyClient helper method called by SpotifyQueue 'add' action to add a track to the playback queue.def add_to_queue(self, track_id: str, device=None): """ Adds track to queue. - track_id: ID of track to play. """ self.sp.add_to_queue(track_id, device.get('id') if device else None)