Skip to main content
Glama

get_artist_top_tracks

Retrieve an artist's most popular tracks globally or by country using Spotify streaming data to identify hits and build playlists.

Instructions

Discover an artist's most popular and widely-played tracks based on global streaming data.

🎯 USE CASES: β€’ Quick introduction to an artist's biggest hits β€’ Building "best of" playlists for parties or events β€’ Understanding which songs made an artist famous β€’ Creating radio-friendly playlists with mainstream appeal β€’ Checking what's trending from your favorite artists

πŸ“ WHAT IT RETURNS: β€’ Top 10 tracks ranked by global popularity β€’ Track names, album information, and release dates β€’ Popularity scores and play count estimates β€’ Preview URLs and track durations β€’ Market-specific popularity rankings

πŸ” EXAMPLES: β€’ "What are Ed Sheeran's top tracks?" β€’ "Show me The Weeknd's biggest hits in the US" β€’ "Get Ariana Grande's most popular songs" β€’ "Find the top tracks for artist ID: 1Xyo4u8uXC1ZmMpatF05PJ"

🌍 MARKET SPECIFICITY: β€’ Results can vary by country/region β€’ Reflects local music preferences and cultural differences β€’ Use country parameter for region-specific results β€’ Defaults to US market if not specified

⚠️ REQUIREMENTS: β€’ Valid Spotify access token β€’ Artist must have released tracks

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tokenYesSpotify access token for authentication
artistIdYesSpotify artist ID or URI
countryNoCountry code for localized content (e.g., 'US', 'GB')

Implementation Reference

  • The handler function for the MCP 'get_artist_top_tracks' tool. It destructures the input arguments and delegates the API call to SpotifyService.getArtistTopTracks.
    handler: async (args: any, spotifyService: SpotifyService) => { const { token, artistId, country = "US" } = args; return await spotifyService.getArtistTopTracks(token, artistId, country); },
  • The input schema for the 'get_artist_top_tracks' tool defining validation for token, artistId, and optional country parameters.
    schema: createSchema({ token: commonSchemas.token(), artistId: commonSchemas.spotifyId("artist"), country: commonSchemas.country(), }),
  • Registration of all tools including artistTools (which contains get_artist_top_tracks) into the central allTools registry used by ToolRegistrar for MCP tool exposure.
    export const allTools: ToolsRegistry = { ...albumTools, ...artistTools, ...trackTools, ...playlistTools, ...playbackTools, ...userTools, ...searchTools, };
  • The SpotifyService helper method that performs the actual Spotify API request to retrieve the top tracks for an artist in a specific market.
    async getArtistTopTracks( token: string, artistId: string, country: string = "US" ): Promise<{ tracks: SpotifyTrack[] }> { const id = this.extractId(artistId); const params = { market: country }; return await this.makeRequest<{ tracks: SpotifyTrack[] }>( `artists/${id}/top-tracks`, token, params ); }

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/latiftplgu/Spotify-OAuth-MCP-server'

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