get_queue_length
Retrieve the current queue length of a specified Sonos device or the active device if none is provided. Use this tool to monitor and manage playback queues efficiently.
Instructions
Retrieve the queue length for a Sonos device.
Args: name: The name of the device to retrieve the queue length from. If None, uses the current device.
Returns: int: The length of the queue.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No |
Implementation Reference
- server.py:416-426 (handler)The handler function for the 'get_queue_length' tool, decorated with @mcp.tool() which handles both implementation and registration in FastMCP. It fetches the Sonos device and returns its queue length using the helper function.@mcp.tool() def get_queue_length(name: Optional[str] = None) -> int: """Retrieve the queue length for a Sonos device. Args: name: The name of the device to retrieve the queue length from. If None, uses the current device. Returns: int: The length of the queue. """ return fetch_queue_length(get_device(name))
- server.py:405-414 (helper)Supporting helper utility that directly accesses the queue_size attribute from the Sonos SoCo object.def fetch_queue_length(sonos): """Return the queue length for a Sonos device. Args: sonos: The Sonos device to retrieve the queue length from. Returns: int: The length of the queue. """ return sonos.queue_size