spotify-mcp

spotify-mcp

Enables AI agents to search Spotify tracks and control playback (play, pause, skip, queue, volume) through the Spotify Web API.

Category
访问服务器

README

Spotify MCP

Model Context Protocol (MCP) server for Spotify. Let AI agents like Cursor, Claude Code, and Codex search tracks and control playback through the Spotify Web API.

Features

  • Search tracks by title, artist, or natural language
  • Play, pause, resume, skip, and go previous
  • Search-and-play / search-and-queue in one step
  • Read what’s currently playing
  • List Spotify Connect devices and transfer playback
  • Set volume (0–100%)
  • OAuth login with automatic token refresh

Requirements

  • Node.js 18+
  • A Spotify Premium account (playback control requires Premium)
  • A Spotify Developer app (Dashboard)

Quick start

1. Clone and install

git clone https://github.com/AndreaZero/spotify-mcp.git
cd spotify-mcp
npm install

2. Create a Spotify app

  1. Open the Spotify Developer Dashboard.

  2. Create an app.

  3. Under Redirect URIs, add:

    http://127.0.0.1:8888/callback
    
  4. Copy the Client ID and Client Secret.

3. Configure environment

cp .env.example .env

Edit .env:

SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
SPOTIFY_REDIRECT_URI=http://127.0.0.1:8888/callback

4. Authenticate

npm run auth

Open the printed URL in your browser, approve access, then wait until you see Spotify authentication successful. Tokens are saved to .spotify-token.json (gitignored) and refreshed automatically.

5. Run

npm start

Cursor setup

Add the server to your MCP config (e.g. ~/.cursor/mcp.json or project .cursor/mcp.json):

{
  "mcpServers": {
    "spotify": {
      "command": "npx",
      "args": ["tsx", "src/index.ts"],
      "cwd": "/absolute/path/to/spotify-mcp",
      "env": {
        "SPOTIFY_CLIENT_ID": "your_spotify_client_id",
        "SPOTIFY_CLIENT_SECRET": "your_spotify_client_secret",
        "SPOTIFY_REDIRECT_URI": "http://127.0.0.1:8888/callback"
      }
    }
  }
}

On Windows, use a full path for cwd, for example:

C:\\Users\\you\\Documents\\cursor-projects\\spotify-mcp

You can omit env if credentials already live in the project .env and the process starts with that working directory.

After saving, restart Cursor (or reload MCP servers), then try:

Play Everlong by Foo Fighters

What’s playing right now?

Set volume to 30

Claude Desktop / other MCP clients

Same idea: run npx tsx src/index.ts with cwd set to this repo and the Spotify env vars available.

Tools

Tool Description
spotify_search_track Search tracks (query, optional limit 1–10)
spotify_play Play a track URI on the active (or given) device
spotify_play_search Search and play the best match
spotify_pause Pause playback
spotify_resume Resume playback
spotify_next Skip to next track
spotify_previous Go to previous track
spotify_add_to_queue Queue a track URI
spotify_queue_search Search and queue the best match
spotify_now_playing Current track and progress
spotify_devices List Spotify Connect devices
spotify_transfer Transfer playback to another device
spotify_volume Set volume 0–100%

Scripts

Command Description
npm run auth Browser OAuth login; writes .spotify-token.json
npm start Start the MCP server on stdio
npm run inspect Open the MCP Inspector against this server
npm run typecheck Run TypeScript checks

Project layout

spotify-mcp/
├── src/
│   ├── index.ts      # MCP server & tools
│   ├── auth.ts       # OAuth authorization flow
│   └── spotify.ts    # Spotify Web API client + token refresh
├── .env.example
├── package.json
└── tsconfig.json

OAuth scopes

The auth flow requests:

  • user-read-playback-state
  • user-read-currently-playing
  • user-modify-playback-state

For a longer walkthrough, see docs/SETUP.md.

Troubleshooting

“Spotify not authenticated”
Run npm run auth again from the project root.

“No active device” / playback errors
Open Spotify on a phone, desktop, or web player so a Connect device is available, then call spotify_devices or spotify_transfer.

Redirect URI mismatch
The URI in the Dashboard must match SPOTIFY_REDIRECT_URI exactly (default http://127.0.0.1:8888/callback).

Token expired
Refresh is automatic when a refresh token exists. If refresh fails, delete .spotify-token.json and run npm run auth again.

Security

  • Do not commit .env or .spotify-token.json.
  • Keep your Client Secret private.
  • See SECURITY.md for reporting issues.

Contributing

See CONTRIBUTING.md.

License

MIT

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选