Spotify Playlist MCP

Spotify Playlist MCP

Local STDIO MCP server for safely curating Spotify playlists with a plan/apply workflow, allowlist-based write protection, and authentication status checks.

Category
访问服务器

README

Spotify Playlist MCP

A local STDIO MCP server for safely curating Spotify playlists from Codex desktop scheduled tasks. It can inspect owned playlists, search Spotify tracks, update playlist metadata, and add or remove tracks through a bounded plan/apply workflow.

Safety model

  • Reads Spotify credentials and safety settings only from this project's ignored .env, with optional process-level overrides.
  • Stores the OAuth token at ~/.config/spotify-playlist-mcp/token.json with file mode 0600.
  • Refuses every write unless the playlist ID appears in SPOTIFY_ALLOWED_PLAYLIST_IDS.
  • Verifies that the authenticated user owns the playlist.
  • Caps each plan with SPOTIFY_MAX_CHANGES_PER_PLAN, default 10 affected tracks.
  • Binds plans to the current Spotify snapshot_id, expires them after 10 minutes, and permits one application only.
  • Consumes a plan before the first write so a partially applied operation cannot be retried accidentally.

Spotify refresh tokens currently expire six months after authorization. spotify_auth_status reports the remaining time so a scheduled task can warn before reauthorization is required. See Spotify's refresh-token guide.

Tools

Tool Type Purpose
spotify_auth_status Read Report authorization and refresh-token age without returning credentials
spotify_list_owned_playlists Read List owned playlists, visibility, counts, snapshots, and links
spotify_search_tracks Read Search for candidate tracks, maximum 10 results per request
spotify_get_playlist Read Return current playlist metadata and playable track items
spotify_plan_playlist_changes Read Validate and preview additions, removals, name, description, or visibility changes
spotify_apply_playlist_plan Write Apply one exact, unexpired, single-use plan

Track additions are appended. URI removals remove every matching occurrence, and the impact count reflects that behavior. The server intentionally does not expose bulk replacement, arbitrary requests, playlist deletion, or unplanned writes.

Install and verify

source ~/.nvm/nvm.sh
nvm use 24.14.0
npm install
npm test
npm run typecheck
npm run build
npm audit

One-time Spotify authorization

The redirect URI in .env must exactly match the Spotify Dashboard setting. The current loopback callback is http://127.0.0.1:3000/auth/callback.

npm run auth

Open the printed Spotify URL and approve the scopes. The command receives the loopback callback and saves the token privately. Check status without revealing credentials:

node dist/auth-cli.js --status

Spotify currently requires reauthorization every six months because refreshing an access token does not extend the refresh token lifetime.

Codex desktop configuration

The desktop app, CLI, and IDE extension share ~/.codex/config.toml. A scheduled desktop task can launch this STDIO server directly:

[mcp_servers.spotify-playlists]
command = "/absolute/path/to/node"
args = ["/absolute/path/to/spotify-playlist-mcp/dist/index.js"]
cwd = "/absolute/path/to/spotify-playlist-mcp"
enabled = true
required = true
default_tools_approval_mode = "auto"
tool_timeout_sec = 60

[mcp_servers.spotify-playlists.env]
SPOTIFY_ALLOWED_PLAYLIST_IDS = "replace-with-owned-playlist-id"
SPOTIFY_MAX_CHANGES_PER_PLAN = "10"

[mcp_servers.spotify-playlists.tools.spotify_apply_playlist_plan]
approval_mode = "approve"

Restart the ChatGPT desktop app after changing MCP configuration. Keep the computer on and the app running when a scheduled task needs the local server. See the official Codex MCP configuration and scheduled tasks documentation.

Leave SPOTIFY_ALLOWED_PLAYLIST_IDS empty until the intended public playlist exists and its exact ID has been reviewed. Multiple IDs may be comma-separated.

Suggested scheduled-task prompt

Use the Spotify playlist MCP to curate only the configured allowlisted playlist.
First check spotify_auth_status and stop with a warning when authorization is missing or due within 14 days.
Inspect the current playlist before searching for candidates.
Follow the playlist's stated audience and description.
Do not remove protected anchor tracks unless the task prompt explicitly names them.
Make no more than the configured change cap.
Create a playlist change plan, report its additions, removals, metadata updates, and warnings, then apply that exact plan only when it matches these rules.
Report the final snapshot ID and Spotify link.

Test this prompt manually before scheduling it. Scheduled runs are unattended, so the mutation tool must not be configured to prompt for approval.

Development

npm test
npm run typecheck
npm run build

Tests use in-memory Spotify fakes and an in-memory MCP transport. No test calls Spotify or reads the real token file.

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

官方
精选