Skip to main content
Glama

get_all_device_states

Retrieve state information for all Sonos devices on your network. Use this tool to fetch detailed data about each device's current status for monitoring or control purposes.

Instructions

Retrieve the state information for all discovered Sonos devices.

Returns: List[Dict[str, Any]]: A list of dictionaries containing state information for each device.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'get_all_device_states' MCP tool. It discovers all Sonos devices, retrieves detailed state information (name, volume, transport state, track info) for each using helper functions get_devices() and get_info_from(), and returns a list of these states. Registered via @mcp.tool() decorator.
    @mcp.tool()
    def get_all_device_states() -> List[Dict[str, Any]]:
        """Retrieve the state information for all discovered Sonos devices.
        
        Returns:
            List[Dict[str, Any]]: A list of dictionaries containing state information for each device.
        """
        devices = get_devices()
        infos = []
        for device in devices.values():
            infos.append(get_info_from(device))
        return infos
  • Helper function used by get_all_device_states to extract comprehensive state information from a single Sonos device, including player name, volume, transport state, and detailed track metadata.
    def get_info_from(device: soco.SoCo) -> Dict[str, Any]:
        """Retrieve detailed information from a Sonos device.
        
        Args:
            device: The Sonos device to retrieve information from.
            
        Returns:
            Dict[str, Any]: A dictionary containing the device's name, volume, state, and current track information.
        """
        track_info = device.get_current_track_info()
        return {
            "name": device.player_name,
            "volume": device.volume,
            "state": device.get_current_transport_info()["current_transport_state"],
            "track": {
                "title": track_info.get("title"),
                "artist": track_info.get("artist"),
                "album": track_info.get("album"),
                "position": track_info.get("position"),
                "duration": track_info.get("duration"),
                "playlist_position": track_info.get("playlist_position"),
                "album_art": track_info.get("album_art")
            }
        }
  • Helper function that returns the global dictionary of discovered Sonos devices, lazily discovering them if none are cached.
    def get_devices() -> Dict[str, soco.SoCo]:
        """Retrieve the dictionary of discovered Sonos devices.
        
        Returns:
            Dict[str, soco.SoCo]: A dictionary mapping device names to their respective SoCo objects.
        """
        global devices
        if not devices:
            discover_devices()
        return devices
  • Type signature of the tool: no input parameters, returns List[Dict[str, Any]] representing list of device states.
    def get_all_device_states() -> List[Dict[str, Any]]:
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the return type (list of dictionaries) but doesn't cover important aspects like whether this is a read-only operation, potential side effects, rate limits, authentication needs, or what specific state information is included. For a tool with zero annotation coverage, this leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with two sentences that directly address the tool's purpose and return value. It's front-loaded with the main functionality and avoids unnecessary elaboration. The only minor improvement would be integrating the return information more seamlessly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has no parameters, no output schema, and no annotations, the description provides basic purpose and return format information. However, for a tool that presumably interacts with hardware devices, more context about what 'state information' includes, whether this operation is safe/read-only, and how it differs from sibling tools would make it more complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters with 100% schema description coverage, so the schema already fully documents the lack of parameters. The description appropriately doesn't add parameter information beyond what's in the schema, which is correct for a parameterless tool.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Retrieve') and resource ('state information for all discovered Sonos devices'), making the purpose specific and understandable. However, it doesn't explicitly distinguish this tool from its sibling 'get_device_state' (which presumably retrieves state for a single device), missing full sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'get_device_state' or other sibling tools. The description only states what it does, not when it's appropriate or when other tools might be better suited.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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