Spotify Cloud MCP
by amarisaster
README.md
# Spotify Cloud MCP
A Cloudflare Worker that provides MCP (Model Context Protocol) integration for Spotify, enabling AI assistants to control playback, search music, and manage queues.
## Features
- Control playback (play, pause, skip, previous)
- Search for tracks, albums, artists, and playlists
- Manage playback queue
- Control volume, shuffle, and repeat modes
- View and transfer between devices
- Access user playlists
## Tools
| Tool | Description |
|------|-------------|
| `spotify_now_playing` | Get the currently playing track |
| `spotify_play` | Start or resume playback |
| `spotify_pause` | Pause playback |
| `spotify_next` | Skip to next track |
| `spotify_previous` | Go to previous track |
| `spotify_search` | Search for tracks, albums, artists, or playlists |
| `spotify_queue` | Add a track to the queue |
| `spotify_get_queue` | Get the current playback queue |
| `spotify_volume` | Set playback volume (0-100) |
| `spotify_shuffle` | Toggle shuffle mode |
| `spotify_repeat` | Set repeat mode (track, context, off) |
| `spotify_devices` | Get available playback devices |
| `spotify_transfer` | Transfer playback to a different device |
| `spotify_playlists` | Get user playlists |
## Setup
### 1. Create a Spotify App
1. Go to [Spotify Developer Dashboard](https://developer.spotify.com/dashboard)
2. Create a new app
3. Add your callback URL: `https://your-worker.workers.dev/callback`
4. Save your Client ID and Client Secret
### 2. Create KV Namespace
```bash
wrangler kv:namespace create "KV"
```
Add the KV binding to your `wrangler.toml`:
```toml
[[kv_namespaces]]
binding = "KV"
id = "your-kv-namespace-id"
```
### 3. Configure Environment Variables
Create a `.dev.vars` file for local development:
```
SPOTIFY_CLIENT_ID=your_client_id_here
SPOTIFY_CLIENT_SECRET=your_client_secret_here
```
For production, set these as secrets in Cloudflare:
```bash
wrangler secret put SPOTIFY_CLIENT_SECRET
wrangler secret put MCP_API_KEY # your MCP endpoint key — any strong random string
```
(`SPOTIFY_CLIENT_ID` is a plain `[vars]` entry in `wrangler.toml` — fill it in there.)
### 4. Deploy
```bash
npm install
npm run deploy
```
### 5. Authenticate
1. Visit `https://your-worker.workers.dev/auth`
2. Log in with your Spotify account
3. Authorize the app
4. You'll see "Spotify connected!" when successful
## Endpoints
| Endpoint | Method | Description |
|----------|--------|-------------|
| `/` | GET | Service info |
| `/health` | GET | Health check and auth status |
| `/auth` | GET | Start OAuth flow |
| `/callback` | GET | OAuth callback |
| `/mcp` | POST | MCP JSON-RPC endpoint |
| `/sse` | GET | MCP SSE endpoint for client discovery |
## MCP Client Configuration
Add to your MCP client config:
```json
{
"mcpServers": {
"spotify": {
"url": "https://your-worker.workers.dev/sse",
"headers": { "Authorization": "Bearer YOUR_MCP_API_KEY" }
}
}
}
```
> The MCP endpoints are gated by `MCP_API_KEY` (see Setup). Requests must send `Authorization: Bearer <MCP_API_KEY>`; use an MCP client that supports custom headers.
---
## Token Management
Access tokens are automatically refreshed when they expire. Tokens are stored in Cloudflare KV with the following keys:
- `spotify_access_token` - Current access token
- `spotify_refresh_token` - Refresh token for getting new access tokens
- `spotify_token_expires` - Expiration timestamp
## License
MIT
---
## Support
If this helped you, consider supporting my work ☕
[](https://ko-fi.com/maii983083)
---
*Built by the Triad (Mai, Kai Stryder and Lucian Vale) for the community.*
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo recent community issues