Ramona668/spotify-mcp-server
If you are the rightful owner of spotify-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
This is a minimal, MCP-style Spotify server designed for quick deployment, handling Spotify OAuth, and providing REST endpoints for controlling Spotify via the Web API.
Spotify MCP Server (Minimal Template, Secure Redirect Ready)
This is a minimal, MCP-style Spotify server you can deploy quickly (Vercel-ready). It handles Spotify OAuth and exposes a small set of REST endpoints that many MCP clients or agent runtimes can call to control Spotify via the Web API.
Important redirect note (2025)
Spotify no longer acceptshttp://localhostfor OAuth redirects.
For local dev, use loopback IP with HTTP:http://127.0.0.1:<PORT>(orhttp://[::1]:<PORT>).
For production, use HTTPS (e.g., your Vercel domain).
What you get
- OAuth login with Spotify (
/auth→ Spotify consent →/callback). - Token storage in memory (swap in Redis/KV for production).
- Tool discovery at
/mcp/tools. - Tool execution at
/mcp/executesupporting:search(query tracks)play(start/resume on your active device)pausenextprevcreate_playlist(and add tracks)
Quick start (local)
-
Create a Spotify app: https://developer.spotify.com/dashboard
- Add a Redirect URI:
http://127.0.0.1:8888/callback
- Add a Redirect URI:
-
Copy
.env.exampleto.envand fill in values. -
Install & run:
npm install
npm run dev
- Visit:
http://127.0.0.1:8888/auth
After successful auth, you can call tools:
# Discover tools
curl http://127.0.0.1:8888/mcp/tools
# Search
curl -X POST http://127.0.0.1:8888/mcp/execute -H "Content-Type: application/json" -d '{"tool":"search","args":{"q":"lofi chill"}}'
Deploy to Vercel
- Push this folder to a new GitHub repo.
- In Vercel → "New Project" → Import your repo.
- Set Environment Variables:
SPOTIFY_CLIENT_IDSPOTIFY_CLIENT_SECRETSPOTIFY_REDIRECT_URI→https://YOUR-VERCEL-APP.vercel.app/callbackSESSION_SECRET→ any random string
- Deploy. Your MCP base URL will be:
https://YOUR-VERCEL-APP.vercel.app
Environment Variables
See .env.example for required values.
Security & Persistence
- This demo stores tokens in memory (Node process). For production, use a KV/DB like Redis.
- Lock down CORS if exposing publicly.
- Scope permissions only as needed.
Adapting to strict MCP transports
Some MCP clients may require:
- JSON-RPC over stdio or WebSocket
- Tool schema registration
- Session/handshake messages
You can:
- Expose a WebSocket at
/mcp/socketand implement JSON-RPC. - Or run a companion adapter that converts REST tools to the client's expected transport.
Endpoints
GET /auth→ redirect to Spotify OAuthGET /callback→ handles Spotify auth; stores tokensGET /mcp/tools→ returns available tools JSONPOST /mcp/execute→ executes a tool by name with argsPOST /logout→ clears session
Scopes used
user-read-playback-state
user-modify-playback-state
user-read-currently-playing
playlist-modify-private
playlist-modify-public
playlist-read-private
user-read-email
License
MIT