mode
Control or retrieve the play mode of a Sonos device, such as 'NORMAL', 'SHUFFLE_NOREPEAT', 'SHUFFLE', or 'REPEAT_ALL', by specifying the mode and device name.
Instructions
Get or set the play mode of a Sonos device.
Args: mode: The play mode to set (e.g., "NORMAL", "SHUFFLE_NOREPEAT", "SHUFFLE", "REPEAT_ALL"). If None, returns the current mode. name: The name of the device to set the mode for. If None, uses the current device.
Returns: str: The current play mode after the operation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | ||
| name | No |
Implementation Reference
- server.py:234-251 (handler)The handler function for the 'mode' MCP tool, decorated with @mcp.tool() for registration. It gets or sets the play mode (NORMAL, SHUFFLE_NOREPEAT, SHUFFLE, REPEAT_ALL) on a Sonos device, using type hints and docstring for schema.@mcp.tool() def mode( mode: Optional[Literal["NORMAL", "SHUFFLE_NOREPEAT", "SHUFFLE", "REPEAT_ALL"]] = None, name: Optional[str] = None ) -> str: """Get or set the play mode of a Sonos device. Args: mode: The play mode to set (e.g., "NORMAL", "SHUFFLE_NOREPEAT", "SHUFFLE", "REPEAT_ALL"). If None, returns the current mode. name: The name of the device to set the mode for. If None, uses the current device. Returns: str: The current play mode after the operation. """ device = get_device(name) if mode: device.play_mode = mode return device.play_mode