speaker_info
Retrieve detailed speaker information for a specified or active Sonos device using the MCP Server, enabling precise control and management of your audio setup.
Instructions
Retrieve speaker information for a Sonos device.
Args: name: The name of the device to retrieve speaker information from. If None, uses the current device.
Returns: Dict[str, str]: A dictionary containing speaker information.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No |
Implementation Reference
- server.py:264-274 (handler)The core handler function for the 'speaker_info' MCP tool, decorated with @mcp.tool() for registration. It uses the helper get_device to obtain the Sonos device and calls its get_speaker_info() method to return the speaker details as a dictionary.@mcp.tool() def speaker_info(name: Optional[str] = None) -> Dict[str, str]: """Retrieve speaker information for a Sonos device. Args: name: The name of the device to retrieve speaker information from. If None, uses the current device. Returns: Dict[str, str]: A dictionary containing speaker information. """ return get_device(name).get_speaker_info()
- server.py:31-61 (helper)Supporting helper function get_device that resolves the Sonos device by name (case-insensitive) or defaults to the first/current device, used by the speaker_info handler.def get_device(name: Optional[str] = None) -> soco.SoCo: """Retrieve a Sonos device by name or return the current device. Args: name: The name of the device to retrieve. If None, returns the current device. Returns: soco.SoCo: The Sonos device object. Raises: ValueError: If the specified device name is not found. """ global device if not name and device: return device devices = get_devices() if not name: device = devices[list(devices.keys())[0]] return device if name in devices: device = devices[name] return device for key in devices: if key.lower() == name.lower(): device = devices[key] return device raise ValueError(f"Device {name} not found")
- server.py:264-264 (registration)The @mcp.tool() decorator registers the speaker_info function as an MCP tool.@mcp.tool()