Skip to main content
Glama

get_album_tracks

Retrieve track listings and details from Spotify albums using album ID or URI, with options to limit results and paginate through tracks.

Instructions

Get Spotify catalog information for an album's tracks

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe Spotify ID or URI for the album
limitNoMaximum number of tracks to return (1-50)
offsetNoThe index of the first track to return

Implementation Reference

  • The core handler function that implements the get_album_tracks tool. It extracts the album ID, validates pagination parameters (limit 1-50, offset >=0), and makes a Spotify API request to fetch the album's tracks.
    async getAlbumTracks(args: AlbumTracksArgs) { const albumId = this.extractAlbumId(args.id); const { limit = 20, offset = 0 } = args; if (limit < 1 || limit > 50) { throw new McpError( ErrorCode.InvalidParams, 'Limit must be between 1 and 50' ); } if (offset < 0) { throw new McpError( ErrorCode.InvalidParams, 'Offset must be non-negative' ); } const params = { limit, offset }; return this.api.makeRequest( `/albums/${albumId}/tracks${this.api.buildQueryString(params)}` ); }
  • src/index.ts:252-278 (registration)
    Registers the get_album_tracks tool in the MCP server's listTools response, defining its name, description, and input schema.
    { name: 'get_album_tracks', description: 'Get Spotify catalog information for an album\'s tracks', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'The Spotify ID or URI for the album' }, limit: { type: 'number', description: 'Maximum number of tracks to return (1-50)', minimum: 1, maximum: 50, default: 20 }, offset: { type: 'number', description: 'The index of the first track to return', minimum: 0, default: 0 } }, required: ['id'] }, },
  • src/index.ts:758-764 (registration)
    Handles incoming callTool requests for get_album_tracks by validating arguments and delegating execution to the AlbumsHandler instance.
    case 'get_album_tracks': { const args = this.validateArgs<AlbumTracksArgs>(request.params.arguments, ['id']); const result = await this.albumsHandler.getAlbumTracks(args); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
  • TypeScript type definitions for AlbumTracksArgs (used in handler and validation), extending AlbumArgs and PaginationParams for input structure.
    import { PaginationParams } from './common.js'; export interface AlbumArgs { id: string; } export interface AlbumTracksArgs extends AlbumArgs, PaginationParams {} export interface MultipleAlbumsArgs { ids: string[]; } export interface NewReleasesArgs extends PaginationParams { country?: string; }
  • Helper method to normalize Spotify album IDs or URIs to plain IDs, used in getAlbumTracks.
    private extractAlbumId(id: string): string { return id.startsWith('spotify:album:') ? id.split(':')[2] : 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/superseoworld/mcp-spotify'

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