Skip to main content
Glama

get_top_artists

Retrieve a user's most listened-to Spotify artists within specified time periods, enabling analysis of listening habits and preferences.

Instructions

Get user's top artists from Spotify
Args:
    limit: Number of artists (max 50)
    time_range: One of 'short_term' (4 weeks), 'medium_term' (6 months), 'long_term' (all time)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
time_rangeNomedium_term

Implementation Reference

  • main.py:112-120 (handler)
    MCP tool handler for get_top_artists. Decorated with @mcp.tool(), calls SpotifyClient.get_top_artists and returns result as string.
    @mcp.tool()
    async def get_top_artists(limit: int = 20, time_range: str = "medium_term") -> str:
        """
        Get user's top artists from Spotify
        Args:
            limit: Number of artists (max 50)
            time_range: One of 'short_term' (4 weeks), 'medium_term' (6 months), 'long_term' (all time)
        """
        return await client.get_top_artists(limit, time_range)
  • Core implementation in SpotifyClient that queries Spotify API for user's top artists using spotipy.current_user_top_artists.
    async def get_top_artists(
        self, limit: int = 20, time_range: str = "medium_term"
    ) -> dict:
        """
        Get the current user's top artists.
        - limit: Number of artists to return (default 20, max 50)
        - time_range: 'short_term' (last 4 weeks), 'medium_term' (last 6 months),
                     or 'long_term' (all time) (default: medium_term)
        """
        try:
            results = self.sp.current_user_top_artists(
                limit=limit, offset=0, time_range=time_range
            )
            return results
        except Exception as e:
            return f"Error getting top artists: {str(e)}"
Behavior2/5

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

With no annotations, the description carries the full burden but only states what the tool does without behavioral details. It doesn't disclose authentication needs, rate limits, or response format, which are critical for a tool accessing user data from an external service like Spotify.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded with the main purpose, followed by parameter details. It uses bullet points for clarity, but could be slightly more structured by separating usage notes from parameter explanations to enhance readability.

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 moderate complexity (2 parameters, no output schema, no annotations), the description is adequate but incomplete. It covers parameters well but lacks details on authentication, error handling, or return values, which are needed for full agent understanding in a Spotify API context.

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

Parameters5/5

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

The description adds significant meaning beyond the input schema, which has 0% coverage. It explains 'limit' as 'Number of artists (max 50)' and 'time_range' with specific options and durations, fully compensating for the schema's lack of descriptions and providing essential usage context.

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 'user's top artists from Spotify', making the purpose specific and understandable. However, it doesn't differentiate from siblings like 'get_artist_top_tracks' or 'get_recommendations', which also retrieve artist-related data, so it misses full sibling distinction.

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. For example, it doesn't mention using 'get_artist_top_tracks' for specific artist details or 'search_spotify' for broader queries, leaving the agent without context for selection among similar tools.

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

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