now_playing
Retrieve currently playing track details across all Sonos devices, including track name, artist, and album, for real-time monitoring and management.
Instructions
Retrieve information about currently playing tracks on all Sonos devices.
Returns: List[Dict[str, str]]: A list of dictionaries containing the name, title, artist, and album of currently playing tracks.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.py:102-123 (handler)The core handler function for the 'now_playing' MCP tool. Decorated with @mcp.tool() for automatic registration using FastMCP. It discovers Sonos devices, checks which are playing, and returns a list of dicts with device name, title, artist, and album for currently playing tracks.@mcp.tool() def now_playing() -> List[Dict[str, str]]: """Retrieve information about currently playing tracks on all Sonos devices. Returns: List[Dict[str, str]]: A list of dictionaries containing the name, title, artist, and album of currently playing tracks. """ devices = get_devices() infos = [] for device in devices.values(): track = device.get_current_track_info() if not track: continue is_playing = device.get_current_transport_info()["current_transport_state"] == "PLAYING" if is_playing: infos.append({ "name": device.player_name, "title": track["title"], "artist": track["artist"], "album": track["album"] }) return infos