Skip to main content
Glama

get_artist_info

Retrieve detailed Spotify artist information and top tracks by providing 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

Implementation Reference

  • Registers the get_artist_info tool with the FastMCP server using the @mcp.tool() decorator.
    @mcp.tool() @log_tool_execution
  • The main handler function that executes the tool logic: fetches artist details and top 10 tracks using Spotify API, structures output using Artist model.
    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 model used for validating and serializing artist information in the get_artist_info tool output.
    class Artist(BaseModel): """A Spotify artist.""" name: str id: str genres: list[str] | None = None popularity: int | None = None followers: int | None = None

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