Spotify MCP Server for LLM Music Playback
Enable LLM-driven Spotify playback and control with this MCP server for seamless music integration.
npx -y @varunneal/spotify-mcpOverview
This MCP (Model Context Protocol) server bridges large language models and Spotify playback by exposing Spotify Web API controls as MCP tools. It lets an LLM issue high-level actions — play a track, pause, change volume, queue songs, or query the current playback state — while the server handles OAuth, device targeting, and the Spotify API calls. The result is seamless, programmatic music control that can be integrated into assistants, chatbots, or other applications that consume MCP-compatible toolsets.
Why this is useful: language models can reason about user intent (e.g., “play something upbeat for working”) but they cannot directly call external music APIs. The MCP server provides a safe, auditable surface of discrete tools with typed inputs/outputs so an LLM can request playback changes in a structured way. That makes it easier to build voice agents, collaborative DJ features, and interactive experiences that combine natural language and real music playback.
Features
- Exposes common Spotify playback controls as MCP tools (play, pause, seek, next, previous, set volume)
- Token management and OAuth flow support for Spotify Web API
- Device targeting and transfer playback support
- Search and queueing helpers (search tracks, add to queue, create playlists)
- Structured JSON inputs/outputs for safe LLM integration via MCP
- Optional Docker deployment for easy hosting
- Audit logs for commands issued by models
Installation / Configuration
Prerequisites:
- A Spotify developer account and an application to obtain Client ID / Client Secret
- A server environment (Docker recommended) and port reachable by your LLM orchestration
Typical local setup (shell):
# clone the repository
# install dependencies (project may be Node or Python-based)
# Node:
# or Python:
# python -m venv venv
# source venv/bin/activate
# pip install -r requirements.txt
# python main.py
Environment configuration (.env example):
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
SPOTIFY_REDIRECT_URI=https://your-server.example.com/callback
SPOTIFY_SCOPES=user-modify-playback-state,user-read-playback-state,user-read-currently-playing,playlist-read-private
MCP_PORT=3333
HOST=0.0.0.0
Docker (example):
# docker-compose.yml
version: "3.8"
services:
spotify-mcp:
image: varunneal/spotify-mcp:latest
ports:
- "3333:3333"
environment:
- SPOTIFY_CLIENT_ID=${SPOTIFY_CLIENT_ID}
- SPOTIFY_CLIENT_SECRET=${SPOTIFY_CLIENT_SECRET}
- SPOTIFY_REDIRECT_URI=${SPOTIFY_REDIRECT_URI}
- MCP_PORT=3333
After configuring env vars and starting the server, complete the Spotify OAuth flow (visit the /login or /authorize endpoint provided by the server) to grant playback scopes and persist refresh tokens.
Available Tools / Resources
The server exposes a set of MCP tools that an LLM can call. Each tool accepts JSON-serializable inputs and returns structured outputs.
Tool summary:
| Tool name | Description | Input (example) | Output |
|---|---|---|---|
| play | Start playback (track/playlist/uri) | { “uri”: “spotify:track:…”, “device_id”: “…” } | { “status”: “playing”, “uri”: “…” } |
| pause | Pause current playback | { “device_id”: “…” } | { “status”: “paused” } |
| resume | Resume paused playback | { “device_id”: “…” } | { “status”: “playing” } |
| seek | Seek to position (ms) | { “position_ms”: 90000 } | { “position_ms”: 90000 } |
| next | Skip to next track | {} | { “status”: “skipped” } |
| previous | Skip to previous track | {} | { “status”: “skipped_previous” } |
| set_volume | Set device volume (0-100) | { “volume_percent”: 50 } | { “volume_percent”: 50 } |
| add_to_queue | Add a track to the queue | { “uri”: “spotify:track:…” } | { “queued”: true } |
| search | Search for tracks/playlists | { “q”: “artist or title”, “type”: “track”, “limit”: 5 } | { “results”: […] } |
| get_playback | Get current playback state | {} | { “is_playing”: true, “item”: {…} } |
| transfer_playback | Transfer active device | { “device_id”: “…” } | { “transferred”: true } |
Example MCP-style JSON request to play a track:
Example response:
Use Cases
- Assistant-driven playback: integrate with a chat assistant so users can say “play relaxing jazz” and the LLM uses search + play tools to create and start a session.
- Voice-controlled parties: a voice agent manages the queue and volume across