checkUsersSavedAlbums
Verify which albums are saved in your Spotify library by checking up to 20 album IDs at once. This tool helps you confirm album status in "Your Music" without manual searching.
Instructions
Check if albums are saved in the user's "Your Music" library
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| albumIds | Yes | Array of Spotify album IDs to check (max 20) |
Implementation Reference
- src/albums.ts:250-296 (handler)The main handler function for the 'checkUsersSavedAlbums' tool. It validates input, calls the Spotify API to check saved status for the provided album IDs, formats the results, and returns a markdown response with the status of each album.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) }`, }, ], }; } },
- src/albums.ts:244-249 (schema)Zod schema defining the input parameters for the tool: an array of up to 20 Spotify album IDs.schema: { albumIds: z .array(z.string()) .max(20) .describe('Array of Spotify album IDs to check (max 20)'), },
- src/index.ts:12-14 (registration)Registration of all tools, including 'checkUsersSavedAlbums' from albumTools, by calling server.tool() with name, description, schema, and handler.[...readTools, ...playTools, ...albumTools].forEach((tool) => { server.tool(tool.name, tool.description, tool.schema, tool.handler); });
- src/albums.ts:299-304 (registration)Export of albumTools array including the checkUsersSavedAlbums tool, which is later imported and registered in index.ts.export const albumTools = [ getAlbums, getAlbumTracks, saveOrRemoveAlbumForUser, checkUsersSavedAlbums, ];