start_playback_track
Play a specific track on Spotify by providing its track URI. Use this tool to start music playback on your preferred device.
Instructions
Start playback of a specific track on Spotify
Args:
track_uri: Spotify URI of the track (e.g. 'spotify:track:1234...')
device_id: Optional device to play on
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| track_uri | Yes | ||
| device_id | No |
Implementation Reference
- main.py:101-110 (handler)The FastMCP tool handler function for 'start_playback_track', decorated with @mcp.tool() for registration, which calls the SpotifyClient method.@mcp.tool() async def start_playback_track(track_uri: str, device_id: str = None) -> str: """ Start playback of a specific track on Spotify Args: track_uri: Spotify URI of the track (e.g. 'spotify:track:1234...') device_id: Optional device to play on """ return await client.start_playback_track(track_uri, device_id)
- spotify.py:191-204 (helper)SpotifyClient helper method that implements the core logic using spotipy.Spotify.start_playback with the provided track URI.async def start_playback_track( self, track_uri: str, device_id: Optional[str] = None ) -> str: """ Start playback of a specific track. - track_uri: Spotify URI of the track to play - device_id: Optional device to play on """ try: self.sp.start_playback(device_id=device_id, uris=[track_uri]) return "Started playing track successfully" except Exception as e: return f"Error starting track playback: {str(e)}"