SpotifyMCP

SpotifyMCP

Enables AI assistants to control Spotify playback, search the full catalog including podcasts and audiobooks, manage libraries and playlists, and understand listening taste.

Category
访问服务器

README

SpotifyMCP

An MCP server that wraps the Spotify Web API, letting AI assistants (like Claude) control playback, search the full catalog including podcasts and audiobooks, manage your library and playlists, and understand your listening taste.

Why this one

Most Spotify MCP servers are thin wrappers. This one is built to be the default:

  • Complete API surface — every non-deprecated Spotify Web API endpoint callable with a standard developer token is covered by a tool (playback, search, catalog, audiobooks, personalization, library, playlists, following).
  • Honest about deprecations — Spotify removed recommendations, related artists, audio features/analysis, genre seeds, and featured playlists from new apps. Servers still exposing those ship tools that fail at runtime; this one doesn't.
  • Tested — full unit suite over the client (token refresh, rate limiting, pagination) and every tool handler, plus an end-to-end MCP protocol smoke test. Many alternatives have zero tests.
  • Paginated everything — fetch_all on library and playlist listings walks every page (capped at 500 items) instead of silently truncating at one page of 50.
  • Podcasts are first-class — episodes work everywhere: now-playing, queue, search-and-play. Several competitors can't see podcasts at all.
  • Device-aware playback — list devices, transfer playback, and target any command at a specific device for multi-room setups.
  • Robust auth — PKCE flow with silent refresh, persistent mode-600 token cache, headless paste-flow (SPOTIFY_HEADLESS=1) for servers and containers.

Features

Playback (15 tools) — now playing / currently-playing polls, play (by URI, or play_from_search to play straight from a name), pause, skip, previous, seek, volume, shuffle, repeat, queue view/add, device list, transfer playback.

Search & catalog — unified search across tracks/artists/albums/playlists/shows/episodes; deep lookups for tracks, artists, artist albums, albums, album tracks, shows, show episodes, episodes, and your profile (get_me).

Audiobooks — titles, chapters, chapter lookup, and your saved audiobooks (market-gated by Spotify to US/UK/CA/IE/NZ/AU).

Personalization — top tracks and artists across three time ranges, recently played.

Library — saved tracks/albums/shows/episodes with optional full pagination; unified save/remove/check via /me/library URIs.

Playlists — full CRUD plus item management (add/remove/reorder), cover art retrieval and custom cover upload (ugc-image-upload scope required for upload).

Following — followed-artists list and follow-state checks.

Also exposed: 7 MCP resources (profile, player state, queue, top tracks/artists, recently played, playlists) and 4 prompt templates (DJ set, mood playlist, taste summary, discovery alternative).

Requirements & limitations

  • Spotify Premium is required for playback control (play, pause, skip, seek, volume, shuffle, repeat, queue, transfer). Free accounts can authenticate and use search/catalog/library/playlist tools, but every playback command will fail with a Premium-required error from Spotify.
  • fetch_all pagination walks up to 500 items per call (protects against runaway loops); beyond that, use limit/offset paging.
  • Audiobook tools are market-gated by Spotify to US, UK, Canada, Ireland, New Zealand, and Australia.
  • Spotify's developer mode allows up to 5 authorised users per app until extended quota is granted.

Quick setup

1. Create a Spotify app

