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
| Name | Required | Description | Default |
|---|---|---|---|
| artist_id | Yes |
Implementation Reference
- src/spotify_mcp/fastmcp_server.py:445-446 (registration)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