Skip to main content
Glama
boristopalov

Spotify MCP Server

by boristopalov

SpotifyQueue

Control your Spotify playback queue by adding tracks or viewing upcoming songs through the Spotify MCP Server.

Instructions

Manage the playback queue - get the queue or add tracks.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction to perform: 'add' or 'get'.
track_idNoTrack ID to add to queue (required for add action)

Implementation Reference

  • Main execution handler for the SpotifyQueue tool within the @server.call_tool() function. Dispatches based on 'action' to either add a track to the queue or retrieve the current queue using the spotify_client.
    case "Queue":
        logger.info(f"Queue operation with arguments: {arguments}")
        action = arguments.get("action")
    
        match action:
            case "add":
                track_id = arguments.get("track_id")
                if not track_id:
                    logger.error("track_id is required for add to queue.")
                    return [types.TextContent(
                        type="text",
                        text="track_id is required for add action"
                    )]
                spotify_client.add_to_queue(track_id)
                return [types.TextContent(
                    type="text",
                    text=f"Track added to queue successfully."
                )]
    
            case "get":
                queue = spotify_client.get_queue()
                return [types.TextContent(
                    type="text",
                    text=json.dumps(queue, indent=2)
                )]
    
    
            case _:
                return [types.TextContent(
                    type="text",
                    text=f"Unknown queue action: {action}. Supported actions are: add, remove, and get."
                )]
  • Pydantic schema definition for SpotifyQueue tool inputs, used to generate the tool schema via ToolModel.as_tool().
    class Queue(ToolModel):
        """Manage the playback queue - get the queue or add tracks."""
        action: str = Field(description="Action to perform: 'add' or 'get'.")
        track_id: Optional[str] = Field(default=None, description="Track ID to add to queue (required for add action)")
  • Registration of the SpotifyQueue tool (as Queue.as_tool()) in the @server.list_tools() handler.
    tools = [
        Playback.as_tool(),
        Search.as_tool(),
        Queue.as_tool(),
        GetInfo.as_tool(),
    ]
  • SpotifyClient helper method called by SpotifyQueue 'get' action to fetch and parse the current playback queue.
    def get_queue(self, device=None):
        """Returns the current queue of tracks."""
        queue_info = self.sp.queue()
        self.logger.info(f"currently playing keys {queue_info['currently_playing'].keys()}")
    
        queue_info['currently_playing'] = self.get_current_track()
    
        queue_info['queue'] = [utils.parse_track(track) for track in queue_info.pop('queue')]
    
        return queue_info
  • SpotifyClient helper method called by SpotifyQueue 'add' action to add a track to the playback queue.
    def add_to_queue(self, track_id: str, device=None):
        """
        Adds track to queue.
        - track_id: ID of track to play.
        """
        self.sp.add_to_queue(track_id, device.get('id') if device else None)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv1.0.0
    • addedInput schema / description
      Added value: +"Manage the playback queue - get the queue or add tracks."
    • addedInput schema / title
      Added value: +"Queue"
  2. First observed

TDQS

B3.4/5.0
Behavior2/5

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

No annotations exist, so the description bears full responsibility. It fails to disclose behavior such as whether adding a track requires an active device, if the queue is appended or overwritten, or what errors occur. Minimal behavioral detail beyond the schema.

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?

Single, concise sentence that immediately communicates the tool's purpose. No superfluous words, front-loads the resource and actions.

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

Completeness4/5

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

For a simple tool with two parameters and two actions, the description adequately covers purpose. It lacks details on return values or error cases but is sufficient for basic usage given no output schema and limited complexity.

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 coverage is 100% with parameter descriptions. The description adds marginal value by linking 'add tracks' to the action parameter and implying track_id for add. Baseline score is appropriate as schema handles semantics.

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 tool manages the playback queue with two specific actions: get or add tracks. It distinguishes itself from sibling tools like SpotifyPlayback by focusing on queue management.

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 on when to use this tool versus alternatives like SpotifyPlayback for control operations. The description simply lists actions without context on prerequisites or typical use cases.

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