MCP Spotify Server
Enables interaction with Spotify through LLMs using OAuth2 authentication. Supports music search, playback control, playlist management, and device management through natural language commands.
README
🎵 MCP Spotify Server
Um servidor MCP (Model Context Protocol) que permite interagir com o Spotify através de LLMs. Este servidor fornece ferramentas para buscar música, controlar reprodução, gerenciar playlists e muito mais.
🚀 Funcionalidades
- Autenticação OAuth2 com Spotify
- Busca por músicas, artistas, álbuns e playlists
- Controle de reprodução (tocar, pausar, próximo, anterior)
- Informações da música atual
- Gerenciamento de dispositivos
- Listagem e reprodução de playlists
📋 Pré-requisitos
- Node.js (versão 18 ou superior)
- Conta Spotify (Premium recomendado para funcionalidade completa)
- Aplicação Spotify registrada no Spotify Developer Dashboard
- ngrok (para expor o servidor local)
🛠️ Instalação
-
Clone o repositório:
git clone https://github.com/seu-usuario/MCPSpotify.git cd MCPSpotify -
Instale as dependências:
npm install -
Instale o ngrok:
macOS (com Homebrew):
brew install ngrok/ngrok/ngrokWindows (com Chocolatey):
choco install ngrokLinux:
# Baixe o binário do site oficial curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | sudo tee /etc/apt/sources.list.d/ngrok.list sudo apt update && sudo apt install ngrokOu baixe diretamente do site oficial
-
Configure as variáveis de ambiente:
cp env.example .env -
Edite o arquivo
.envcom suas credenciais:SPOTIFY_CLIENT_ID=seu_client_id_aqui SPOTIFY_CLIENT_SECRET=seu_client_secret_aqui SPOTIFY_REDIRECT_URI=http://localhost:3000/callback -
Configure o MCP (opcional):
Para Claude Desktop:
cp configs/claude-desktop.example.json ~/.claude-desktop/config.json # Edite o arquivo com seu caminho e credenciaisPara Cursor:
cp configs/cursor.example.json ~/.cursor/mcp.json # Edite o arquivo com seu caminho e credenciaisPara outros clientes MCP:
cp mcp-config.example.json mcp-config.json # Edite o arquivo com seu caminho e credenciais
🔧 Configuração do Spotify
- Acesse o Spotify Developer Dashboard
- Clique em "Create App"
- Preencha os dados:
- App name: MCP Spotify Server
- App description: Servidor MCP para integração com Spotify
- Após criar, copie o Client ID e Client Secret
- Clique em "Edit Settings" e adicione
http://localhost:3000/callbacknas Redirect URIs
🌐 Configuração do ngrok
Para que o OAuth do Spotify funcione corretamente, você precisa expor seu servidor local para a internet. O ngrok é a ferramenta recomendada para isso.
1. Crie uma conta no ngrok (opcional mas recomendado)
- Acesse ngrok.com e crie uma conta gratuita
- Isso permite URLs estáveis e remove limitações de tempo
2. Configure o ngrok
# Autentique sua conta (opcional)
ngrok config add-authtoken SEU_TOKEN_AQUI
# Exponha a porta 8080
ngrok http 8080
3. Atualize a Redirect URI
- Copie a URL HTTPS fornecida pelo ngrok (ex:
https://abc123.ngrok.io) - No Spotify Dashboard, adicione
https://abc123.ngrok.io/callbacknas Redirect URIs - Atualize seu arquivo
.env:SPOTIFY_REDIRECT_URI=https://abc123.ngrok.io/callback
4. Inicie o servidor
# Em um terminal, mantenha o ngrok rodando
ngrok http 8080
# Em outro terminal, inicie o servidor
npm run dev
🚀 Uso
Desenvolvimento
# Terminal 1: Inicie o ngrok
ngrok http 8080
# Terminal 2: Inicie o servidor
npm run dev
Produção
npm run build
npm start
🎯 Ferramentas Disponíveis
Autenticação
spotify_auth- Inicia o processo de autenticaçãospotify_set_tokens- Finaliza a autenticação com ocodede retorno
Busca
spotify_search- Busca por músicas, artistas, álbuns ou playlists
Controle de Reprodução
spotify_play- Toca uma música específicaspotify_pause- Pausa a reproduçãospotify_resume- Retoma a reproduçãospotify_next- Pula para a próxima músicaspotify_previous- Volta para a música anterior
Informações
spotify_current_playing- Obtém informações sobre a música atualspotify_devices- Lista dispositivos disponíveisspotify_playlists- Lista playlists do usuário
Playlists
spotify_play_playlist- Toca uma playlist específica
📝 Exemplos de Uso
Fluxo de Autenticação
- Iniciar o login (vai abrir o navegador)
{
"name": "spotify_auth",
"arguments": {}
}
- Depois de autorizar no Spotify, copie o
coderetornado e finalize:
{
"name": "spotify_set_tokens",
"arguments": { "code": "SEU_CODE_AQUI" }
}
Buscar uma música
{
"name": "spotify_search",
"arguments": {
"query": "Bohemian Rhapsody",
"type": "track",
"limit": 5
}
}
Tocar uma música
{
"name": "spotify_play",
"arguments": {
"track_id": "4uLU6hMCjMI75M1A2tKUQC"
}
}
Buscar playlists
{
"name": "spotify_playlists",
"arguments": {
"limit": 10
}
}
🔒 Segurança
- As credenciais do Spotify são armazenadas apenas localmente
- Os tokens de acesso são renovados automaticamente
- Nenhuma informação é enviada para servidores externos (exceto Spotify)
🐛 Solução de Problemas
Erro de Autenticação
- Verifique se as credenciais no
.envestão corretas - Confirme se a Redirect URI está configurada no Spotify Dashboard
- Certifique-se de que o ngrok está rodando e a URL está atualizada no
.env - Verifique se a URL do ngrok no Spotify Dashboard corresponde à URL no arquivo
.env
Dispositivo Não Encontrado
- Certifique-se de que o Spotify está aberto em algum dispositivo
- Verifique se o dispositivo está ativo na sua conta Spotify
Erro de Permissões
- Algumas funcionalidades requerem Spotify Premium
- Verifique se todas as permissões foram concedidas durante a autenticação
Problemas com ngrok
- URL muda a cada reinicialização: Use uma conta ngrok gratuita para URLs estáveis
- Erro de conexão: Verifique se o ngrok está rodando na porta correta (3000)
- Timeout: Certifique-se de que o servidor está rodando antes de iniciar o ngrok
- URL não acessível: Verifique se o firewall não está bloqueando a conexão
📄 Licença
MIT License - veja o arquivo LICENSE para detalhes.
🤝 Contribuição
Contribuições são bem-vindas! Sinta-se à vontade para abrir issues e pull requests.
📞 Suporte
Se você encontrar problemas ou tiver dúvidas, abra uma issue no repositório.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.