Skip to main content
Glama
jamiew

Spotify MCP Server

get_playlist_info

Retrieve Spotify playlist metadata including title, description, and owner details using the playlist ID. Use this tool to access playlist information without track listings.

Instructions

Get basic information about a Spotify playlist.

Args:
    playlist_id: Spotify playlist ID

Returns:
    Dict with playlist metadata (no tracks - use get_playlist_tracks for tracks)

Note: This returns playlist info only. For tracks, use get_playlist_tracks
which supports full pagination for large playlists.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
playlist_idYes

Implementation Reference

  • The handler function for the 'get_playlist_info' tool. It fetches basic metadata about a Spotify playlist using the Spotify API and structures the response using the Playlist Pydantic model. The @mcp.tool() decorator registers this function as an MCP tool.
    @mcp.tool()
    @log_tool_execution
    def get_playlist_info(playlist_id: str) -> dict[str, Any]:
        """Get basic information about a Spotify playlist.
    
        Args:
            playlist_id: Spotify playlist ID
    
        Returns:
            Dict with playlist metadata (no tracks - use get_playlist_tracks for tracks)
    
        Note: This returns playlist info only. For tracks, use get_playlist_tracks
        which supports full pagination for large playlists.
        """
        try:
            logger.info(f"📋 Getting playlist info: {playlist_id}")
            result = spotify_client.playlist(
                playlist_id, fields="id,name,description,owner,public,tracks.total"
            )
    
            playlist = Playlist(
                name=result["name"],
                id=result["id"],
                owner=result.get("owner", {}).get("display_name"),
                description=result.get("description"),
                tracks=None,  # No tracks - use get_playlist_tracks
                total_tracks=result.get("tracks", {}).get("total"),
                public=result.get("public"),
            )
    
            return playlist.model_dump()
        except SpotifyException as e:
            raise convert_spotify_error(e) from e
  • Pydantic BaseModel defining the output schema for playlist information, used directly in the get_playlist_info handler to structure the API response.
    class Playlist(BaseModel):
        """A Spotify playlist."""
    
        name: str
        id: str
        owner: str | None = None
        description: str | None = None
        tracks: list[Track] | None = None
        total_tracks: int | None = None
        public: bool | None = None
  • The @mcp.tool() decorator on the get_playlist_info function, which registers it as an MCP tool.
    @mcp.tool()

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