Skip to main content
Glama
jamiew

Spotify MCP Server

playback_control

Control Spotify playback by starting, pausing, skipping tracks, or checking current status. Use this tool to manage music playback through the Spotify MCP Server.

Instructions

Control Spotify playback.

Args:
    action: Action ('get', 'start', 'pause', 'skip')
    track_id: Track ID to play (for 'start')
    num_skips: Number of tracks to skip

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYes
track_idNo
num_skipsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
trackNo
deviceNo
repeatNooff
volumeNo
shuffleNo
is_playingYes
progress_msNo

Implementation Reference

  • The playback_control tool handler: controls Spotify playback with actions 'get', 'start', 'pause', 'skip'. Includes registration via @mcp.tool() decorator.
    @mcp.tool()
    @log_tool_execution
    def playback_control(
        action: str, track_id: str | None = None, num_skips: int = 1
    ) -> PlaybackState:
        """Control Spotify playback.
    
        Args:
            action: Action ('get', 'start', 'pause', 'skip')
            track_id: Track ID to play (for 'start')
            num_skips: Number of tracks to skip
        """
        try:
            if action == "get":
                logger.info("🎵 Getting current playback state")
                result = spotify_client.current_user_playing_track()
            elif action == "start":
                if track_id:
                    logger.info(f"🎵 Starting playback of track: {track_id}")
                    spotify_client.start_playback(uris=[f"spotify:track:{track_id}"])
                else:
                    logger.info("🎵 Resuming playback")
                    spotify_client.start_playback()
                result = spotify_client.current_user_playing_track()
            elif action == "pause":
                logger.info("🎵 Pausing playback")
                spotify_client.pause_playback()
                result = spotify_client.current_user_playing_track()
            elif action == "skip":
                logger.info(f"🎵 Skipping {num_skips} track(s)")
                for _ in range(num_skips):
                    spotify_client.next_track()
                result = spotify_client.current_user_playing_track()
            else:
                raise ValueError(f"Invalid action: {action}")
    
            # Parse result
            track = None
            if result and result.get("item"):
                track = parse_track(result["item"])
    
            return PlaybackState(
                is_playing=result.get("is_playing", False) if result else False,
                track=track,
                device=result.get("device", {}).get("name")
                if result and result.get("device")
                else None,
                volume=result.get("device", {}).get("volume_percent")
                if result and result.get("device")
                else None,
                shuffle=result.get("shuffle_state", False) if result else False,
                repeat=result.get("repeat_state", "off") if result else "off",
                progress_ms=result.get("progress_ms") if result else None,
            )
    
        except SpotifyException as e:
            raise convert_spotify_error(e) from e
  • Pydantic schema model PlaybackState used as return type for the tool.
    class PlaybackState(BaseModel):
        """Current playback state."""
    
        is_playing: bool
        track: Track | None = None
        device: str | None = None
        volume: int | None = None
        shuffle: bool = False
        repeat: str = "off"
        progress_ms: int | None = None
  • Pydantic schema model Track used within PlaybackState.
    class Track(BaseModel):
        """A Spotify track with metadata."""
    
        name: str
        id: str
        artist: str
        artists: list[str] | None = None
        album: str | None = None
        album_id: str | None = None
        release_date: str | None = None
        duration_ms: int | None = None
        popularity: int | None = None
        external_urls: dict[str, str] | None = None
  • Helper function parse_track to convert Spotify API track data to Track model, used in playback_control.
    def parse_track(item: dict[str, Any]) -> Track:
        """Parse Spotify track data into Track model."""
        album_data = item.get("album", {})
        return Track(
            name=item["name"],
            id=item["id"],
            artist=item["artists"][0]["name"] if item.get("artists") else "Unknown",
            artists=[a["name"] for a in item.get("artists", [])],
            album=album_data.get("name"),
            album_id=album_data.get("id"),
            release_date=album_data.get("release_date"),
            duration_ms=item.get("duration_ms"),
            popularity=item.get("popularity"),
            external_urls=item.get("external_urls"),
        )
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions actions but doesn't describe what each action does (e.g., 'get' retrieves current playback state, 'skip' advances tracks), nor does it cover permissions, rate limits, or error conditions. This leaves significant behavioral gaps for a tool that modifies playback state.

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 sized with a clear opening statement followed by parameter explanations. However, the parameter explanations could be more structured (e.g., bullet points) and some information is redundant (e.g., repeating 'action' in the description when it's obvious from context).

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 3 parameters with 0% schema coverage and no annotations, the description provides basic parameter context but lacks completeness. It doesn't explain return values despite having an output schema, and for a playback control tool with multiple actions, more behavioral detail would be helpful for the agent to use it correctly.

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

Parameters3/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 value by explaining parameter purposes (e.g., 'track_id' for 'start' action, 'num_skips' for skipping multiple tracks), but doesn't fully document all three parameters' semantics or constraints, leaving some ambiguity about parameter interactions.

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 tool controls Spotify playback with specific actions listed, providing a clear verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'add_to_queue' or 'get_queue' which also relate to playback control, so it doesn't fully distinguish from alternatives.

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?

The description provides no guidance on when to use this tool versus alternatives. While it lists actions, it doesn't indicate when to choose 'playback_control' over sibling tools like 'add_to_queue' for queue management or 'search_tracks' for finding tracks to play, leaving the agent without contextual usage direction.

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

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/jamiew/spotify-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server