Skip to main content
Glama
boristopalov

Spotify MCP Server

by boristopalov

SpotifyGetInfo

Retrieve detailed metadata for Spotify tracks, albums, artists, or playlists including track listings, artist albums, and top tracks.

Instructions

Get detailed information about a Spotify item (track, album, artist, or playlist).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
item_idYesID of the item to get information about
qtypeNoType of item: 'track', 'album', 'artist', or 'playlist'. If 'playlist' or 'album', returns its tracks. If 'artist',returns albums and top tracks.track

Implementation Reference

  • Core handler function that implements the logic for retrieving and parsing detailed information about a Spotify item based on its ID and type (track, album, artist, or playlist).
    def get_info(self, item_id: str, qtype: str = 'track') -> dict:
        """
        Returns more info about item.
        - item_id: id.
        - qtype: Either 'track', 'album', 'artist', or 'playlist'.
        """
        match qtype:
            case 'track':
                return utils.parse_track(self.sp.track(item_id), detailed=True)
            case 'album':
                album_info = utils.parse_album(self.sp.album(item_id), detailed=True)
                return album_info
    
            case 'artist':
                artist_info = utils.parse_artist(self.sp.artist(item_id), detailed=True)
                albums = self.sp.artist_albums(item_id)
                top_tracks = self.sp.artist_top_tracks(item_id)['tracks']
                albums_and_tracks = {
                    'albums': albums,
                    'tracks': {'items': top_tracks}
                }
                parsed_info = utils.parse_search_results(albums_and_tracks, qtype="album,track")
                artist_info['top_tracks'] = parsed_info['tracks']
                artist_info['albums'] = parsed_info['albums']
    
                return artist_info
            case 'playlist':
                playlist = self.sp.playlist(item_id)
                playlist_info = utils.parse_playlist(playlist, detailed=True)
    
                return playlist_info
    
        raise ValueError(f"uknown qtype {qtype}")
  • Pydantic model defining the input schema for the SpotifyGetInfo tool, including item_id and qtype parameters.
    class GetInfo(ToolModel):
        """Get detailed information about a Spotify item (track, album, artist, or playlist)."""
        item_id: str = Field(description="ID of the item to get information about")
        qtype: str = Field(default="track", description="Type of item: 'track', 'album', 'artist', or 'playlist'. "
                                                        "If 'playlist' or 'album', returns its tracks. If 'artist',"
                                                        "returns albums and top tracks.")
  • Registers the SpotifyGetInfo tool (as 'SpotifyGetInfo') by including it in the list returned by the list_tools handler.
    @server.list_tools()
    async def handle_list_tools() -> list[types.Tool]:
        """List available tools."""
        logger.info("Listing available tools")
        tools = [
            Playback.as_tool(),
            Search.as_tool(),
            Queue.as_tool(),
            GetInfo.as_tool(),
        ]
        logger.info(f"Available tools: {[tool.name for tool in tools]}")
        return tools
  • Dispatch handler in the main call_tool function that invokes the Spotify client get_info method with parsed arguments and formats the response.
    case "GetInfo":
        logger.info(f"Getting item info with arguments: {arguments}")
        item_info = spotify_client.get_info(
            item_id=arguments.get("item_id"),
            qtype=arguments.get("qtype", "track")
        )
        return [types.TextContent(
            type="text",
            text=json.dumps(item_info, indent=2)
        )]
  • Helper function used by get_info to parse track details, extracting and formatting key fields like name, id, artists, album, etc.
    def parse_track(track_item: dict, detailed=False) -> Optional[dict]:
        if not track_item:
            return None
        narrowed_item = {
            'name': track_item['name'],
            'id': track_item['id'],
        }
    
        if 'is_playing' in track_item:
            narrowed_item['is_playing'] = track_item['is_playing']
    
        if detailed:
            narrowed_item['album'] = parse_album(track_item.get('album'))
            for k in ['track_number', 'duration_ms']:
                narrowed_item[k] = track_item.get(k)
    
        if not track_item.get('is_playable', True):
            narrowed_item['is_playable'] = False
    
        artists = [a['name'] for a in track_item['artists']]
        if detailed:
            artists = [parse_artist(a) for a in track_item['artists']]
    
        if len(artists) == 1:
            narrowed_item['artist'] = artists[0]
        else:
            narrowed_item['artists'] = artists
    
        return narrowed_item
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Get detailed information') but doesn't cover critical aspects like authentication requirements, rate limits, error handling, or what 'detailed information' entails (e.g., fields returned, pagination). This leaves significant gaps for an agent to understand operational constraints.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without redundancy. It's front-loaded with the core action and resource, making it easy to parse quickly. There's no wasted verbiage or unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of retrieving varied Spotify item types and the lack of annotations and output schema, the description is insufficient. It doesn't explain what 'detailed information' includes (e.g., track metadata, artist albums), how results are structured, or any behavioral traits like authentication needs. For a tool with no structured safety or output guidance, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly (item_id and qtype with default and effects). The description doesn't add any meaningful semantic details beyond what's in the schema, such as format examples for item_id or nuances in qtype behavior. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('detailed information about a Spotify item'), specifying the item types (track, album, artist, or playlist). However, it doesn't explicitly differentiate from sibling tools like SpotifySearch, which might also retrieve information but through search queries rather than direct ID lookup.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like SpotifySearch or other siblings. It lacks context about prerequisites (e.g., authentication), exclusions, or specific scenarios where this direct ID lookup is preferred over search-based methods.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/boristopalov/spotify-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server