Skip to main content
Glama

play_index

Play a specific track from the queue on a Sonos device by specifying its index. Optionally, choose the device name or use the current one. Returns the device’s updated state including track details.

Instructions

Play a specific track from the queue on a Sonos device.

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

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

Raises: ValueError: If the index is out of the queue's range.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexYes
nameNo

Implementation Reference

  • The handler function decorated with @mcp.tool() that implements the logic to play a specific track by index from the Sonos queue. It validates the index, skips if already playing, and returns device info.
    @mcp.tool()
    def play_index(index: int, name: Optional[str] = None) -> Dict[str, Any]:
        """Play a specific track from the queue on a Sonos device.
        
        Args:
            index: The index of the track to play.
            name: The name of the device to play the track on. If None, uses the current device.
            
        Returns:
            Dict[str, Any]: The device's state after playing the specified track, including name, volume, state, and track info.
            
        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 0 <= index <= queue_length:
            raise ValueError(f"Index {index} is not within range 1-{queue_length}")
        
        current = int(sonos.get_current_track_info()['playlist_position'])
        if index != current:
            sonos.play_from_queue(index)
        return get_info_from(sonos)
  • server.py:342-342 (registration)
    The @mcp.tool() decorator registers the play_index function as an MCP tool.
    @mcp.tool()
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. It discloses key behaviors: it plays a track based on queue index, can target a specific device or default to current, returns device state, and raises ValueError for out-of-range indices. However, it doesn't cover aspects like whether this interrupts current playback, requires specific permissions, or has rate limits, leaving some behavioral 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 well-structured with clear sections (Args, Returns, Raises) and front-loaded core purpose. It's appropriately sized with no redundant information, though the formatting with separate sections slightly reduces pure conciseness compared to a single flowing paragraph.

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 and no output schema, the description provides reasonable coverage for a 2-parameter tool with moderate complexity. It explains parameters, return values, and errors, but lacks details about the queue context (e.g., how the queue is populated) and doesn't fully address behavioral aspects like playback interruption or device availability requirements.

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?

Schema description coverage is 0%, so the description must compensate. It adds meaningful semantics for both parameters: 'index' is explained as 'the index of the track to play' with context about queue range validation, and 'name' is clarified as the device name with a default behavior. This goes beyond the bare schema types, though it could provide more detail on index numbering (e.g., 0-based vs 1-based).

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 ('Play') and resource ('a specific track from the queue on a Sonos device'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'play' (which likely plays the current track) or 'skip' (which might advance the queue), missing full sibling distinction.

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

Usage Guidelines3/5

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

The description implies usage by mentioning the queue context and device selection, but doesn't provide explicit guidance on when to use this tool versus alternatives like 'play' or 'skip'. It states what happens if 'name' is None, but lacks clear when-to-use or when-not-to-use directives compared to siblings.

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