spotifyMCP

spotifyMCP

Enables controlling Spotify playback, managing playlists, searching music, and accessing library features through any MCP-compatible AI client. Provides 34 tools for full Spotify integration.

Category
访问服务器

README

spotifyMCP

MCP server for Spotify. Control playback, manage playlists, search music, and more — from any MCP-compatible AI client.

34 tools. 2 dependencies. Works locally or on a server.

Quick Start

git clone https://github.com/real-kijmoshi/SpotifyMCP.git
cd spotifyMCP
npm install    # or bun install
npm run setup  # or bun run setup

The setup script will:

  1. Show you where to get a Spotify Developer app
  2. Ask for your Client ID, Secret (optional), port, and webhook URL
  3. Generate an API key to protect your server from unauthorized access
  4. Open Spotify authorization in your browser
  5. Handle the OAuth callback automatically
  6. Optionally start the server with a public tunnel (cloudflared) and run it as a background service (pm2)

Connect to Claude Desktop

Add one of these to claude_desktop_config.json:

Local (stdio):

{
  "mcpServers": {
    "spotify": {
      "command": "node",
      "args": ["/absolute/path/to/spotifyMCP/src/index.js", "--stdio"]
    }
  }
}

HTTP (local or remote):

{
  "mcpServers": {
    "spotify": {
      "url": "http://localhost:3000/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_KEY"
      }
    }
  }
}

Via tunnel (public URL):

{
  "mcpServers": {
    "spotify": {
      "url": "https://your-tunnel.trycloudflare.com/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_KEY"
      }
    }
  }
}

Running

# Local stdio mode (for Claude Desktop)
node src/index.js --stdio

# HTTP server on port 3000
node src/index.js --port 3000

# HTTP server with public tunnel
node src/index.js --port 3000 --tunnel

# As a pm2 background service with tunnel
npm run service:install

Service Management

npm run service:logs       # view logs (shows tunnel URL)
npm run service:status     # check status
npm run service:restart    # restart
npm run service:stop       # stop
npm run service:remove     # remove service

Getting a Spotify Client ID

  1. Go to developer.spotify.com/dashboard
  2. Log in with your Spotify account
  3. Click Create App
  4. Set a name (e.g. "spotifyMCP") and description
  5. Add Redirect URI: http://127.0.0.1:3080/callback (local) or the HTTPS URL shown during setup (server)
  6. Click Save
  7. Copy your Client ID from the app settings page

Server Setup

When running on a remote server, the setup automatically starts a cloudflared tunnel for the OAuth callback. This gives you a real HTTPS URL (e.g. https://xxxx.trycloudflare.com/callback) that Spotify accepts.

  • cloudflared must be installed (https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/)
  • The tunnel starts on port 3080, gets a temporary HTTPS URL, then closes after auth completes
  • No self-signed certs, no SSH tunnels needed

Tools (34)

Playback

Tool Description
playback_state Get current playback state
playback_now_playing Get currently playing track
playback_play Start or resume playback
playback_pause Pause playback
playback_next Skip to next track
playback_previous Skip to previous track
playback_seek Seek to position (ms)
playback_volume Set volume (0-100)
playback_shuffle Toggle shuffle mode
playback_repeat Set repeat mode
playback_transfer Transfer to another device

Search

Tool Description
search Search tracks, artists, albums, playlists
search_tracks Search tracks only
search_artists Search artists only
search_albums Search albums only
search_playlists Search playlists only

Playlists

Tool Description
playlists_list List your playlists
playlists_get Get playlist and its tracks
playlists_create Create a new playlist
playlists_add_tracks Add tracks to playlist
playlists_remove_tracks Remove tracks from playlist
playlists_follow Follow/save a playlist

Profile & Discovery

Tool Description
user_profile Get your Spotify profile
user_top_tracks Get your top tracks
user_top_artists Get your top artists
user_devices List available devices
user_recently_played Get recently played tracks

Library

Tool Description
library_saved_tracks List saved/liked tracks
library_saved_albums List saved albums
library_check_tracks Check if tracks are in library
library_save_tracks Save tracks to library
library_remove_tracks Remove tracks from library

Queue

Tool Description
queue_get Get current playback queue
queue_add Add track to queue

Architecture

spotifyMCP/
├── setup.js              # Interactive quickstart CLI
└── src/
    ├── index.js          # Entry point (--stdio or --port N --tunnel)
    ├── create-server.js  # McpServer factory + tool registration
    ├── http-handler.js   # node:http + StreamableHTTPServerTransport
    ├── tunnel.js         # Auto-detect cloudflared / localtunnel
    ├── auth/
    │   ├── oauth.js      # PKCE generation, token exchange/refresh
    │   ├── auth-server.js # Ephemeral OAuth callback server
    │   └── token-store.js # .spotify-auth.json persistence
    ├── spotify/
    │   └── api.js        # Spotify Web API fetch wrapper
    └── tools/            # 7 tool modules, 34 tools total

Config (.env)

SPOTIFY_CLIENT_ID=your_client_id
SPOTIFY_CLIENT_SECRET=optional
REDIRECT_URI=http://127.0.0.1:3080/callback
MCP_PORT=3000
MCP_API_KEY=auto_generated_key
LOCATION=local
# SERVER_IP=10.0.0.5
# WEBHOOK_URL=

Authentication

When running in HTTP mode (especially with a public tunnel), the server is protected by an API key. The setup script generates one automatically.

For Claude Desktop, add the headers field:

{
  "headers": {
    "Authorization": "Bearer YOUR_API_KEY"
  }
}

The API key is required for all HTTP requests. Stdio mode (local) does not use API key auth since it's already protected by process isolation.

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

官方
精选