spotifyMCP
Enables controlling Spotify playback, managing playlists, searching music, and accessing library features through any MCP-compatible AI client. Provides 34 tools for full Spotify integration.
README
spotifyMCP
MCP server for Spotify. Control playback, manage playlists, search music, and more — from any MCP-compatible AI client.
34 tools. 2 dependencies. Works locally or on a server.
Quick Start
git clone https://github.com/real-kijmoshi/SpotifyMCP.git
cd spotifyMCP
npm install # or bun install
npm run setup # or bun run setup
The setup script will:
- Show you where to get a Spotify Developer app
- Ask for your Client ID, Secret (optional), port, and webhook URL
- Generate an API key to protect your server from unauthorized access
- Open Spotify authorization in your browser
- Handle the OAuth callback automatically
- Optionally start the server with a public tunnel (cloudflared) and run it as a background service (pm2)
Connect to Claude Desktop
Add one of these to claude_desktop_config.json:
Local (stdio):
{
"mcpServers": {
"spotify": {
"command": "node",
"args": ["/absolute/path/to/spotifyMCP/src/index.js", "--stdio"]
}
}
}
HTTP (local or remote):
{
"mcpServers": {
"spotify": {
"url": "http://localhost:3000/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}
Via tunnel (public URL):
{
"mcpServers": {
"spotify": {
"url": "https://your-tunnel.trycloudflare.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}
Running
# Local stdio mode (for Claude Desktop)
node src/index.js --stdio
# HTTP server on port 3000
node src/index.js --port 3000
# HTTP server with public tunnel
node src/index.js --port 3000 --tunnel
# As a pm2 background service with tunnel
npm run service:install
Service Management
npm run service:logs # view logs (shows tunnel URL)
npm run service:status # check status
npm run service:restart # restart
npm run service:stop # stop
npm run service:remove # remove service
Getting a Spotify Client ID
- Go to developer.spotify.com/dashboard
- Log in with your Spotify account
- Click Create App
- Set a name (e.g. "spotifyMCP") and description
- Add Redirect URI:
http://127.0.0.1:3080/callback(local) or the HTTPS URL shown during setup (server) - Click Save
- Copy your Client ID from the app settings page
Server Setup
When running on a remote server, the setup automatically starts a cloudflared tunnel for the OAuth callback. This gives you a real HTTPS URL (e.g. https://xxxx.trycloudflare.com/callback) that Spotify accepts.
- cloudflared must be installed (
https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/) - The tunnel starts on port 3080, gets a temporary HTTPS URL, then closes after auth completes
- No self-signed certs, no SSH tunnels needed
Tools (34)
Playback
| Tool | Description |
|---|---|
playback_state |
Get current playback state |
playback_now_playing |
Get currently playing track |
playback_play |
Start or resume playback |
playback_pause |
Pause playback |
playback_next |
Skip to next track |
playback_previous |
Skip to previous track |
playback_seek |
Seek to position (ms) |
playback_volume |
Set volume (0-100) |
playback_shuffle |
Toggle shuffle mode |
playback_repeat |
Set repeat mode |
playback_transfer |
Transfer to another device |
Search
| Tool | Description |
|---|---|
search |
Search tracks, artists, albums, playlists |
search_tracks |
Search tracks only |
search_artists |
Search artists only |
search_albums |
Search albums only |
search_playlists |
Search playlists only |
Playlists
| Tool | Description |
|---|---|
playlists_list |
List your playlists |
playlists_get |
Get playlist and its tracks |
playlists_create |
Create a new playlist |
playlists_add_tracks |
Add tracks to playlist |
playlists_remove_tracks |
Remove tracks from playlist |
playlists_follow |
Follow/save a playlist |
Profile & Discovery
| Tool | Description |
|---|---|
user_profile |
Get your Spotify profile |
user_top_tracks |
Get your top tracks |
user_top_artists |
Get your top artists |
user_devices |
List available devices |
user_recently_played |
Get recently played tracks |
Library
| Tool | Description |
|---|---|
library_saved_tracks |
List saved/liked tracks |
library_saved_albums |
List saved albums |
library_check_tracks |
Check if tracks are in library |
library_save_tracks |
Save tracks to library |
library_remove_tracks |
Remove tracks from library |
Queue
| Tool | Description |
|---|---|
queue_get |
Get current playback queue |
queue_add |
Add track to queue |
Architecture
spotifyMCP/
├── setup.js # Interactive quickstart CLI
└── src/
├── index.js # Entry point (--stdio or --port N --tunnel)
├── create-server.js # McpServer factory + tool registration
├── http-handler.js # node:http + StreamableHTTPServerTransport
├── tunnel.js # Auto-detect cloudflared / localtunnel
├── auth/
│ ├── oauth.js # PKCE generation, token exchange/refresh
│ ├── auth-server.js # Ephemeral OAuth callback server
│ └── token-store.js # .spotify-auth.json persistence
├── spotify/
│ └── api.js # Spotify Web API fetch wrapper
└── tools/ # 7 tool modules, 34 tools total
Config (.env)
SPOTIFY_CLIENT_ID=your_client_id
SPOTIFY_CLIENT_SECRET=optional
REDIRECT_URI=http://127.0.0.1:3080/callback
MCP_PORT=3000
MCP_API_KEY=auto_generated_key
LOCATION=local
# SERVER_IP=10.0.0.5
# WEBHOOK_URL=
Authentication
When running in HTTP mode (especially with a public tunnel), the server is protected by an API key. The setup script generates one automatically.
For Claude Desktop, add the headers field:
{
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
The API key is required for all HTTP requests. Stdio mode (local) does not use API key auth since it's already protected by process isolation.
License
MIT
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.