Skip to main content
Glama
agustinhopneto

Spotify MCP Server

🎧 Spotify MCP Server

A lightweight Model Context Protocol (MCP) server that lets AI assistants like Claude, Codex and Cursor control Spotify playback and manage your library and playlists.

TypeScript Node.js MCP Spotify Docker Biome

About β€’ Examples β€’ Tools β€’ Getting started β€’ MCP clients β€’ Credits


πŸ“– About

This server exposes the Spotify Web API as 30 MCP tools, so an AI assistant can search the catalog, see what’s playing, control playback and volume, manage the queue and edit your playlists and library, all in natural language.

Based on marcelmarais/spotify-mcp-server. This version keeps the original implementation and adds:

  • 🐳 a Docker-first workflow with Docker Compose

  • βš™οΈ configuration through a local .env file

  • πŸ”‘ persisted OAuth tokens in a mounted volume, with proactive refresh every 45 minutes

  • πŸ“Š extra tools: getTopTracks, getTopArtists and unfollowPlaylist

  • πŸ€– a setup that works out of the box with Codex, Claude and Cursor

Related MCP server: spotify-mcp-server

πŸ’¬ Example prompts

  • "Play Elvis’s first song"

  • "Create a Taylor Swift / Slipknot fusion playlist"

  • "Copy all the techno tracks from my workout playlist to my work playlist"

  • "What have I been listening to the most this month?"

  • "Turn the volume down a bit"

🧰 Tools

Tool

Description

searchSpotify

Search for tracks, albums, artists or playlists

getNowPlaying

Current track, progress, device, volume and shuffle/repeat state

getMyPlaylists

The current user’s playlists

getPlaylistTracks

Tracks in a playlist

getRecentlyPlayed

Recently played tracks

getUsersSavedTracks

Tracks in "Liked Songs" (paginated)

getTopTracks

The user’s most-played tracks over a time range

getTopArtists

The user’s most-played artists over a time range

getQueue

Current track and upcoming items in the queue

getAvailableDevices

Available Spotify Connect devices

removeUsersSavedTracks

Remove tracks from "Liked Songs" (max 40)

Tool

Description

playMusic

Play a track, album, artist or playlist (by URI or type + ID)

pausePlayback

Pause playback

resumePlayback

Resume playback

skipToNext

Skip to the next track

skipToPrevious

Go back to the previous track

addToQueue

Add an item to the playback queue

setVolume

Set the volume to a percentage (Premium)

adjustVolume

Raise or lower the volume by a relative amount (Premium)

Tool

Description

getAlbums

Details for one or more albums (max 20)

getAlbumTracks

Tracks from an album (paginated)

saveOrRemoveAlbumForUser

Save or remove albums from "Your Music"

checkUsersSavedAlbums

Check whether albums are saved in the library

Tool

Description

createPlaylist

Create a new playlist

getPlaylist

Playlist details: owner, track count, visibility, description

updatePlaylist

Change name, description, public or collaborative settings

addTracksToPlaylist

Add tracks to a playlist

removeTracksFromPlaylist

Remove tracks from a playlist (max 100)

reorderPlaylistItems

Move a range of tracks to a new position

unfollowPlaylist

Remove a playlist from the user’s library

πŸš€ Getting started

Prerequisites

1. Create a Spotify app

  1. Open the Spotify Developer Dashboard and click Create app.

  2. Add http://127.0.0.1:8888/callback as a Redirect URI.

  3. Copy the app’s Client ID and Client Secret.

# Clone the repository
git clone https://github.com/agustinhopneto/spotify-mcp-server.git
cd spotify-mcp-server

# Create your .env and fill SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET
cp .env.example .env

# Build the image
npm run docker:build

# Authorize your Spotify account (opens the OAuth flow on port 8888)
npm run docker:auth

# Start the server in the background
npm run docker:up

Tokens are saved to data/spotify-config.json. Never commit or share this file. If Spotify revokes the token or the automatic refresh fails, run npm run docker:auth again.

Command

Description

npm run docker:build

Build or update the image

npm run docker:auth

Connect your Spotify account in the browser

npm run docker:up

Start the container in the background

npm run docker:logs

Follow the container logs

npm run docker:down

Stop the container

Alternative: run with Node.js

npm install
cp spotify-config.example.json spotify-config.json  # add your clientId, clientSecret and redirectUri
npm run auth    # authorize your account; tokens are saved to spotify-config.json
npm run build

πŸ”Œ Connecting an MCP client

MCP talks over stdio, so the client starts one MCP process per connection.

With Docker: the process runs inside the persistent container. Run npm run docker:up first and replace the path with your own:

{
  "mcpServers": {
    "spotify": {
      "command": "docker",
      "args": [
        "compose", "-f", "/absolute/path/to/spotify-mcp-server/compose.yaml",
        "exec", "-T", "spotify-mcp", "node", "build/index.js"
      ]
    }
  }
}

With Node.js:

{
  "mcpServers": {
    "spotify": {
      "command": "node",
      "args": ["/absolute/path/to/spotify-mcp-server/build/index.js"]
    }
  }
}

This configuration works with Claude Desktop, Codex, Cursor (Settings β†’ MCP) and Cline (cline_mcp_settings.json).

🧱 Architecture

flowchart LR
    AI[AI assistant<br/><sub>Claude Β· Codex Β· Cursor</sub>] <-->|MCP over stdio| S[Spotify MCP Server]
    S -->|Spotify Web API SDK| SP[(Spotify)]
    S <--> T[(spotify-config.json<br/><sub>OAuth tokens</sub>)]
src/
β”œβ”€β”€ index.ts     # MCP server bootstrap + token refresh
β”œβ”€β”€ auth.ts      # OAuth authorization flow
β”œβ”€β”€ read.ts      # Read tools
β”œβ”€β”€ play.ts      # Playback tools
β”œβ”€β”€ albums.ts    # Album tools
β”œβ”€β”€ playlist.ts  # Playlist tools
β”œβ”€β”€ utils.ts     # Spotify client, token handling, helpers
└── types.ts

πŸ› οΈ Development

Command

Description

npm run build

Compile TypeScript to build/

npm run lint

Lint with Biome

npm run lint:fix

Fix lint issues

npm run typecheck

Type check

CI runs lint and type checking on every push and pull request, and Dependabot keeps the dependencies up to date.

πŸ™ Credits

This project is based on marcelmarais/spotify-mcp-server. All credit for the original implementation goes to its author and contributors. ⭐ Go give the original a star!


Maintained with πŸ’š by Agustinho Neto

Related MCP Connectors

Related MCP Servers