Skip to main content
Glama

previous

Skip to the previous track on a Sonos device. Specify the device name or use the current one. Returns updated device state, including track details, volume, and playback status.

Instructions

Skip to the previous track on a Sonos device.

Args: name: The name of the device to skip the track on. If None, uses the current device.

Returns: Dict[str, Any]: The device's state after skipping to the previous track, including name, volume, state, and track info.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameNo

Implementation Reference

  • The 'previous' tool handler function, decorated with @mcp.tool() for registration. It retrieves the specified Sonos device, calls device.previous() to skip to the previous track, and returns the updated device state using get_info_from.
    @mcp.tool()
    def previous(name: Optional[str] = None) -> Dict[str, Any]:
        """Skip to the previous track on a Sonos device.
        
        Args:
            name: The name of the device to skip the track on. If None, uses the current device.
            
        Returns:
            Dict[str, Any]: The device's state after skipping to the previous track, including name, volume, state, and track info.
        """
        device = get_device(name)
        device.previous()
        return get_info_from(device)
  • Helper function used by the 'previous' tool to format and return the device's state information after executing the previous track skip.
    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 used by the 'previous' tool to retrieve the specified Sonos device object.
    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")
Behavior3/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 describes the action (skipping to previous track) and the return value (device state), but lacks details on error conditions, permissions needed, whether this affects queue order, or rate limits. It provides basic operational context but misses deeper behavioral traits.

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

Conciseness5/5

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

The description is efficiently structured with a clear purpose statement followed by Args and Returns sections. Every sentence adds value: the first states the action, the second explains the parameter, and the third describes the return. There is no wasted text, and information is front-loaded appropriately.

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 no annotations, no output schema, and low schema coverage, the description provides basic operational info but lacks completeness. It covers what the tool does and the parameter meaning, but doesn't detail error handling, side effects, or the full structure of the returned dict. For a mutation tool with minimal structured data, this leaves gaps in understanding.

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 schema has 0% description coverage for its single parameter, so the description must compensate. It adds meaningful semantics by explaining that 'name' is the device name and defaults to the current device if None, which clarifies usage beyond the bare schema. However, it doesn't specify format constraints or examples for valid device names.

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

Purpose5/5

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

The description clearly states the specific action ('Skip to the previous track') and resource ('on a Sonos device'), distinguishing it from siblings like 'next', 'pause', or 'play' which perform different playback control actions. It precisely defines what the tool does without ambiguity.

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

Usage Guidelines4/5

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

The description provides clear context by specifying it operates on a Sonos device and mentions using the current device if no name is provided. However, it doesn't explicitly state when to use this tool versus alternatives like 'skip' (which might skip forward) or 'play_index' (which plays a specific track), leaving some sibling differentiation implicit rather than explicit.

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