SpotifyQueue
Manage your Spotify playback queue by adding tracks or viewing current queue items to control music playback order.
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-208 (handler)Handler logic in handle_call_tool for the SpotifyQueue tool, dispatching to add_to_queue or get_queue based on action.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 model defining the input schema for the SpotifyQueue tool (Spotify + Queue).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)SpotifyQueue tool (via Queue.as_tool()) is registered in the list_tools handler.tools = [ Playback.as_tool(), Search.as_tool(), Queue.as_tool(), GetInfo.as_tool(), ]
- Core implementation of adding a track to the Spotify queue, called by the tool handler.@utils.validate 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)
- Core implementation of retrieving the current Spotify queue, called by the tool handler.@utils.validate 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