Skip to main content
Glama
fborello

MCP Spotify Server

by fborello

spotify_set_tokens

Complete Spotify authentication by providing the authorization code received after user login to enable music playback and playlist management.

Instructions

Conclui a autenticação com o código recebido do Spotify

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesCódigo de autorização retornado pelo Spotify após login

Implementation Reference

  • The main handler function that takes the authorization code and exchanges it for Spotify access and refresh tokens using SpotifyAuth, returning success or error message.
    async setTokens(code: string) {
      try {
        const tokens = await this.spotifyAuth.exchangeCodeForTokens(code);
        return {
          content: [
            {
              type: 'text',
              text: '✅ Autenticação com Spotify concluída com sucesso!',
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `❌ Erro na autenticação: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
        };
      }
    }
  • Input schema for the spotify_set_tokens tool, defining the required 'code' string parameter.
    {
      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'],
      },
    },
  • src/index.ts:265-266 (registration)
    Tool dispatch registration in the CallToolRequestSchema handler switch statement, routing calls to spotifyTools.setTokens.
    case 'spotify_set_tokens':
      return await spotifyTools.setTokens(args.code);

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