Skip to main content
Glama

get_top_tracks

Retrieve your most frequently played Spotify tracks from recent weeks, months, or all-time listening history to analyze personal music preferences and create data-driven playlists.

Instructions

Discover your most listened-to tracks based on actual listening history across different time periods.

🎯 USE CASES: • Understand your personal music listening patterns • Create "Year in Music" summaries and personal statistics • Build playlists based on your actual favorite songs • Share your top music with friends and social media • Track changes in musical preferences over time

📝 WHAT IT RETURNS: • Your most played tracks ranked by listening frequency • Track information with play count estimates • Time-period specific listening statistics • Artist and album information for top tracks • Insights into your musical preferences and habits

🔍 EXAMPLES: • "What are my top tracks this month?" • "Show my most listened songs of all time" • "Get my top 20 tracks from the last 6 months" • "What songs have I been playing on repeat recently?"

⏰ TIME PERIODS: • 'short_term' - Last 4 weeks of listening history • 'medium_term' - Last 6 months of musical activity • 'long_term' - All-time listening patterns and favorites • Compare across periods to see taste evolution

📊 LISTENING INSIGHTS: • Discover patterns in your music consumption • Identify your most-loved songs across different eras • Perfect for building "best of" personal playlists • Great for music discovery based on your actual preferences • Useful for understanding your musical identity

💡 PERSONAL ANALYTICS: • Track how your taste evolves over time • Identify seasonal listening patterns • Use for building recommendation systems • Share musical identity with others • Create data-driven personal playlists

⚠️ REQUIREMENTS: • Valid Spotify access token with user-top-read scope • Sufficient listening history for accurate results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tokenYesSpotify access token for authentication
timeRangeNomedium_term
limitNo

Implementation Reference

  • The handler function for the 'get_top_tracks' MCP tool. It destructures the input arguments (token, timeRange, limit) and delegates execution to SpotifyService.getTopTracks.
    handler: async (args: any, spotifyService: SpotifyService) => {
      const { token, timeRange = "medium_term", limit = 20 } = args;
      return await spotifyService.getTopTracks(token, timeRange, limit);
    },
  • Zod schema definition for the 'get_top_tracks' tool inputs: Spotify access token, time range (short_term, medium_term, long_term), and optional limit (default 20).
    schema: createSchema({
      token: commonSchemas.token(),
      timeRange: commonSchemas.timeRange(),
      limit: commonSchemas.limit(1, 50, 20),
    }),
  • Full tool registration object for 'get_top_tracks' within the trackTools export, including title, description, schema, and handler. This object is imported and spread into the main allTools registry.
      get_top_tracks: {
        title: "Get User's Top Tracks",
        description: `Discover your most listened-to tracks based on actual listening history across different time periods.
    
    🎯 USE CASES:
    • Understand your personal music listening patterns
    • Create "Year in Music" summaries and personal statistics
    • Build playlists based on your actual favorite songs
    • Share your top music with friends and social media
    • Track changes in musical preferences over time
    
    📝 WHAT IT RETURNS:
    • Your most played tracks ranked by listening frequency
    • Track information with play count estimates
    • Time-period specific listening statistics
    • Artist and album information for top tracks
    • Insights into your musical preferences and habits
    
    🔍 EXAMPLES:
    • "What are my top tracks this month?"
    • "Show my most listened songs of all time"
    • "Get my top 20 tracks from the last 6 months"
    • "What songs have I been playing on repeat recently?"
    
    ⏰ TIME PERIODS:
    • 'short_term' - Last 4 weeks of listening history
    • 'medium_term' - Last 6 months of musical activity
    • 'long_term' - All-time listening patterns and favorites
    • Compare across periods to see taste evolution
    
    📊 LISTENING INSIGHTS:
    • Discover patterns in your music consumption
    • Identify your most-loved songs across different eras
    • Perfect for building "best of" personal playlists
    • Great for music discovery based on your actual preferences
    • Useful for understanding your musical identity
    
    💡 PERSONAL ANALYTICS:
    • Track how your taste evolves over time
    • Identify seasonal listening patterns
    • Use for building recommendation systems
    • Share musical identity with others
    • Create data-driven personal playlists
    
    ⚠️ REQUIREMENTS:
    • Valid Spotify access token with user-top-read scope
    • Sufficient listening history for accurate results`,
        schema: createSchema({
          token: commonSchemas.token(),
          timeRange: commonSchemas.timeRange(),
          limit: commonSchemas.limit(1, 50, 20),
        }),
        handler: async (args: any, spotifyService: SpotifyService) => {
          const { token, timeRange = "medium_term", limit = 20 } = args;
          return await spotifyService.getTopTracks(token, timeRange, limit);
        },
      },
  • Core implementation in SpotifyService that performs the actual Spotify API call to retrieve user's top tracks for the specified time range and limit.
    async getTopTracks(
      token: string,
      timeRange: "short_term" | "medium_term" | "long_term" = "medium_term",
      limit: number = 20
    ): Promise<TopItemsResponse<SpotifyTrack>> {
      const params = {
        time_range: timeRange,
        limit: Math.min(limit, 50),
      };
      return await this.makeRequest<TopItemsResponse<SpotifyTrack>>(
        "me/top/tracks",
        token,
        params
      );
    }
  • Central tools registry where trackTools (containing get_top_tracks) is spread into allTools, making it available to the ToolRegistrar for MCP tool exposure.
    export const allTools: ToolsRegistry = {
      ...albumTools,
    
      ...artistTools,
    
      ...trackTools,
    
      ...playlistTools,
    
      ...playbackTools,
    
      ...userTools,
    
      ...searchTools,
    };
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds useful context like authentication requirements ('Valid Spotify access token with user-top-read scope') and data prerequisites ('Sufficient listening history for accurate results'), but does not cover potential limitations like rate limits, error conditions, or response format details beyond high-level return types.

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

Conciseness2/5

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

The description is overly verbose and repetitive, with multiple sections (USE CASES, WHAT IT RETURNS, EXAMPLES, TIME PERIODS, LISTENING INSIGHTS, PERSONAL ANALYTICS, REQUIREMENTS) that contain overlapping information. Sentences like 'Perfect for building "best of" personal playlists' and 'Great for music discovery based on your actual preferences' could be condensed without losing meaning.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 3 parameters, no annotations, and no output schema, the description provides substantial context: purpose, use cases, return information, examples, time period details, and requirements. It adequately covers the tool's functionality, though it lacks explicit parameter documentation and detailed behavioral traits like error handling.

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

Parameters4/5

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

Schema description coverage is low at 33%, with only the 'token' parameter documented. The description compensates by explaining 'timeRange' options in the 'TIME PERIODS' section and implying 'limit' usage in examples like 'Get my top 20 tracks', though it doesn't explicitly name or detail all parameters. This adds significant value beyond the sparse schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Discover your most listened-to tracks based on actual listening history across different time periods.' It specifies the verb ('discover'), resource ('most listened-to tracks'), and scope ('listening history across different time periods'), distinguishing it from siblings like get_recently_played or get_liked_tracks.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool through 'USE CASES' and 'EXAMPLES' sections, such as understanding personal listening patterns or creating summaries. However, it does not explicitly state when NOT to use it or name specific alternatives among siblings (e.g., get_top_artists for artist-focused analysis).

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

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