dj-mcp
Enables AI agents to search music and control Spotify playback on Spotify Connect devices (desktop app, phone, speakers). Provides tools for searching tracks, albums, artists and playlists; listing devices and transferring playback to them by ID or name; play/pause/next/previous, seeking and volume control; queueing tracks; reading currently playing, recently played and top tracks/artists; and creating playlists and adding items to them.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
dj-mcp
An MCP server for controlling playback with the Spotify Web API. dj-mcp is packaged as an
Agent Plugin (a stdio MCP server plus a skill) and ships a CLI over the same core,
so AI agents can search music and play it on your Spotify Connect devices (desktop app, phone, speakers).
Currently supports Spotify. In the future, I'd like to consider supporting other music services such as Apple Music.
Zero dependencies. Node.js >= 20. All logic is in
lib/core.mjs.Auth: Authorization Code + PKCE (S256) with your own Spotify app. No client secret.
Results come back trimmed to small, stable shapes, not raw Spotify JSON.
Tokens are stored outside the repo in
~/.config/dj-mcp/(directory 0700, files 0600, atomic writes). The access token refreshes automatically (early, and once on a 401). Rotated refresh tokens are saved. On HTTP 429 it waits forRetry-After(≤30 s, up to 2 retries), otherwise it returns arate_limitederror.
dj-mcp is an independent project. It is not affiliated with, sponsored by, or endorsed by Spotify. "Spotify" is a trademark of Spotify AB and is used here only to describe the API this tool works with. Playback control needs Spotify Premium.
How this differs from other Spotify MCP servers
There are several good Spotify MCP servers out there. This one makes a few particular choices that might suit some setups:
Authorization Code + PKCE. You only need your own app's Client ID. No client secret is stored or required.
Zero runtime dependencies. Plain Node.js (>= 20), with nothing to install from npm.
A shell CLI on the same core (
bin/dj-mcp), for agents or scripts that can run commands but can't load MCP servers.transfer_playback(and other playback tools) accept a device name as well as a device ID.Built for new Development Mode apps (February 2026 onward). It avoids the endpoints that were removed or renamed for them.
Small and playback-focused. Search, devices, playback control, listening history, and simple playlist creation.
If you're looking for more features, such as playlist editing or library management, marcelmarais/spotify-mcp-server may be a better fit.
Related MCP server: Spotify MCP Node Server
1. Create a Spotify app
Go to https://developer.spotify.com/dashboard and choose Create app. Spotify's guidelines say the app name must not include "Spotify" or anything similar to it (e.g. "My DJ Agent").
Set Redirect URI to exactly
http://127.0.0.1:8888/callback. Nothing has to listen on that address, because you'll copy the redirected URL from the browser.Under "Which API/SDKs are you planning to use?", check Web API. Save.
Copy the app's Client ID. It's public, not a secret. You don't need the client secret.
In development mode, only allowlisted users can authorize. Add your own Spotify account (and up to 4 others) under User Management.
2. Set the Client ID
dj-mcp looks for the Client ID in this order (there is no built-in default):
the environment variable
SPOTIFY_CLIENT_IDclient_idin<config dir>/config.json
The config dir (which also holds the tokens) is ~/.config/dj-mcp, or DJ_MCP_CONFIG_DIR if set.
mkdir -p ~/.config/dj-mcp && chmod 700 ~/.config/dj-mcp
printf '{\n "client_id": "YOUR_CLIENT_ID"\n}\n' > ~/.config/dj-mcp/config.json && chmod 600 ~/.config/dj-mcp/config.jsonIf neither is set, tools return client_id_missing with these instructions.
The refresh token is tied to the Client ID it was issued to, and refreshes always use the ID saved with the tokens.
If you switch to a different app, run auth_start again. auth_status reports client_id_mismatch when the two differ.
Optional: SPOTIFY_REDIRECT_URI if you registered a different loopback redirect.
3. Authorize (once per machine)
Call
auth_startand open theauthorize_urlit returns in a browser signed in to Spotify. Click Agree.The browser goes to
http://127.0.0.1:8888/callback?code=...&state=...and shows a "can't connect" error. That's expected.Copy the full URL from the address bar and call
auth_completewithredirect_urlset to it. It checksstate. Do this soon after approving, because Spotify codes expire within minutes. Runningauth_startagain makes earlier URLs invalid.auth_statusshould showauthorized: trueandmissing_scopes: [].
Requested scopes: user-read-playback-state user-modify-playback-state user-read-currently-playing user-read-recently-played user-top-read playlist-read-private playlist-modify-private playlist-modify-public user-library-read.
4. Use it
CLI (any agent that can run shell commands)
SDJ=/path/to/dj-mcp/bin/dj-mcp
$SDJ tools # list tools and params
$SDJ auth_status
$SDJ auth_start
$SDJ auth_complete --redirect_url 'http://127.0.0.1:8888/callback?code=...&state=...' # keep the single quotes
$SDJ search --json '{"query":"artist:\"Bill Evans\" waltz","types":["track"],"limit":5}'
$SDJ get_devices
$SDJ transfer_playback --device_name 'Living Room' --play false
$SDJ play --json '{"uris":["spotify:track:..."]}'
$SDJ play --json '{"context_uri":"spotify:album:...","offset":0}'
$SDJ set_volume --volume_percent 40
$SDJ get_currently_playingYou can pass arguments as --json '{...}', as a bare JSON object, or as --key value. Values are JSON-parsed,
except string fields like URLs and IDs. Output is JSON. On failure it prints
{"error":{"code","message","hint"?,"status"?,"retry_after"?}} and exits with code 1.
Error codes worth handling: client_id_missing, not_authorized, invalid_grant (re-authorize), no_active_device,
device_not_found, rate_limited, forbidden, premium_required, state_mismatch.
MCP: generic stdio
The server speaks newline-delimited JSON-RPC 2.0 on stdio: node /path/to/dj-mcp/bin/dj-mcp-server.
Claude Desktop
claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/, Windows: %APPDATA%\Claude\):
{
"mcpServers": {
"dj-mcp": {
"command": "node",
"args": ["/ABSOLUTE/PATH/dj-mcp/bin/dj-mcp-server"],
"env": { "SPOTIFY_CLIENT_ID": "YOUR_CLIENT_ID" }
}
}
}If node isn't found, use its absolute path (which node).
Cursor
Option A, as a local plugin: copy the folder itself (not a symlink) to ~/.cursor/plugins/local/dj-mcp and reload.
Cursor doesn't expand the standard ${PLUGIN_ROOT} placeholder used in mcp.json's cwd. The server doesn't depend
on its working directory, but if it won't start that way, use option B.
Option B, as a plain MCP server in ~/.cursor/mcp.json (or .cursor/mcp.json in a project):
{
"mcpServers": {
"dj-mcp": {
"command": "node",
"args": ["/ABSOLUTE/PATH/dj-mcp/bin/dj-mcp-server"],
"env": { "SPOTIFY_CLIENT_ID": "YOUR_CLIENT_ID" }
}
}
}Other Agent Plugins clients
Install the directory as a plugin. mcp.json declares a stdio server (./bin/dj-mcp-server) and
skills/dj-mcp/SKILL.md tells the agent when to call each tool.
SPOTIFY_CLIENT_ID is declared under extensions["com.cursor"].variables, because the Agent Plugins manifest
schema has no top-level variables key. An unexpanded ${SPOTIFY_CLIENT_ID} placeholder counts as unset.
Tools
tool | purpose |
auth_start | Create and save a PKCE verifier and state; return |
auth_complete | Take |
auth_status | Authorized or not, expiry, granted/missing scopes, Client ID source (never tokens) |
search | track/album/artist/playlist; |
get_devices | Spotify Connect devices → |
transfer_playback | Make a device active ( |
play |
|
pause / next / previous | Playback controls (optional device) |
set_volume | 0–100 |
add_to_queue | Add a track/episode URI to the queue |
get_currently_playing |
|
get_recently_played |
|
get_top_items | Top tracks or artists, |
create_playlist |
|
add_items_to_playlist |
|
URIs can also be open.spotify.com/... links.
Shapes
Track {uri,name,artists[],album,duration_ms} · Device {id,name,type,is_active,volume_percent} ·
Playback {device,item,is_playing,progress_ms,shuffle,repeat} · Album {uri,name,artists[],release_date,total_tracks} ·
Artist {uri,name,genres[]} · Playlist {uri,id,name,owner,public,total_items,description}.
Spotify development-mode limits
Checked against developer.spotify.com in November 2026: the February 2026 Web API changelog and migration guide, the March 2026 changelog, and the November 2024 Web API announcement.
The app owner needs an active Premium subscription. A development-mode app allows at most 5 users, and they must be allowlisted.
GET /search:limitmax is 10 (default 5). Page withoffset.Playlist items:
/playlists/{id}/tracks→/playlists/{id}/items. Contents are returned only for playlists the user owns or collaborates on, and thetracksfield is renameditems.Create playlist:
POST /me/playlists(POST /users/{id}/playlistswas removed).Library: save/remove/follow →
PUT/DELETE /me/library(URIs); contains checks →GET /me/library/contains.Removed: batch GETs (
/tracks,/albums,/artists, ...), artist top tracks, new releases, browse categories, other users' profiles and playlists, markets.popularityand some other fields were removed from objects.Unavailable to development-mode apps since 2024-11-27: recommendations, related artists, audio features, audio analysis, featured playlists, category playlists, and 30-second preview URLs. The agent has to choose tracks itself from search, top items and recent plays.
Development
npm test # node --test, no network: fetch is mocked; the stdio smoke test spawns the real server with a fake Client IDSee VERIFY.md for the verification checklist.
License
MIT. See LICENSE.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Full Spotify Web API coverage - albums, artists, playlists, player controls, and more.
Spotify MCP server for ChatGPT, Claude and any AI agent: search songs and artists, list playlists, read playlist songs, create playlist, add songs to playlist, remove songs from playlist, set playlist public or private and save to Liked Songs in your own Spotify account. Cotlet works in the account through your Cloud Browser, a real Chrome where you sign in to Spotify yourself; Cotlet does not store your password and you need no Spotify API key. About the official Spotify API: Spotify has a full Web API and, since 23 Apr 2026, an official connector for Claude (checked 5 Nov 2026). The API needs an app you register, and in development mode the app owner must have Premium and the app allows 5 users; unlimited users need a registered business with at least 250,000 monthly users. Setup and FAQ: https://cotlet.dev/integrations/spotify-api-mcp-server
Generate full songs with vocals, instrumentals and sound effects from text. One server for Suno, Google Lyria, Mureka, MiniMax, ACE-Step, YuE and ElevenLabs. Your agent can quote the credit cost before generating, start a song, wait for it to finish and return download links. Sign in with OAuth; optional daily credit caps; retries never charge twice.
Spotify: Spotify Data API for Millions of songs & podcasts, artists, albums, playlists and more.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables interaction with Spotify through LLMs using OAuth2 authentication. Supports music search, playback control, playlist management, and device management through natural language commands.142MIT
- AlicenseBqualityDmaintenanceEnables AI assistants to control Spotify playback, manage playlists, search music, and access listening history. Requires Spotify Premium and uses secure OAuth 2.0 with PKCE authentication.13MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to search Spotify, inspect playback state, manage devices, and control music through the official Spotify Web API using OAuth authentication.3MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to search Spotify tracks and control playback (play, pause, skip, queue, volume) through the Spotify Web API.2MIT