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)}"

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