Skip to main content
Glama
fborello

MCP Spotify Server

by fborello

spotify_pause

Pause current Spotify playback on your device. Use this tool to temporarily stop music or podcasts during your listening session.

Instructions

Pausa a reprodução atual

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_idNoID do dispositivo (opcional)

Implementation Reference

  • The `pause` method in the `SpotifyTools` class implements the core logic for the `spotify_pause` tool. It ensures a valid token, calls the Spotify API to pause playback on the specified or active device, and returns a success or error message.
    async pause(deviceId?: string) {
      try {
        await this.spotifyAuth.ensureValidToken();
        const spotifyApi = this.spotifyAuth.getSpotifyApi();
    
        const options = deviceId ? { device_id: deviceId } : {};
        await spotifyApi.pause(options);
    
        return {
          content: [
            {
              type: 'text',
              text: '⏸️ Reprodução pausada',
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `❌ Erro ao pausar: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
        };
      }
    }
  • The input schema definition for the `spotify_pause` tool, specifying an optional `device_id` parameter.
    {
      name: 'spotify_pause',
      description: 'Pausa a reprodução atual',
      inputSchema: {
        type: 'object',
        properties: {
          device_id: {
            type: 'string',
            description: 'ID do dispositivo (opcional)',
          },
        },
      },
    },
  • src/index.ts:274-275 (registration)
    The switch case in the `CallToolRequestSchema` handler that routes calls to the `spotify_pause` tool to the `SpotifyTools.pause` method.
    case 'spotify_pause':
      return await spotifyTools.pause(args.device_id);
  • src/index.ts:43-253 (registration)
    The `ListToolsRequestSchema` handler registers the `spotify_pause` tool by including it in the list of available tools with its schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: 'spotify_auth',
            description: 'Inicia o processo de autenticação com o Spotify',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
          {
            name: 'spotify_set_tokens',
            description: 'Conclui a autenticação com o código recebido do Spotify',
            inputSchema: {
              type: 'object',
              properties: {
                code: {
                  type: 'string',
                  description: 'Código de autorização retornado pelo Spotify após login',
                },
              },
              required: ['code'],
            },
          },
          {
            name: 'spotify_search',
            description: 'Busca por músicas, artistas, álbuns ou playlists no Spotify',
            inputSchema: {
              type: 'object',
              properties: {
                query: {
                  type: 'string',
                  description: 'Termo de busca (nome da música, artista, etc.)',
                },
                type: {
                  type: 'string',
                  enum: ['track', 'artist', 'album', 'playlist'],
                  description: 'Tipo de conteúdo para buscar',
                },
                limit: {
                  type: 'number',
                  description: 'Número máximo de resultados (padrão: 20)',
                },
              },
              required: ['query', 'type'],
            },
          },
          {
            name: 'spotify_play',
            description: 'Toca uma música específica no Spotify',
            inputSchema: {
              type: 'object',
              properties: {
                track_id: {
                  type: 'string',
                  description: 'ID da música no Spotify',
                },
                device_id: {
                  type: 'string',
                  description: 'ID do dispositivo (opcional)',
                },
              },
              required: ['track_id'],
            },
          },
          {
            name: 'spotify_pause',
            description: 'Pausa a reprodução atual',
            inputSchema: {
              type: 'object',
              properties: {
                device_id: {
                  type: 'string',
                  description: 'ID do dispositivo (opcional)',
                },
              },
            },
          },
          {
            name: 'spotify_resume',
            description: 'Retoma a reprodução pausada',
            inputSchema: {
              type: 'object',
              properties: {
                device_id: {
                  type: 'string',
                  description: 'ID do dispositivo (opcional)',
                },
              },
            },
          },
          {
            name: 'spotify_next',
            description: 'Pula para a próxima música',
            inputSchema: {
              type: 'object',
              properties: {
                device_id: {
                  type: 'string',
                  description: 'ID do dispositivo (opcional)',
                },
              },
            },
          },
          {
            name: 'spotify_previous',
            description: 'Volta para a música anterior',
            inputSchema: {
              type: 'object',
              properties: {
                device_id: {
                  type: 'string',
                  description: 'ID do dispositivo (opcional)',
                },
              },
            },
          },
          {
            name: 'spotify_current_playing',
            description: 'Obtém informações sobre a música que está tocando',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
          {
            name: 'spotify_devices',
            description: 'Lista dispositivos disponíveis para reprodução',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
          {
            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)',
                },
              },
            },
          },
          {
            name: 'spotify_play_playlist',
            description: 'Toca uma playlist específica',
            inputSchema: {
              type: 'object',
              properties: {
                playlist_id: {
                  type: 'string',
                  description: 'ID da playlist no Spotify',
                },
                device_id: {
                  type: 'string',
                  description: 'ID do dispositivo (opcional)',
                },
              },
              required: ['playlist_id'],
            },
          },
          {
            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'],
            },
          },
          {
            name: 'spotify_add_tracks_to_playlist',
            description: 'Adiciona músicas a uma playlist existente',
            inputSchema: {
              type: 'object',
              properties: {
                playlist_id: {
                  type: 'string',
                  description: 'ID da playlist no Spotify',
                },
                track_ids: {
                  type: 'array',
                  items: {
                    type: 'string',
                  },
                  description: 'Array com os IDs das músicas para adicionar',
                },
              },
              required: ['playlist_id', 'track_ids'],
            },
          },
        ],
      };
    });

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