remove_index_from_queue
Remove a specific track from a Sonos device queue by specifying its index. Ensures quick updates to the playback list and corrects queue management. Requires the track index and optional device name.
Instructions
Remove a specific track from the queue on a Sonos device.
Args: index: The index of the track to remove. name: The name of the device to remove the track from. If None, uses the current device.
Returns: List[Dict[str, Any]]: The updated queue after removing the track.
Raises: ValueError: If the index is out of the queue's range.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| index | Yes | ||
| name | No |
Implementation Reference
- server.py:367-390 (handler)The core handler function for the 'remove_index_from_queue' tool. Decorated with @mcp.tool() which also handles registration in FastMCP. It retrieves the Sonos device coordinator, validates the index, removes the track using soco API, and returns the updated queue via get_queue.@mcp.tool() def remove_index_from_queue(index: int, name: Optional[str] = None) -> List[Dict[str, Any]]: """Remove a specific track from the queue on a Sonos device. Args: index: The index of the track to remove. name: The name of the device to remove the track from. If None, uses the current device. Returns: List[Dict[str, Any]]: The updated queue after removing the track. Raises: ValueError: If the index is out of the queue's range. """ sonos = get_device(name).group.coordinator queue_length = sonos.queue_size if not 1 <= index <= queue_length: raise ValueError(f"Index {index} is not within range 1-{queue_length}") sonos.remove_from_queue(index) # Return the updated queue return get_queue(name)