Skip to main content
Glama
fborello

MCP Spotify Server

by fborello

spotify_playlists

Retrieve your Spotify playlists to view and manage your music collections. Get a list of your saved playlists with customizable limits for easy organization and access.

Instructions

Lista playlists do usuário

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNúmero máximo de playlists (padrão: 20)

Implementation Reference

  • The main handler function getPlaylists() that fetches user's playlists from Spotify API, formats them into a text response, and handles errors.
    async getPlaylists(limit: number = 20) {
      try {
        await this.spotifyAuth.ensureValidToken();
        const spotifyApi = this.spotifyAuth.getSpotifyApi();
    
        const response = await spotifyApi.getUserPlaylists({ limit });
        const playlists = response.body.items;
    
        if (playlists.length === 0) {
          return {
            content: [
              {
                type: 'text',
                text: '❌ Nenhuma playlist encontrada',
              },
            ],
          };
        }
    
        let content = `📋 **Suas playlists:**\n\n`;
        playlists.forEach((playlist: any, index: number) => {
          content += `${index + 1}. **${playlist.name}**\n`;
          content += `   ID: ${playlist.id}\n`;
          content += `   Descrição: ${playlist.description || 'Sem descrição'}\n`;
          content += `   Total de músicas: ${playlist.tracks.total}\n`;
          content += `   Pública: ${playlist.public ? 'Sim' : 'Não'}\n`;
          content += `   Link: ${playlist.external_urls.spotify}\n\n`;
        });
    
        return {
          content: [
            {
              type: 'text',
              text: content,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `❌ Erro ao obter playlists: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
        };
      }
    }
  • Input schema for the spotify_playlists tool, specifying an optional 'limit' parameter.
    {
      name: 'spotify_playlists',
      description: 'Lista playlists do usuário',
      inputSchema: {
        type: 'object',
        properties: {
          limit: {
            type: 'number',
            description: 'Número máximo de playlists (padrão: 20)',
          },
        },
      },
    },
  • src/index.ts:292-294 (registration)
    Registers the tool handler in the CallToolRequestSchema switch statement, delegating to spotifyTools.getPlaylists().
    case 'spotify_playlists':
      return await spotifyTools.getPlaylists(args.limit);
  • src/index.ts:30-32 (registration)
    Instantiates the SpotifyTools class which contains the tool implementations.
    const spotifyAuth = new SpotifyAuth(config);
    const spotifyTools = new SpotifyTools(spotifyAuth);
  • TypeScript interface defining the structure of a Spotify playlist, used in the codebase.
    export interface SpotifyPlaylist {
      id: string;
      name: string;
      description: string;
      owner: {
        display_name: string;
      };
      tracks: {
        total: number;
      };
      images: Array<{
        url: string;
        width: number;
        height: number;
      }>;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states it lists user playlists but doesn't mention if it requires authentication, how it handles pagination, rate limits, or what the return format is. This leaves significant gaps for a tool that likely interacts with user data.

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, efficient phrase in Portuguese ('Lista playlists do usuário') that directly states the purpose without any wasted words. It's appropriately sized and front-loaded, making it easy to parse quickly.

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?

Given the lack of annotations and output schema, the description is incomplete. It doesn't address authentication needs, return format, or error handling, which are crucial for a tool that likely requires user authorization and returns a list of playlists. This leaves the agent with insufficient context for reliable use.

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 input schema has 100% description coverage, with the 'limit' parameter well-documented. The description adds no additional parameter information beyond what the schema provides, so it meets the baseline score of 3 without compensating or adding extra value.

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 'Lista playlists do usuário' clearly states the verb ('Lista') and resource ('playlists do usuário'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'spotify_search' or 'spotify_play_playlist', which might also involve playlists, so it doesn't reach the highest 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. It doesn't mention prerequisites (e.g., authentication status), exclusions, or comparisons to siblings like 'spotify_search' for finding playlists, leaving the agent with minimal context for selection.

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/fborello/MCPSpotify'

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