spotify-library-mcp

spotify-library-mcp

Enables you to manage your personal Spotify library from Claude or a CLI, including organizing playlists, merging and deleting playlists, saving tracks, searching with artist verification, and querying top tracks, artists, and recently played items.

Category
访问服务器

README

spotify-library-mcp

Local MCP server + CLI for managing your own Spotify library. Single user, runs on your machine, PKCE auth (no client secret needed).

Setup (one time)

  1. https://developer.spotify.com/dashboard → Create app
    • Redirect URI: http://127.0.0.1:8888/callback
    • API: Web API
  2. Copy the Client ID into .env (SPOTIFY_CLIENT_ID=...)
  3. npm install && npm run auth → browser opens → approve → refresh token is written to .env
  4. Verify: node bin/spot.js playlists

Use from Claude Code

.mcp.json in this folder registers the server for this project. For every project:

claude mcp add --scope user spotify-library -- node /path/to/spotify-library-mcp/src/server.js

CLI

node bin/spot.js playlists
node bin/spot.js playlist <id>
node bin/spot.js rename <id> "New name"
node bin/spot.js merge '{"sourceIds":["a","b"],"newName":"Merged","deleteSources":true}'
node bin/spot.js delete <id>
node bin/spot.js top short_term 20
node bin/spot.js summary            # whole library
node bin/spot.js summary <id>       # one playlist
node bin/spot.js find "Sultans"     # which playlists contain it
node bin/spot.js dupes
node bin/spot.js diff <a> <b>
node bin/spot.js snapshot weekly && node bin/spot.js changes
node bin/spot.js rediscover 4 50

Tools

Playlists — list_playlists, get_playlist, create_playlist, update_playlist, add_tracks, remove_tracks, delete_playlist, merge_playlists Library — get_saved_tracks, save_tracks, remove_saved_tracks, get_top_tracks, get_top_artists, get_recently_played Search — search, find_track (artist-verified), get_search_budget, get_api_limits Analysis (computed server-side, compact output — things Spotify users have asked for for a decade):

  • summarize_library — liked songs in no playlist, stale/empty playlists, cross-playlist overlaps, decades, dupes
  • summarize_playlist — runtime, top artists, decades, duplicates, over-representation
  • find_in_playlists — "which of my playlists has this song?"
  • dedupe_report — same artist+title ignoring remaster/live/edit suffixes, with ids to remove
  • playlist_diff — only-in-A / only-in-B / shared
  • snapshot_library · list_snapshots · changes_since — backup + "what changed since last week" (renames, adds, removes, likes)
  • rediscover — liked years ago, absent from top tracks and recent plays; spread across artists

On my library these found: 233 liked songs in no playlist, 210 near-duplicates inside playlists, 1,113 forgotten likes from 2018–2021.

Library scripts (how I reorganised 40 playlists → 9)

node scripts/pull.js library.json      # snapshot playlists + likes + tops
node scripts/build.js library.json     # file every track into genre collections (additive)
node scripts/moods.js                  # collapse genre collections into mood playlists
node scripts/curate.js library.json    # like picks, build Programming + שישי
node scripts/nostalgia.js library.json # 3-generation nostalgia
node scripts/explore.js library.json   # 🧭 Explore: ~400 new artists, many languages (search-heavy, resumable)
node scripts/genz.js                   # 🚗 Gen Z
node scripts/trending.js library.json  # 📈 Trending from live popularity

The artist lists in scripts/classify.js and friends are my taste — fork and edit. Every script is additive; deletions are separate explicit spot delete calls.

Tests

npm test runs the whole flow against an in-memory mock Spotify (test/mock-spotify.js). No real credentials touched.

claude.ai connector (remote)

npm run tunnel starts src/http.js (Streamable HTTP at /<MCP_SECRET>/mcp) plus a Cloudflare quick tunnel and prints the URL to paste into claude.ai → Settings → Connectors → Add custom connector (no OAuth; the secret path is the gate).

Quick tunnels get a new hostname each start. For a stable URL either run a named Cloudflare tunnel on your own domain, or deploy src/http.js behind your existing reverse proxy (e.g. the Nightscout box) with MCP_SECRET, SPOTIFY_CLIENT_ID, SPOTIFY_REFRESH_TOKEN in the environment.

Spotify API limits (2026, apps created after Nov 2024) — baked in

What Status Handled how
/audio-features, /recommendations, related-artists removed client throws a clear error before any request
batch GET /tracks?ids=, /artists?ids= 403 same; use single-item endpoints
artist genres field gone no genre data available, use your own knowledge
/playlists/{id}/tracks renamed /items, entries under item client uses new paths
POST /users/{id}/playlists deprecated POST /me/playlists
PUT/DELETE /me/tracks deprecated /me/library?uris= (max 20 per call, chunked)
name-only search returns karaoke/covers find_track tool verifies the artist
/search quota ~1000/day per app → 429 with retry-after ≈ 21h persistent daily budget (default 800, SPOTIFY_SEARCH_DAILY_CAP), result cache, ban memory — see below
~500 rapid calls silent TLS-level drop for ~10 min (no 429) 150 ms pacing + retry with backoff

get_api_limits tool returns this list to the model; the server's MCP instructions carry the summary too.

Search budget (learned 2026-08-23)

~1,000 /search calls in one day got this app a 429 with retry-after: 75469 (21 h). The limit is per app (client id), not per user, and it's the only quota we've hit that locks you out for a day.

What the server does about it (src/budget.js, state in .search-budget.json):

  • counts searches per UTC day and refuses past SPOTIFY_SEARCH_DAILY_CAP (default 800) with a clear error
  • caches every search result, so reruns of a script cost 0 searches
  • remembers a ban from a long retry-after and fails fast until it expires — no 21-hour sleeps
  • get_search_budget tool / searchBudget() report remaining, cached, banned-until

Bulk scripts (scripts/explore.js, genz.js, trending.js) print the budget first, stop cleanly at the cap, and resume on rerun (they skip what's already in the playlist). Plan ≈ 250 searches per script per day, or use a second Spotify app for bulk jobs.

Tomorrow's plan: ban lifts 2026-08-24 ~14:00 IDT → run explore (≈400, two days) or point a fresh client id at it.

推荐服务器

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

官方
精选