Skip to main content
Glama

get_queue

Retrieve a list of tracks in the playback queue for a specified Sonos device, providing detailed track information for media management and control.

Instructions

Retrieve the queue of tracks for a Sonos device.

Args: name: The name of the device to retrieve the queue from. If None, uses the current device.

Returns: List[Dict[str, Any]]: A list of dictionaries containing track information in the queue.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameNo

Implementation Reference

  • The main handler function for the 'get_queue' MCP tool, decorated with @mcp.tool(). It retrieves the queue from the Sonos device, marks the current track, and returns a list of track dictionaries with index, title, artist, album, and current flag.
    @mcp.tool() def get_queue(name: Optional[str] = None) -> List[Dict[str, Any]]: """Retrieve the queue of tracks for a Sonos device. Args: name: The name of the device to retrieve the queue from. If None, uses the current device. Returns: List[Dict[str, Any]]: A list of dictionaries containing track information in the queue. """ sonos = get_device(name) tracks = sonos.get_queue() current = int(sonos.get_current_track_info()['playlist_position']) return [{ "index": idx-1, "title": track.title, "artist": track.creator, "album": track.album, **({"current": True} if idx == current else {}) } for idx, track in enumerate(tracks, 1)]

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/WinstonFassett/sonos-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server