SP

Spotify MCP Server for LLM Music Playback

Enable LLM-driven Spotify playback and control with this MCP server for seamless music integration.

Quick Install
npx -y @varunneal/spotify-mcp

Overview

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
git clone https://github.com/varunneal/spotify-mcp.git
cd spotify-mcp

# install dependencies (project may be Node or Python-based)
# Node:
npm install
npm run start

# 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 nameDescriptionInput (example)Output
playStart playback (track/playlist/uri){ “uri”: “spotify:track:…”, “device_id”: “…” }{ “status”: “playing”, “uri”: “…” }
pausePause current playback{ “device_id”: “…” }{ “status”: “paused” }
resumeResume paused playback{ “device_id”: “…” }{ “status”: “playing” }
seekSeek to position (ms){ “position_ms”: 90000 }{ “position_ms”: 90000 }
nextSkip to next track{}{ “status”: “skipped” }
previousSkip to previous track{}{ “status”: “skipped_previous” }
set_volumeSet device volume (0-100){ “volume_percent”: 50 }{ “volume_percent”: 50 }
add_to_queueAdd a track to the queue{ “uri”: “spotify:track:…” }{ “queued”: true }
searchSearch for tracks/playlists{ “q”: “artist or title”, “type”: “track”, “limit”: 5 }{ “results”: […] }
get_playbackGet current playback state{}{ “is_playing”: true, “item”: {…} }
transfer_playbackTransfer active device{ “device_id”: “…” }{ “transferred”: true }

Example MCP-style JSON request to play a track:

{
  "tool": "play",
  "input": { "uri": "spotify:track:3n3Ppam7vgaVa1iaRUc9Lp", "device_id": "device-id-123" }
}

Example response:

{
  "status": "ok",
  "result": { "status": "playing", "uri": "spotify:track:3n3Ppam7vgaVa1iaRUc9Lp" }
}

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