start_playlist_playback
Play a Spotify playlist by providing its ID, optionally specifying a device for playback.
Instructions
Start playback of a specific playlist
Args:
playlist_id: Spotify playlist ID
device_id: Optional device to play on
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| playlist_id | Yes | ||
| device_id | No |
Implementation Reference
- main.py:155-166 (handler)The main handler function for the MCP tool 'start_playlist_playback'. It is registered via the @mcp.tool() decorator and handles starting playback of a specified Spotify playlist by constructing the context URI and calling the SpotifyClient helper method.@mcp.tool() async def start_playlist_playback(playlist_id: str, device_id: str = None) -> str: """ Start playback of a specific playlist Args: playlist_id: Spotify playlist ID device_id: Optional device to play on """ return await client.start_context_playback( f"spotify:playlist:{playlist_id}", device_id )
- spotify.py:269-282 (helper)Helper method in the SpotifyClient class that performs the actual Spotify API call to start playback of a context URI (such as a playlist), used by the MCP tool handler.async def start_context_playback( self, context_uri: str, device_id: Optional[str] = None ) -> str: """ Start playback of a context (playlist, album, artist) - context_uri: Spotify URI (e.g. 'spotify:playlist:37i9dQ...') - device_id: Optional device to play on """ try: self.sp.start_playback(device_id=device_id, context_uri=context_uri) return "Started playing context successfully" except Exception as e: return f"Error starting context playback: {str(e)}"