add_to_queue
Add a Spotify track to your playback queue using its track ID. This tool lets you queue songs for continuous listening without interrupting current playback.
Instructions
Add a track to the playback queue.
Args:
track_id: Spotify track ID to add to queue
Returns:
Dict with status and message
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| track_id | Yes |
Implementation Reference
- The core handler function for the 'add_to_queue' MCP tool. Decorated with @mcp.tool() for automatic registration in FastMCP. Takes a track_id parameter, formats it as a Spotify URI, and calls the underlying spotipy client's add_to_queue method. Returns a success message or raises an error.@mcp.tool() @log_tool_execution def add_to_queue(track_id: str) -> dict[str, str]: """Add a track to the playback queue. Args: track_id: Spotify track ID to add to queue Returns: Dict with status and message """ try: logger.info(f"🎵 Adding track {track_id} to queue") spotify_client.add_to_queue(f"spotify:track:{track_id}") return {"status": "success", "message": "Added track to queue"} except SpotifyException as e: raise convert_spotify_error(e) from e
- src/spotify_mcp/fastmcp_server.py:363-363 (registration)The @mcp.tool() decorator registers the add_to_queue function as an MCP tool in the FastMCP server. The @log_tool_execution decorator adds logging.@mcp.tool()
- Supporting method in the SpotifyClient wrapper class that wraps spotipy's add_to_queue. Although not directly called by the tool handler (which uses the raw spotipy client), it provides a similar interface for adding tracks to the queue.def add_to_queue(self, track_id: str, device: dict[str, Any] | None = None) -> 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)