Each user needs their own Spotify app to get a Client ID — this is how Spotify identifies which app is making API requests.

  1. Go to the Spotify Developer Dashboard and create a new app.
  2. In the app settings, add the following Redirect URI exactly (Spotify will reject the login if this doesn't match):
    http://127.0.0.1:8888/callback
    
  3. Save. Copy your Client ID.

2. Authenticate

Run the command below once to log in to your Spotify account. Replace your_client_id_here with the Client ID from step 1. It opens a browser window, and after you approve, saves tokens to ~/.spotify-mcp/tokens.json. The server refreshes them automatically — you won't need to do this again.

macOS / Linux:

SPOTIFY_CLIENT_ID=your_client_id_here npx -y @novalux12/spotify-mcp@latest auth

Headless / remote hosts (no browser on the machine running the MCP server):

SPOTIFY_HEADLESS=1 SPOTIFY_CLIENT_ID=your_client_id_here npx -y @novalux12/spotify-mcp@latest auth

The auth URL is printed; complete the flow in any browser (e.g. on your laptop), then paste the redirect URL back into the prompt. Useful for homelabs, CI, and agent runtimes.

Headless authentication (browserless hosts)

If you're running this MCP server on a host that doesn't have a browser (e.g., a cloud VM, a Docker container, a remote server), set the SPOTIFY_HEADLESS=1 environment variable. The auth flow will skip the local HTTP callback server and instead prompt you to paste the redirect URL after authorizing the app in your browser.

Steps

  1. Set SPOTIFY_HEADLESS=1 in your environment
  2. Run the server — it will print a URL to authorize the app
  3. Open the URL in a browser on a different machine
  4. After authorizing, your browser will redirect to the redirect URI
  5. Copy the full URL from the address bar
  6. Paste it back into the server prompt

Why

The default auth flow opens a browser via the open package and runs a local HTTP callback server on 127.0.0.1:8888. That breaks when the MCP server runs on a headless host (homelab, CI, agent runtime) where there is no browser to open(), and the 127.0.0.1:8888 callback can't be reached from the user's machine.

SPOTIFY_HEADLESS=1 switches to a paste-URL flow: the auth URL is printed to stdout, the operator completes the flow in any browser (their laptop, phone), then pastes the full redirect URL back. The code + state are extracted and exchanged server-side. Works across machines.

Windows (Command Prompt):

set SPOTIFY_CLIENT_ID=your_client_id_here && npx -y @novalux12/spotify-mcp@latest auth

Windows (PowerShell):

$env:SPOTIFY_CLIENT_ID="your_client_id_here"; npx -y @novalux12/spotify-mcp@latest auth

3. Configure Claude Desktop

Open your claude_desktop_config.json:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: Open Claude Desktop → Settings → Developer → Edit Config

Add the mcpServers block (replace your_client_id_here with your Client ID):

{
  "mcpServers": {
    "spotify": {
      "command": "npx",
      "args": ["-y", "@novalux12/spotify-mcp@latest"],
      "env": {
        "SPOTIFY_CLIENT_ID": "your_client_id_here"
      }
    }
  }
}

Fully quit and restart Claude Desktop. A hammer icon in the chat input confirms the server is connected.

Alternative: Claude Code

If you use Claude Code, add the server without editing JSON by hand:

claude mcp add spotify -- npx -y @novalux12/spotify-mcp@latest
# then set SPOTIFY_CLIENT_ID in your shell or MCP env:
export SPOTIFY_CLIENT_ID=your_client_id_here

Or add it to .mcp.json in your project root — same command/args/env shape as above.

Command for AI agents

Any coding agent (Claude Code, OpenClaw, Cursor, Aider, …) can install, build, authenticate and register the server in one paste. Give it your Client ID and let it run:

git clone https://github.com/NovaLux12/spotify-mcp-server.git && cd spotify-mcp-server \
  && npm ci && npm run build \
  && SPOTIFY_CLIENT_ID=your_client_id_here npm run auth

Then point your host's MCP config at <repo>/dist/index.js with SPOTIFY_CLIENT_ID in its env (shapes below). Agents should finish by calling the get_me tool once — it proves auth, scopes and transport in a single round-trip.

OpenClaw

Add to mcp.servers in ~/.openclaw/openclaw.json:

"spotify": {
  "command": "node",
  "args": ["/path/to/spotify-mcp-server/dist/index.js"],
  "cwd": "/path/to/spotify-mcp-server",
  "env": { "SPOTIFY_CLIENT_ID": "your_client_id_here" }
}

Then restart the OpenClaw gateway so it respawns the server. Headless box? Run the auth step with SPOTIFY_HEADLESS=1 on any machine with a browser (see above) — tokens land in ~/.spotify-mcp/tokens.json either way.

When things go wrong: install the doctor skill

This repo ships skills/spotify-mcp-doctor/SKILL.md — a procedural diagnostic your agent can execute instead of you re-reading this README. It walks the real failure modes in order: wiring → binary → app credentials → token freshness → error classification (Premium vs dev-mode allowlist vs market gating vs deprecations). Install:

cp -r skills/spotify-mcp-doctor ~/.openclaw/workspace/skills/   # OpenClaw
# or drop it into .claude/skills/ for Claude Code projects

Then just ask your agent: "Spotify tools are failing — run the spotify doctor skill."

Usage

Once connected, you can ask Claude things like:

  • "What are my top Spotify tracks?"
  • "Create a playlist of chill lo-fi songs for studying"
  • "Add the song Blinding Lights to my workout playlist"
  • "What artists have I been listening to most lately?"
  • "Make me a playlist with a late night driving vibe"

Troubleshooting

  • "Not authenticated" on first tool call — run npx -y @novalux12/spotify-mcp@latest auth (or npm run auth from a clone) and complete the browser flow. Tokens are stored at ~/.spotify-mcp/tokens.json and refreshed automatically.
  • Redirect URI mismatch — the Spotify app's redirect URI must be exactly http://127.0.0.1:8888/callback (no trailing slash). Save the app settings and retry.
  • Port 8888 busy — another process is holding the callback port; stop it or pick a free port via SPOTIFY_REDIRECT_URI=http://127.0.0.1:8888/callback with a different port and matching Dashboard setting.
  • Headless / Docker — set SPOTIFY_HEADLESS=1 before auth; paste the redirect URL back when prompted (see above).

Disclaimer

This is a personal project, not affiliated with or endorsed by Spotify. It is provided as-is with no warranties or guarantees of any kind. Use it responsibly and in accordance with the Spotify Developer Terms of Service. The author is not responsible for any misuse or consequences arising from use of this software.

Development

git clone https://github.com/NovaLux12/spotify-mcp-server.git
cd spotify-mcp-server
npm install
npm run build

Copy .env.example to .env and fill in your Client ID, then:

npm run auth   # authenticate with Spotify
npm run dev    # run from source (no build needed)

Requires Node 22.9+ (--env-file-if-exists support). No .env file is needed — env vars come from your host config or the command line.

Testing

npm test   # node:test runner — unit tests for the client and every tool module, plus an MCP protocol smoke test

Acknowledgements

  • calebWei/SpotifyMCP — original auth flow and playback scaffolding this project grew from.
  • varunneal/spotify-mcp — the reference implementation used as the quality bar for tool coverage and ergonomics.

License

MIT © Carme99 and NovaLux12 contributors.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选