Skip to main content
Glama
varunneal

Spotify MCP Server

by varunneal

SpotifyGetInfo

Retrieve detailed information about Spotify tracks, albums, artists, or playlists using their URIs. Get track lists for albums and playlists, or albums and top tracks for artists.

Instructions

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

Input Schema

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

Implementation Reference

  • Core handler implementing the tool logic: fetches detailed Spotify item information (track, album, artist, playlist) using spotipy and parses results.
    def get_info(self, item_uri: str) -> dict:
        """
        Returns more info about item.
        - item_uri: uri. Looks like 'spotify:track:xxxxxx', 'spotify:album:xxxxxx', etc.
        """
        _, qtype, item_id = item_uri.split(":")
        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':
                if self.username is None:
                    self.set_username()
                playlist = self.sp.playlist(item_id)
                self.logger.info(f"playlist info is {playlist}")
                playlist_info = utils.parse_playlist(playlist, self.username, detailed=True)
    
                return playlist_info
    
        raise ValueError(f"Unknown qtype {qtype}")
  • Tool dispatch handler in @server.call_tool(): extracts item_uri argument and calls spotify_client.get_info, formats response as JSON.
    case "GetInfo":
        logger.info(f"Getting item info with arguments: {arguments}")
        item_info = spotify_client.get_info(
            item_uri=arguments.get("item_uri")
        )
        return [types.TextContent(
            type="text",
            text=json.dumps(item_info, indent=2)
        )]
  • Pydantic input schema/model for SpotifyGetInfo tool, defining required 'item_uri' field.
    class GetInfo(ToolModel):
        """Get detailed information about a Spotify item (track, album, artist, or playlist)."""
        item_uri: str = Field(description="URI of the item to get information about. " +
                                          "If 'playlist' or 'album', returns its tracks. " +
                                          "If 'artist', returns albums and top tracks.")
  • Registers SpotifyGetInfo via GetInfo.as_tool() in the list of tools returned by @server.list_tools().
    @server.list_tools()
    async def handle_list_tools() -> list[types.Tool]:
        """List available tools."""
        logger.info("Listing available tools")
        # await server.request_context.session.send_notification("are you recieving this notification?")
        tools = [
            Playback.as_tool(),
            Search.as_tool(),
            Queue.as_tool(),
            GetInfo.as_tool(),
            Playlist.as_tool(),
        ]
        logger.info(f"Available tools: {[tool.name for tool in tools]}")
        return tools
  • Base ToolModel class with as_tool() method that constructs the tool definition including name 'SpotifyGetInfo' from class name 'GetInfo'.
    class ToolModel(BaseModel):
        @classmethod
        def as_tool(cls):
            return types.Tool(
                name="Spotify" + cls.__name__,
                description=cls.__doc__,
                inputSchema=cls.model_json_schema()
            )
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the tool retrieves information, implying a read-only operation, but lacks details on permissions, rate limits, or response format. The description adds minimal behavioral context beyond the basic purpose.

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 unnecessary words. It is appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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

Completeness3/5

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

Given the tool's low complexity (1 parameter, no annotations, no output schema), the description is minimally adequate. It covers the basic purpose but lacks details on usage, behavioral traits, or output, which are needed for full contextual understanding.

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%, with the parameter 'item_uri' fully documented in the schema. The description does not add any additional meaning or examples beyond what the schema provides, such as URI format or usage tips, so it meets the baseline of 3.

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 detailed information') and resource ('Spotify item'), specifying the types of items supported (track, album, artist, or playlist). However, it does not explicitly differentiate from sibling tools like SpotifySearch, which might also retrieve information, making it a 4 rather than a 5.

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?

No guidance is provided on when to use this tool versus alternatives. The description does not mention sibling tools like SpotifySearch or SpotifyPlaylist, nor does it specify prerequisites or exclusions. This leaves the agent without context for tool selection.

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

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