getFollowedArtists
Retrieve a list of artists you follow on Spotify, with options to paginate results and limit the number returned.
Instructions
Get a list of artists the user is following on Spotify
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| after | No | The last artist ID from the previous request. Cursor for pagination. | |
| limit | No | Maximum number of artists to return (1-50) |
Implementation Reference
- src/read.ts:400-435 (handler)The handler function that retrieves the list of artists followed by the user using the Spotify API, handles pagination with 'after' and 'limit', formats the results as a numbered list with names and IDs, and returns a markdown text response.handler: async (args, extra: SpotifyHandlerExtra) => { const { limit = 50, after } = args; const artists = await handleSpotifyRequest(async (spotifyApi) => { return await spotifyApi.currentUser.followedArtists( after, limit as MaxInt<50>, ); }); if (artists.artists.items.length === 0) { return { content: [ { type: 'text', text: "User doesn't follow any artists on Spotify", }, ], }; } const formattedArtists = artists.artists.items .map((artist, i) => { return `${i + 1}. "${artist.name}" - ID: ${artist.id}`; }) .join('\n'); return { content: [ { type: 'text', text: `# Artists You Follow\n\n${formattedArtists}`, }, ], }; },
- src/read.ts:386-399 (schema)Zod schema for input parameters: optional 'after' for pagination cursor and optional 'limit' (1-50) for number of artists.schema: { after: z .string() .optional() .describe( 'The last artist ID from the previous request. Cursor for pagination.', ), limit: z .number() .min(1) .max(50) .optional() .describe('Maximum number of artists to return (1-50)'), },
- src/read.ts:521-529 (registration)Inclusion of getFollowedArtists in the readTools export array, which groups read-related tools.export const readTools = [ searchSpotify, getNowPlaying, getUserPlaylists, getPlaylistTracks, getRecentlyPlayed, getFollowedArtists, getUserTopItems, ];
- src/index.ts:12-14 (registration)MCP server registration loop that registers all tools, including getFollowedArtists from readTools, by calling server.tool() with name, description, schema, and handler.[...playTools, ...readTools, ...writeTools].forEach((tool) => { server.tool(tool.name, tool.description, tool.schema, tool.handler); });