Skip to main content
Glama
fborello

MCP Spotify Server

by fborello

spotify_create_playlist

Create a new Spotify playlist with custom name, description, and privacy settings to organize your music collection.

Instructions

Cria uma nova playlist no Spotify

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionNoDescrição da playlist (opcional)
nameYesNome da playlist
publicNoSe a playlist deve ser pública (padrão: false)

Implementation Reference

  • The core handler function `createPlaylist` in the SpotifyTools class that implements the tool logic: ensures valid token, fetches user ID, creates the playlist via Spotify API using fetch, and returns success/error details.
    /**
     * Cria uma nova playlist usando fetch direto
     */
    async createPlaylist(name: string, description?: string, isPublic: boolean = false) {
      try {
        await this.spotifyAuth.ensureValidToken();
        const spotifyApi = this.spotifyAuth.getSpotifyApi();
        const accessToken = await this.spotifyAuth.ensureValidToken();
    
        // Primeiro, obter o ID do usuário atual
        const userResponse = await fetch('https://api.spotify.com/v1/me', {
          headers: {
            'Authorization': `Bearer ${accessToken}`,
            'Content-Type': 'application/json'
          }
        });
    
        if (!userResponse.ok) {
          throw new Error(`Erro ao obter dados do usuário: ${userResponse.status}`);
        }
    
        const userData = await userResponse.json();
        const userId = userData.id;
    
        // Criar a playlist
        const playlistResponse = await fetch(`https://api.spotify.com/v1/users/${userId}/playlists`, {
          method: 'POST',
          headers: {
            'Authorization': `Bearer ${accessToken}`,
            'Content-Type': 'application/json'
          },
          body: JSON.stringify({
            name: name,
            description: description || '',
            public: isPublic
          })
        });
    
        if (!playlistResponse.ok) {
          const errorData = await playlistResponse.json();
          throw new Error(`Erro ao criar playlist: ${playlistResponse.status} - ${errorData.error?.message || 'Erro desconhecido'}`);
        }
    
        const playlist = await playlistResponse.json();
    
        return {
          content: [
            {
              type: 'text',
              text: `✅ Playlist "${name}" criada com sucesso!\n\n**Detalhes:**\n- Nome: ${playlist.name}\n- ID: ${playlist.id}\n- Descrição: ${playlist.description || 'Sem descrição'}\n- Pública: ${playlist.public ? 'Sim' : 'Não'}\n- Link: ${playlist.external_urls.spotify}`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `❌ Erro ao criar playlist: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
        };
      }
    }
  • Tool schema definition in the ListTools response, including name, description, and inputSchema with properties name (required string), description (optional string), public (boolean).
    {
      name: 'spotify_create_playlist',
      description: 'Cria uma nova playlist no Spotify',
      inputSchema: {
        type: 'object',
        properties: {
          name: {
            type: 'string',
            description: 'Nome da playlist',
          },
          description: {
            type: 'string',
            description: 'Descrição da playlist (opcional)',
          },
          public: {
            type: 'boolean',
            description: 'Se a playlist deve ser pública (padrão: false)',
          },
        },
        required: ['name'],
      },
    },
  • src/index.ts:298-299 (registration)
    Registration in the CallToolRequest handler switch statement that dispatches to the SpotifyTools.createPlaylist method with parsed arguments.
    case 'spotify_create_playlist':
      return await spotifyTools.createPlaylist(args.name, args.description, args.public);
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states it creates a playlist but doesn't disclose behavioral traits like required permissions, whether it's idempotent, error handling, or what the response includes. This is a significant gap for a mutation tool with zero annotation coverage.

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 sentence in Portuguese with zero waste. It's appropriately sized and front-loaded, clearly stating the tool's purpose without unnecessary elaboration.

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 this is a mutation tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral aspects, prerequisites, and expected outcomes, making it inadequate for an AI agent to fully understand how to invoke it correctly.

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?

Schema description coverage is 100%, so the schema already documents all three parameters (name, description, public) with descriptions. The description adds no additional meaning beyond what the schema provides, meeting the baseline of 3 when schema does the heavy lifting.

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 'Cria uma nova playlist no Spotify' clearly states the action (creates) and resource (new playlist on Spotify) in Portuguese. It's specific about what the tool does, though it doesn't explicitly differentiate from sibling tools like 'spotify_playlists' which likely lists playlists rather than creates them.

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 via spotify_auth), exclusions, or contextual cues for choosing this over other playlist-related tools.

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