Skip to main content
Glama
makesh-kumar

Spotify MCP Server

by makesh-kumar

getAlbums

Retrieve detailed Spotify album information by providing album IDs, enabling access to track lists, release dates, and artist data for up to 20 albums.

Instructions

Get detailed information about one or more albums by their Spotify IDs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
albumIdsYesA single album ID or array of album IDs (max 20)

Implementation Reference

  • The handler function that implements the core logic of the getAlbums tool. It processes albumIds input, fetches album data from Spotify API using handleSpotifyRequest, handles single or multiple albums, formats the response as markdown text blocks, and catches errors.
    handler: async (args, _extra: SpotifyHandlerExtra) => {
      const { albumIds } = args;
      const ids = Array.isArray(albumIds) ? albumIds : [albumIds];
    
      if (ids.length === 0) {
        return {
          content: [
            {
              type: 'text',
              text: 'Error: No album IDs provided',
            },
          ],
        };
      }
    
      try {
        const albums = await handleSpotifyRequest(async (spotifyApi) => {
          return ids.length === 1
            ? [await spotifyApi.albums.get(ids[0])]
            : await spotifyApi.albums.get(ids);
        });
    
        if (albums.length === 0) {
          return {
            content: [
              {
                type: 'text',
                text: 'No albums found for the provided IDs',
              },
            ],
          };
        }
    
        if (albums.length === 1) {
          const album = albums[0];
          const artists = album.artists.map((a) => a.name).join(', ');
          const releaseDate = album.release_date;
          const totalTracks = album.total_tracks;
          const albumType = album.album_type;
    
          return {
            content: [
              {
                type: 'text',
                text: `# Album Details\n\n**Name**: "${album.name}"\n**Artists**: ${artists}\n**Release Date**: ${releaseDate}\n**Type**: ${albumType}\n**Total Tracks**: ${totalTracks}\n**ID**: ${album.id}`,
              },
            ],
          };
        }
    
        const formattedAlbums = albums
          .map((album, i) => {
            if (!album) return `${i + 1}. [Album not found]`;
    
            const artists = album.artists.map((a) => a.name).join(', ');
            return `${i + 1}. "${album.name}" by ${artists} (${album.release_date}) - ${album.total_tracks} tracks - ID: ${album.id}`;
          })
          .join('\n');
    
        return {
          content: [
            {
              type: 'text',
              text: `# Multiple Albums\n\n${formattedAlbums}`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error getting albums: ${
                error instanceof Error ? error.message : String(error)
              }`,
            },
          ],
        };
      }
    },
  • Zod schema defining the input for getAlbums: albumIds as string or array of strings (max 20).
    schema: {
      albumIds: z
        .union([z.string(), z.array(z.string()).max(20)])
        .describe('A single album ID or array of album IDs (max 20)'),
    },
  • src/index.ts:12-14 (registration)
    Registers the getAlbums tool (included in albumTools) with the MCP server by calling server.tool() for each tool in the combined array.
    [...readTools, ...playTools, ...albumTools].forEach((tool) => {
      server.tool(tool.name, tool.description, tool.schema, tool.handler);
    });
  • src/albums.ts:299-304 (registration)
    Exports array of album-related tools including getAlbums for registration in index.ts.
    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 full burden but lacks behavioral details. It doesn't disclose whether this is a read-only operation, requires authentication, has rate limits, returns paginated results, or what 'detailed information' includes. The mention of 'one or more albums' hints at batch capability, but this is already covered by the schema.

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 front-loads the core purpose without unnecessary words. Every part ('Get detailed information', 'about one or more albums', 'by their Spotify IDs') contributes directly to understanding the tool's function.

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?

For a tool with no annotations, no output schema, and a single parameter, the description is incomplete. It doesn't explain what 'detailed information' entails (e.g., track list, release date), authentication requirements, error handling, or how results are structured, leaving gaps for an AI agent to use it effectively.

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?

Schema description coverage is 100%, with the schema fully documenting the 'albumIds' parameter as accepting a string or array (max 20 items). The description adds minimal value beyond this, only reiterating 'one or more albums by their Spotify IDs' without explaining ID format or usage nuances, meeting the baseline for high schema coverage.

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 action ('Get detailed information') and resource ('about one or more albums by their Spotify IDs'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'checkUsersSavedAlbums' or 'getAlbumTracks', which also involve album data but serve different purposes.

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. It doesn't mention prerequisites like authentication, compare to similar tools (e.g., 'searchSpotify' for finding albums by name, 'checkUsersSavedAlbums' for saved status), or specify use cases like retrieving metadata for known IDs.

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

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