Skip to main content
Glama
fborello

MCP Spotify Server

by fborello

spotify_auth

Start Spotify authentication to enable music search, playback control, playlist management, and device operations through natural language commands.

Instructions

Inicia o processo de autenticação com o Spotify

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main handler function that executes the logic for the 'spotify_auth' tool: checks authentication status, generates and opens the authorization URL, returns success or instructions.
    async authenticate() {
      if (this.spotifyAuth.isAuthenticated()) {
        return {
          content: [
            {
              type: 'text',
              text: '✅ Já autenticado com o Spotify!',
            },
          ],
        };
      }
    
      const authUrl = this.spotifyAuth.getAuthorizationUrl();
      
      // Abrir navegador automaticamente
      await open(authUrl);
      
      return {
        content: [
          {
            type: 'text',
            text: `🔐 Abra este link no navegador para autenticar com o Spotify:\n\n${authUrl}\n\nApós autorizar, você receberá um código. Use o comando spotify_set_tokens com o código recebido.`,
          },
        ],
      };
    }
  • Input schema definition for 'spotify_auth' tool (empty object, no parameters required). Part of the tool registration.
    name: 'spotify_auth',
    description: 'Inicia o processo de autenticação com o Spotify',
    inputSchema: {
      type: 'object',
      properties: {},
    },
  • src/index.ts:46-53 (registration)
    Registration of the 'spotify_auth' tool in the ListTools response, including name, description, and schema.
    {
      name: 'spotify_auth',
      description: 'Inicia o processo de autenticação com o Spotify',
      inputSchema: {
        type: 'object',
        properties: {},
      },
    },
  • Dispatch handler in CallToolRequestSchema that invokes the spotify_auth implementation.
    case 'spotify_auth':
      return await spotifyTools.authenticate();
  • Helper method called by the handler to generate the Spotify OAuth authorization URL with required scopes.
    getAuthorizationUrl(): string {
      const scopes = [
        'user-read-private',
        'user-read-email',
        'user-read-playback-state',
        'user-modify-playback-state',
        'user-read-currently-playing',
        'playlist-read-private',
        'playlist-read-collaborative',
        'playlist-modify-public',
        'playlist-modify-private',
        'user-library-read',
        'user-library-modify',
        'user-top-read',
        'user-read-recently-played'
      ];
    
      return this.spotifyApi.createAuthorizeURL(scopes, 'state');
    }

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