Skip to main content
Glama
jamiew

Spotify MCP Server

get_queue

Retrieve the current playback queue to see what's playing now and what tracks are coming up next in Spotify.

Instructions

Get the current playback queue. Returns: Dict with currently_playing track and queue of upcoming tracks

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'get_queue' MCP tool. It fetches the current queue from Spotify API, parses the tracks using parse_track helper, and returns a structured dictionary with currently_playing and queue lists. Registered automatically via @mcp.tool() decorator.
    @mcp.tool()
    @log_tool_execution
    def get_queue() -> dict[str, Any]:
        """Get the current playback queue.
        Returns:
            Dict with currently_playing track and queue of upcoming tracks
        """
        try:
            logger.info("🎵 Getting playback queue")
            result = spotify_client.queue()
    
            queue_tracks = []
            if result.get("queue"):
                queue_tracks = [parse_track(item) for item in result["queue"]]
    
            return {
                "currently_playing": parse_track(result["currently_playing"]).model_dump()
                if result.get("currently_playing")
                else None,
                "queue": [track.model_dump() for track in queue_tracks],
            }
        except SpotifyException as e:
            raise convert_spotify_error(e) from e
  • Pydantic BaseModel schema for Track objects, used by parse_track to structure queue track data.
    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 that parses raw Spotify track dictionaries into structured Track models, used in get_queue for both currently_playing and queue tracks.
    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"),
        )
  • Supporting method in SpotifyClient wrapper class that also fetches and parses the queue, though not directly called by the MCP tool (tool uses raw spotipy client). Uses similar parsing logic.
    def get_queue(self, device: dict[str, Any] | None = None) -> dict[str, Any]:
        """Returns the current queue of tracks."""
        queue_info = self.sp.queue()
        if not queue_info:
            return {"currently_playing": None, "queue": []}
    
        self.logger.info(
            f"currently playing keys {queue_info.get('currently_playing', {}).keys()}"
        )
    
        queue_info["currently_playing"] = self.get_current_track()
        queue = queue_info.pop("queue", [])
        queue_info["queue"] = [
            track_info
            for track in queue
            if (track_info := utils.parse_track(track)) is not None
        ]
    
        return queue_info or {}
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 states the return format (Dict with currently_playing and queue), which is helpful, but lacks details on permissions, rate limits, error conditions, or whether it requires an active playback session. This partial disclosure meets a baseline for a read-only tool.

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 front-loaded with the core purpose in the first sentence, followed by return details. It's appropriately sized with no wasted words, though the structure could be slightly improved by integrating the return info more seamlessly.

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?

Given the tool's low complexity (0 parameters) and the presence of an output schema (which handles return value documentation), the description is reasonably complete. It covers the purpose and return structure, though it could benefit from more behavioral context like usage prerequisites.

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 fully documents the lack of inputs. The description adds no parameter information, which is appropriate here. A baseline of 4 is applied as it doesn't need to compensate for any gaps.

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's purpose with 'Get the current playback queue' (verb+resource). It distinguishes from siblings like 'get_playlist_tracks' or 'get_saved_tracks' by focusing specifically on the playback queue rather than stored collections. However, it doesn't explicitly contrast with all siblings, missing a perfect score.

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. It doesn't mention prerequisites (e.g., active playback), exclusions, or comparisons to siblings like 'get_playlist_info' for stored content. This leaves 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