Skip to main content
Glama
kylestratis

Spotify Playlist MCP Server

by kylestratis

spotify_get_track

Read-onlyIdempotent

Retrieve comprehensive metadata for a specific Spotify track using its ID, including artist details, album information, duration, popularity, and external URLs.

Instructions

Get detailed information about a specific Spotify track by ID.

Retrieves comprehensive metadata for a single track including artists, album, duration,
popularity, URIs, and external URLs.

Args:
    - track_id: Spotify track ID (not URI), extract from URIs or search results
    - response_format: 'markdown' or 'json'

Returns:
    Markdown: Track details (name, artists, album, duration, ID, URI, popularity)
    JSON: Full API response (id, name, artists, album, duration_ms, popularity, uri, external_urls, preview_url, track_number, disc_number, explicit, available_markets)

Examples:
    - "Get details for track ID 4u7EnebtmKWzUH433cf5Qv" -> Retrieve track info
    - "Show me info about this track" -> When you have the track ID

Errors: Returns error for invalid track (404), auth failure (401), rate limits (429).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The async handler function that executes the spotify_get_track tool, fetching track details from Spotify API and formatting as markdown or JSON.
    async def spotify_get_track(params: GetTrackInput) -> str:
        """Get detailed information about a specific Spotify track by ID.
    
        Retrieves comprehensive metadata for a single track including artists, album, duration,
        popularity, URIs, and external URLs.
    
        Args:
            - track_id: Spotify track ID (not URI), extract from URIs or search results
            - response_format: 'markdown' or 'json'
    
        Returns:
            Markdown: Track details (name, artists, album, duration, ID, URI, popularity)
            JSON: Full API response (id, name, artists, album, duration_ms, popularity, uri, external_urls, preview_url, track_number, disc_number, explicit, available_markets)
    
        Examples:
            - "Get details for track ID 4u7EnebtmKWzUH433cf5Qv" -> Retrieve track info
            - "Show me info about this track" -> When you have the track ID
    
        Errors: Returns error for invalid track (404), auth failure (401), rate limits (429).
        """
        try:
            data = await make_spotify_request(f"tracks/{params.track_id}")
    
            if params.response_format == ResponseFormat.MARKDOWN:
                return f"# Track Details\n\n{format_track_markdown(data)}"
            else:
                # JSON format
                return json.dumps(data, indent=2)
    
        except Exception as e:
            return handle_spotify_error(e)
  • server.py:536-545 (registration)
    MCP tool registration decorator specifying the name and annotations for spotify_get_track.
    @mcp.tool(
        name="spotify_get_track",
        annotations={
            "title": "Get Spotify Track Details",
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": True,
        },
    )
  • Pydantic BaseModel defining the input parameters for the spotify_get_track tool: track_id (required string) and response_format (markdown or json).
    class GetTrackInput(BaseModel):
        """Input model for getting track details."""
    
        model_config = ConfigDict(str_strip_whitespace=True, validate_assignment=True)
    
        track_id: str = Field(
            ..., description="Spotify track ID", min_length=1, max_length=100
        )
        response_format: ResponseFormat = Field(
            default=ResponseFormat.MARKDOWN,
            description="Output format: 'markdown' or 'json'",
        )
Behavior4/5

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

Annotations already provide readOnlyHint=true, destructiveHint=false, openWorldHint=true, and idempotentHint=true. The description adds valuable context beyond this: it specifies the tool retrieves comprehensive metadata, details the return formats (markdown vs. JSON), and lists potential errors (404, 401, 429). This enhances transparency about behavior and error handling, though it could mention rate limit specifics or auth requirements more explicitly.

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 (purpose, args, returns, examples, errors) and front-loaded key information. It is appropriately sized, but some sentences could be more concise (e.g., the examples are slightly verbose). Overall, it earns its place with efficient communication.

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, rich annotations, and the presence of an output schema (implied by returns section), the description is complete. It covers purpose, parameters, return formats, examples, and errors, providing all necessary context for an agent to use the tool effectively without needing to rely solely on structured fields.

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 carries full burden. It adds significant meaning: track_id is clarified as 'Spotify track ID (not URI), extract from URIs or search results', and response_format is explained with detailed output differences for 'markdown' vs. 'json'. This compensates well for the schema gap, though it doesn't cover all possible parameter nuances like length constraints.

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 verb ('Get detailed information') and resource ('about a specific Spotify track by ID'), distinguishing it from siblings like spotify_search_tracks (searching) or spotify_get_audio_features (audio analysis). It specifies it retrieves comprehensive metadata for a single track, making the purpose specific and differentiated.

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 for when to use this tool (e.g., 'When you have the track ID' in examples), but it does not explicitly mention when not to use it or name alternatives like spotify_search_tracks for finding tracks without an ID. The guidance is helpful but lacks explicit exclusions or named alternatives.

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

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