Skip to main content
Glama
marcelmarais

Spotify MCP Server

by marcelmarais

getAlbumTracks

Retrieve track listings from Spotify albums with pagination support to manage large collections systematically.

Instructions

Get tracks from a specific album with pagination support

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
albumIdYesThe Spotify ID of the album
limitNoMaximum number of tracks to return (1-50)
offsetNoOffset for pagination (0-based index)

Implementation Reference

  • The main handler function that fetches album tracks from Spotify API, handles pagination, formats track list with artists and durations, and returns formatted text response.
    handler: async (args, _extra: SpotifyHandlerExtra) => {
      const { albumId, limit = 20, offset = 0 } = args;
    
      try {
        const tracks = await handleSpotifyRequest(async (spotifyApi) => {
          return await spotifyApi.albums.tracks(
            albumId,
            undefined,
            limit as MaxInt<50>,
            offset,
          );
        });
    
        if (tracks.items.length === 0) {
          return {
            content: [
              {
                type: 'text',
                text: 'No tracks found in this album',
              },
            ],
          };
        }
    
        const formattedTracks = tracks.items
          .map((track, i) => {
            if (!track) return `${i + 1}. [Track not found]`;
    
            const artists = track.artists.map((a) => a.name).join(', ');
            const duration = formatDuration(track.duration_ms);
            return `${offset + i + 1}. "${track.name}" by ${artists} (${duration}) - ID: ${track.id}`;
          })
          .join('\n');
    
        return {
          content: [
            {
              type: 'text',
              text: `# Album Tracks (${offset + 1}-${offset + tracks.items.length} of ${tracks.total})\n\n${formattedTracks}`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error getting album tracks: ${
                error instanceof Error ? error.message : String(error)
              }`,
            },
          ],
        };
      }
    },
  • Zod schema defining input parameters: albumId (required string), limit (optional 1-50), offset (optional >=0).
    schema: {
      albumId: z.string().describe('The Spotify ID of the album'),
      limit: z
        .number()
        .min(1)
        .max(50)
        .optional()
        .describe('Maximum number of tracks to return (1-50)'),
      offset: z
        .number()
        .min(0)
        .optional()
        .describe('Offset for pagination (0-based index)'),
    },
  • src/albums.ts:299-304 (registration)
    Exports an array of album-related tools including getAlbumTracks, likely used for MCP tool registration.
    export const albumTools = [
      getAlbums,
      getAlbumTracks,
      saveOrRemoveAlbumForUser,
      checkUsersSavedAlbums,
    ];
Behavior2/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 mentions 'pagination support', which is useful, but lacks details on permissions, rate limits, error handling, or response format. For a read operation with no annotation coverage, this leaves significant gaps in understanding how the tool behaves.

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 that directly states the tool's function and key feature (pagination). It is front-loaded with the core purpose and avoids any unnecessary words, making it highly concise and well-structured.

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

Completeness2/5

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

Given the complexity of a read operation with pagination, no annotations, and no output schema, the description is incomplete. It doesn't explain what the return values look like (e.g., track list format), error conditions, or authentication needs, leaving the agent with insufficient context for reliable 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, clearly documenting all parameters (albumId, limit, offset). The description adds no additional meaning beyond what the schema provides, such as examples or edge cases, so it meets the baseline for high schema coverage without enhancing parameter understanding.

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 clearly states the verb ('Get') and resource ('tracks from a specific album'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'getAlbums' or 'getPlaylistTracks', which also retrieve music content, so it misses full sibling distinction.

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. For example, it doesn't mention when to choose this over 'getAlbums' for album details or 'searchSpotify' for broader track searches, leaving the agent without contextual usage cues.

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/marcelmarais/spotify-mcp-server'

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