getFollowedArtists
Retrieve a list of artists you follow on Spotify with pagination support for browsing large collections.
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:380-436 (handler)Full implementation of the 'getFollowedArtists' tool, including input schema validation with Zod and the async handler that fetches and formats the list of followed artists using Spotify's currentUser.followedArtists API endpoint.const getFollowedArtists: tool<{ after: z.ZodOptional<z.ZodString>; limit: z.ZodOptional<z.ZodNumber>; }> = { name: 'getFollowedArtists', description: 'Get a list of artists the user is following on Spotify', 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)'), }, 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:521-529 (registration)Adds 'getFollowedArtists' to the readTools export array, which collects all read-related tools for registration.export const readTools = [ searchSpotify, getNowPlaying, getUserPlaylists, getPlaylistTracks, getRecentlyPlayed, getFollowedArtists, getUserTopItems, ];
- src/index.ts:4-14 (registration)Imports readTools and registers all tools (including getFollowedArtists) with the MCP server by calling server.tool() for each.import { readTools } from './read.js'; import { writeTools } from './write.js'; const server = new McpServer({ name: 'spotify-controller', version: '1.0.0', }); [...playTools, ...readTools, ...writeTools].forEach((tool) => { server.tool(tool.name, tool.description, tool.schema, tool.handler); });