Skip to main content
Glama

checkUsersSavedAlbums

Verify which Spotify albums are saved in your "Your Music" library by checking up to 20 album IDs at once.

Instructions

Check if albums are saved in the user's "Your Music" library

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
albumIdsYesArray of Spotify album IDs to check (max 20)

Implementation Reference

  • The handler function that implements the tool logic: validates input, calls Spotify API to check if albums are saved (spotifyApi.currentUser.albums.hasSavedAlbums), formats results as numbered list of album IDs with saved status.
    handler: async (args, _extra: SpotifyHandlerExtra) => { const { albumIds } = args; if (albumIds.length === 0) { return { content: [ { type: 'text', text: 'Error: No album IDs provided', }, ], }; } try { const savedStatus = await handleSpotifyRequest(async (spotifyApi) => { return await spotifyApi.currentUser.albums.hasSavedAlbums(albumIds); }); const formattedResults = albumIds .map((albumId, i) => { const isSaved = savedStatus[i]; return `${i + 1}. ${albumId}: ${isSaved ? 'Saved' : 'Not saved'}`; }) .join('\n'); return { content: [ { type: 'text', text: `# Album Save Status\n\n${formattedResults}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error checking saved albums: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } }, };
  • Tool name, description, and input schema: albumIds as array of strings (max 20).
    name: 'checkUsersSavedAlbums', description: 'Check if albums are saved in the user\'s "Your Music" library', schema: { albumIds: z .array(z.string()) .max(20) .describe('Array of Spotify album IDs to check (max 20)'), },
  • src/albums.ts:299-304 (registration)
    Includes the tool in the albumTools array export for later registration.
    export const albumTools = [ getAlbums, getAlbumTracks, saveOrRemoveAlbumForUser, checkUsersSavedAlbums, ];
  • src/index.ts:12-14 (registration)
    Registers the tool on the MCP server by iterating over albumTools (which includes checkUsersSavedAlbums) and calling server.tool with its properties.
    [...readTools, ...playTools, ...albumTools].forEach((tool) => { server.tool(tool.name, tool.description, tool.schema, tool.handler); });

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