Skip to main content
Glama
jamiew

Spotify MCP Server

get_album_info

Retrieve detailed Spotify album metadata including release date, label information, and track listings using the album's unique identifier.

Instructions

Get detailed information about a Spotify album.

Args:
    album_id: Spotify album ID

Returns:
    Dict with album metadata including release_date, label, tracks

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
album_idYes

Implementation Reference

  • The main handler function for the 'get_album_info' tool. Decorated with @mcp.tool() for registration and @log_tool_execution. Fetches album details and tracks from Spotify API, parses using Album and Track models, and returns structured data.
    @mcp.tool()
    @log_tool_execution
    def get_album_info(album_id: str) -> dict[str, Any]:
        """Get detailed information about a Spotify album.
    
        Args:
            album_id: Spotify album ID
    
        Returns:
            Dict with album metadata including release_date, label, tracks
        """
        try:
            logger.info(f"💿 Getting album info: {album_id}")
            result = spotify_client.album(album_id)
    
            album = Album(
                name=result["name"],
                id=result["id"],
                artist=result["artists"][0]["name"] if result.get("artists") else "Unknown",
                artists=[a["name"] for a in result.get("artists", [])],
                release_date=result.get("release_date"),
                release_date_precision=result.get("release_date_precision"),
                total_tracks=result.get("total_tracks"),
                album_type=result.get("album_type"),
                label=result.get("label"),
                genres=result.get("genres", []),
                popularity=result.get("popularity"),
                external_urls=result.get("external_urls"),
            )
    
            # Parse album tracks
            tracks = []
            for item in result.get("tracks", {}).get("items", []):
                if item:
                    # Album track items don't have album info, add it
                    item["album"] = {
                        "name": result["name"],
                        "id": result["id"],
                        "release_date": result.get("release_date"),
                    }
                    tracks.append(parse_track(item).model_dump())
    
            return {
                "album": album.model_dump(),
                "tracks": tracks,
            }
        except SpotifyException as e:
            raise convert_spotify_error(e) from e
  • Pydantic BaseModel schema defining the structure for Spotify album data, used in the get_album_info tool output.
    class Album(BaseModel):
        """A Spotify album."""
    
        name: str
        id: str
        artist: str
        artists: list[str] | None = None
        release_date: str | None = None
        release_date_precision: str | None = None
        total_tracks: int | None = None
        album_type: str | None = None
        label: str | None = None
        genres: list[str] | None = None
        popularity: int | None = None
        external_urls: dict[str, str] | 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