Skip to main content
Glama
igorgarbuz

Spotify MCP Node Server

by igorgarbuz

getUserPlaylists

Retrieve a list of the current user's Spotify playlists, with optional limit control for managing large collections.

Instructions

Get a list of the current user's playlists on Spotify

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of playlists to return (1-50)

Implementation Reference

  • The main handler function for the getUserPlaylists tool. Fetches the current user's playlists from Spotify API using handleSpotifyRequest, handles empty case, formats a numbered list with name, track count, and ID, returns as markdown text content.
      handler: async (args, extra: SpotifyHandlerExtra) => {
        const { limit = 50 } = args;
    
        const playlists = await handleSpotifyRequest(async (spotifyApi) => {
          return await spotifyApi.currentUser.playlists.playlists(
            limit as MaxInt<50>,
          );
        });
    
        if (playlists.items.length === 0) {
          return {
            content: [
              {
                type: 'text',
                text: "You don't have any playlists on Spotify",
              },
            ],
          };
        }
    
        const formattedPlaylists = playlists.items
          .map((playlist, i) => {
            const tracksTotal = playlist.tracks?.total ? playlist.tracks.total : 0;
            return `${i + 1}. "${playlist.name}" (${tracksTotal} tracks) - ID: ${
              playlist.id
            }`;
          })
          .join('\n');
    
        return {
          content: [
            {
              type: 'text',
              text: `# Your Spotify Playlists\n\n${formattedPlaylists}`,
            },
          ],
        };
      },
    };
  • Type definition for the tool parameters and Zod input schema defining optional 'limit' parameter between 1 and 50.
    const getUserPlaylists: tool<{
      limit: z.ZodOptional<z.ZodNumber>;
    }> = {
      name: 'getUserPlaylists',
      description: "Get a list of the current user's playlists on Spotify",
      schema: {
        limit: z
          .number()
          .min(1)
          .max(50)
          .optional()
          .describe('Maximum number of playlists to return (1-50)'),
      },
  • src/read.ts:521-529 (registration)
    The getUserPlaylists tool is included in the exported readTools array for further registration.
    export const readTools = [
      searchSpotify,
      getNowPlaying,
      getUserPlaylists,
      getPlaylistTracks,
      getRecentlyPlayed,
      getFollowedArtists,
      getUserTopItems,
    ];
  • src/index.ts:12-14 (registration)
    All tools from readTools (including getUserPlaylists) are registered to the MCP server instance using the server.tool method.
    [...playTools, ...readTools, ...writeTools].forEach((tool) => {
      server.tool(tool.name, tool.description, tool.schema, tool.handler);
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Get a list' implies a read-only operation, it doesn't specify authentication requirements, rate limits, pagination behavior, or what data is returned. For a tool that accesses user data, this represents significant gaps in behavioral transparency.

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, clear sentence that efficiently communicates the core purpose without any wasted words. It's appropriately sized for a simple retrieval tool and gets straight to the point.

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 and no output schema, the description is insufficiently complete. It doesn't explain what information is returned about each playlist, whether authentication is required, how results are structured, or any limitations. Given the lack of structured metadata, the description should provide more contextual information.

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?

The schema description coverage is 100%, with the single parameter 'limit' fully documented in the schema. The description adds no parameter information beyond what's already in the structured schema, so it meets the baseline expectation but doesn't provide additional semantic context.

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 a list') and resource ('current user's playlists on Spotify'), making the purpose immediately understandable. However, it doesn't distinguish this tool from similar playlist-related tools like 'getPlaylistTracks' or 'createPlaylist', which would require explicit differentiation to earn a perfect score.

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. With sibling tools like 'getPlaylistTracks' (for specific playlist details) and 'createPlaylist' (for creating new playlists), there's no indication of when this general playlist listing tool is appropriate versus those more specialized options.

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/igorgarbuz/spotify-mcp'

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