Skip to main content
Glama
jamiew

Spotify MCP Server

get_artist_info

Retrieve detailed information about a Spotify artist, including their top tracks, using the artist's Spotify ID.

Instructions

Get detailed information about a Spotify artist.

Args:
    artist_id: Spotify artist ID
Returns:
    Dict with artist info and top tracks

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
artist_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function for the 'get_artist_info' tool. Uses @mcp.tool() decorator for FastMCP registration, calls spotify_client.artist() and spotify_client.artist_top_tracks(), constructs an Artist model and parses top tracks, returning structured dict output.
    @mcp.tool()
    @log_tool_execution
    def get_artist_info(artist_id: str) -> dict[str, Any]:
        """Get detailed information about a Spotify artist.
    
        Args:
            artist_id: Spotify artist ID
        Returns:
            Dict with artist info and top tracks
        """
        try:
            logger.info(f"🎤 Getting artist info: {artist_id}")
            result = spotify_client.artist(artist_id)
            top_tracks = spotify_client.artist_top_tracks(artist_id)
    
            artist = Artist(
                name=result["name"],
                id=result["id"],
                genres=result.get("genres", []),
                popularity=result.get("popularity"),
                followers=result.get("followers", {}).get("total"),
            )
    
            tracks = [parse_track(track) for track in top_tracks.get("tracks", [])[:10]]
    
            return {
                "artist": artist.model_dump(),
                "top_tracks": [track.model_dump() for track in tracks],
            }
        except SpotifyException as e:
            raise convert_spotify_error(e) from e
  • Pydantic Artist model (BaseModel) used by get_artist_info for structured output, with fields: name, id, genres, popularity, followers.
    class Artist(BaseModel):
        """A Spotify artist."""
    
        name: str
        id: str
        genres: list[str] | None = None
        popularity: int | None = None
        followers: int | None = None
  • Pydantic Track model (BaseModel) used for parsing top tracks in get_artist_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
  • Tool registered via the @mcp.tool() decorator on the handler function, which automatically registers it with the FastMCP server.
    @mcp.tool()
    @log_tool_execution
    def get_artist_info(artist_id: str) -> dict[str, Any]:
  • parse_track helper function used to convert raw Spotify track dicts into Track model instances for the top_tracks output.
    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?

No annotations are provided, so the description bears full responsibility. It only states the tool 'gets detailed information' without disclosing any behavioral traits such as authentication needs, rate limits, or side effects. The lack of detail on error behavior or response structure reduces transparency.

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 very short and front-loaded, with a clear structure (args, returns). Every sentence serves a purpose, though some additional context could be added without losing conciseness.

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 the presence of an output schema, the description need not detail return values, but it only mentions 'artist info and top tracks' vaguely. For a one-parameter tool, the description is adequate but omits details like error cases or what 'detailed information' includes.

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?

The schema has 0% description coverage, but the description adds that artist_id is a 'Spotify artist ID', providing context beyond the schema's title 'Artist Id'. However, it does not explain format or validation rules, leaving meaning partially clear.

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 it retrieves detailed information about a Spotify artist, including top tracks. This distinguishes it from siblings like get_track_info or get_album_info, satisfying the specific verb+resource criterion.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies that this tool is for artist info, but it does not explicitly state when to use it versus alternatives (e.g., get_artist_info vs get_track_info). No when-not or alternative tool names are mentioned, leaving usage guidance implicit.

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