get_playback_state
Retrieve current playback details from Spotify, including track information and player status.
Instructions
Get current playback information
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_playback_state"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- main.py:66-69 (handler)The MCP tool handler function for 'get_playback_state', decorated with @mcp.tool() for registration and execution. It delegates to SpotifyClient.get_current_playback().
@mcp.tool() async def get_playback_state() -> str: """Get current playback information""" return await client.get_current_playback() - spotify.py:148-158 (helper)Supporting method in SpotifyClient class that implements the core logic by calling spotipy's current_playback() to retrieve the playback state.
async def get_current_playback(self) -> str: """ Get information about current playback state. """ try: playback = self.sp.current_playback() if not playback: return "No active playback session." return playback except Exception as e: return f"Error getting playback state: {str(e)}"