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
| Name | Required | Description | Default |
|---|---|---|---|
| playlist_id | Yes |
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
- src/spotify_mcp/fastmcp_server.py:478-478 (registration)The @mcp.tool() decorator on the get_playlist_info function, which registers it as an MCP tool.@mcp.tool()