Skip to main content
Glama
jamiew

Spotify MCP Server

get_track_info

Retrieve detailed metadata for Spotify tracks by providing track IDs, supporting batch processing for up to 50 tracks in a single API call to improve efficiency.

Instructions

Get detailed information about one or more Spotify tracks.

Args:
    track_ids: Single track ID or list of track IDs (up to 50)

Returns:
    Dict with 'tracks' list containing track metadata including release_date.
    For single ID, returns {'tracks': [track]}.

Note: Batch lookup is much more efficient - 50 tracks = 1 API call instead of 50.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
track_idsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that fetches detailed track information from Spotify API. Handles single track ID or batch of up to 50 IDs, uses parse_track helper, returns structured dict with Track data.
    def get_track_info(track_ids: str | list[str]) -> dict[str, Any]:
        """Get detailed information about one or more Spotify tracks.
    
        Args:
            track_ids: Single track ID or list of track IDs (up to 50)
    
        Returns:
            Dict with 'tracks' list containing track metadata including release_date.
            For single ID, returns {'tracks': [track]}.
    
        Note: Batch lookup is much more efficient - 50 tracks = 1 API call instead of 50.
        """
        try:
            # Normalize to list
            ids = [track_ids] if isinstance(track_ids, str) else track_ids
    
            if len(ids) > 50:
                raise ValueError("Maximum 50 track IDs per request (Spotify API limit)")
    
            logger.info(f"🎵 Getting track info for {len(ids)} track(s)")
    
            if len(ids) == 1:
                result = spotify_client.track(ids[0])
                tracks = [parse_track(result).model_dump()]
            else:
                result = spotify_client.tracks(ids)
                tracks = [
                    parse_track(item).model_dump()
                    for item in result.get("tracks", [])
                    if item
                ]
    
            return {"tracks": tracks}
        except SpotifyException as e:
            raise convert_spotify_error(e) from e
  • FastMCP decorator that registers get_track_info as a tool with automatic schema generation from signature and docstring. Includes logging decorator.
    @mcp.tool()
    @log_tool_execution
  • Pydantic BaseModel defining the structured output format for tracks returned by get_track_info.
    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
  • Utility function that converts raw Spotify API track dictionary into the structured Track Pydantic model used by the handler.
    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"),
        )
Behavior4/5

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

With no annotations provided, the description carries the full burden and does well by disclosing key behavioral traits: it describes the return format (dict with 'tracks' list), handles both single and batch operations, specifies the 50-track limit for efficiency, and explains the response structure difference for single vs multiple IDs. It doesn't mention rate limits or authentication requirements, but provides substantial operational context.

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 clear sections (Args, Returns, Note), front-loads the core purpose, and every sentence adds value. The batch efficiency note is particularly helpful without being verbose.

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

Completeness5/5

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

Given the tool's moderate complexity, no annotations, and the presence of an output schema, the description provides excellent completeness. It covers purpose, parameters, return format, operational efficiency, and edge cases (single vs multiple IDs), making it fully adequate for agent understanding.

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

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant meaning beyond the input schema, which has 0% description coverage. It explains that track_ids can be a single ID or list of IDs, specifies the 50-track maximum for batch operations, and clarifies the format expectations. This fully compensates for the schema's lack of documentation.

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's purpose with specific verb ('Get detailed information') and resource ('Spotify tracks'), distinguishing it from siblings like get_album_info or get_artist_info. It specifies the scope of information returned including metadata like release_date.

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 about batch efficiency ('Batch lookup is much more efficient - 50 tracks = 1 API call instead of 50'), which helps guide usage decisions. However, it doesn't explicitly state when to use this tool versus alternatives like get_audio_features or search_tracks for different types of track information.

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