Skip to main content
Glama

get_artist_top_tracks

Retrieve an artist's most popular tracks on Spotify by providing their artist ID. Use this tool to access top-performing songs for music analysis or playlist creation.

Instructions

Get top tracks for an artist Args: artist_id: Spotify artist ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
artist_idYes

Implementation Reference

  • Core handler function in SpotifyClient that fetches the artist's top tracks using the spotipy library and returns the results as a dictionary or error string.
    async def get_artist_top_tracks(self, artist_id: str) -> dict: """ Get an artist's top tracks - artist_id: Spotify artist ID """ try: # Note: market parameter defaults to user's country results = self.sp.artist_top_tracks(artist_id) return results except Exception as e: return f"Error getting artist top tracks: {str(e)}"
  • main.py:168-175 (registration)
    MCP tool registration decorator and wrapper function that calls the SpotifyClient's get_artist_top_tracks method.
    @mcp.tool() async def get_artist_top_tracks(artist_id: str) -> str: """ Get top tracks for an artist Args: artist_id: Spotify artist ID """ return await client.get_artist_top_tracks(artist_id)

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