Skip to main content
Glama

get_top_artists

Retrieve your most listened-to Spotify artists within customizable timeframes to analyze listening patterns and discover music preferences.

Instructions

Get your top artists

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of artists to return (1-50, default: 10)
time_rangeNoTime range (short_term: 4 weeks, medium_term: 6 months, long_term: all time)medium_term

Implementation Reference

  • Handler for get_top_artists tool: extracts limit and time_range parameters, makes Spotify API request to /me/top/artists endpoint, formats response with artist name, genres, and followers count
    case "get_top_artists": {
      const limit = (args.limit as number) || 10;
      const timeRange = (args.time_range as string) || "medium_term";
    
      const data = await spotifyRequest(
        `/me/top/artists?limit=${limit}&time_range=${timeRange}`
      );
    
      let resultText = `👤 Your Top ${limit} Artists:\n\n`;
      data.items.forEach((artist: any, index: number) => {
        resultText += `${index + 1}. ${artist.name}\n`;
        resultText += `   🎭 Genres: ${artist.genres.slice(0, 3).join(", ")}\n`;
        resultText += `   👥 Followers: ${artist.followers.total.toLocaleString()}\n\n`;
      });
    
      return {
        content: [{ type: "text", text: resultText }],
      };
    }
  • Tool registration with input schema defining two optional parameters: limit (number, default 10) and time_range (enum: short_term/medium_term/long_term, default medium_term)
      name: "get_top_artists",
      description: "Get your top artists",
      inputSchema: {
        type: "object",
        properties: {
          limit: {
            type: "number",
            description: "Number of artists to return (1-50, default: 10)",
            default: 10,
          },
          time_range: {
            type: "string",
            enum: ["short_term", "medium_term", "long_term"],
            description: "Time range (short_term: 4 weeks, medium_term: 6 months, long_term: all time)",
            default: "medium_term",
          },
        },
      },
    },
  • spotifyRequest helper function that handles authentication and makes HTTP requests to the Spotify API, used by get_top_artists handler
    async function spotifyRequest(endpoint: string, method = "GET", data?: any) {
      const token = await getAccessToken();
      
      try {
        const response = await axios({
          method,
          url: `https://api.spotify.com/v1${endpoint}`,
          headers: {
            Authorization: `Bearer ${token}`,
            "Content-Type": "application/json",
          },
          data,
        });
        return response.data;
      } catch (error: any) {
        if (error.response) {
          throw new Error(`Spotify API Error: ${error.response.data.error?.message || error.response.statusText}`);
        }
        throw new Error(`Network Error: ${error.message}`);
      }
    }
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 of behavioral disclosure. 'Get your top artists' implies a read-only operation but doesn't specify authentication requirements, rate limits, data freshness, or what 'top' means (e.g., based on listening history). For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior and 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 with no wasted words. It's front-loaded with the core purpose and appropriately sized for a simple retrieval tool, making it easy 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 (2 parameters, no output schema, no annotations), the description is minimally adequate. It states what the tool does but lacks context on usage, behavioral details, or output format. With no output schema, the description doesn't explain return values, leaving the agent to infer or discover them through use.

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?

The input schema has 100% description coverage, with clear documentation for both parameters (limit and time_range), including defaults and enum values. The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline of 3 for high schema coverage without compensating value.

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 'Get your top artists' clearly states the verb ('Get') and resource ('your top artists'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_top_tracks' or 'get_current_track', which would require more specific language about what distinguishes 'top artists' from other retrieval operations.

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. It doesn't mention prerequisites (e.g., authentication, user context), compare it to similar tools like 'get_top_tracks' or 'search_music', or indicate scenarios where it's appropriate versus when other tools might be better suited.

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/MadhurToshniwal/Spotify-MCP-Server'

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