spotify-mcp
Integrates with the Spotify Web API to search the track catalog, list the user's playlists (with edit permissions), read recently played tracks and top tracks over several time ranges, create new playlists, and add tracks to existing playlists with a dry-run preview by default.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@spotify-mcp Make a private playlist of my top tracks from last month, preview first"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
spotify-mcp
A FastMCP server that lets an AI agent search Spotify, read your listening history, and create or extend your playlists. It runs over stdio, so it works with Claude Code and other MCP clients.
It targets the Spotify Web API after the February 2026 Development Mode changes:
playlist items are at
/playlists/{id}/items;playlists are created with
POST /me/playlists;search returns at most 10 results per request;
batch
GET /tracksno longer exists.
Tools
Tool | What it does | Annotations |
| Searches the catalog. Returns unique, ranked, compact tracks. | read-only, idempotent, open-world |
| Lists your playlists with | read-only, idempotent, open-world |
| Lists your recently played tracks (Spotify keeps about the last 50). | read-only, idempotent, open-world |
| Lists your most played tracks for about 4 weeks, 6 months or a year. | read-only, idempotent, open-world |
| Creates an empty playlist. Reads it back and reports what Spotify actually stored, with | write, not destructive, not idempotent, open-world |
| Previews (the default) or performs adding 1–20 tracks. Both modes first check that the playlist exists and is editable and that every track exists. | write, not destructive, not idempotent, open-world |
Typical chain: search_tracks (or a history tool) → list_my_playlists or create_playlist → add_tracks_to_playlist(dry_run=true) → you confirm → the same call with dry_run=false.
Track uri values from the read tools go into add_tracks_to_playlist.track_uris. Playlist id values from list_my_playlists or create_playlist go into add_tracks_to_playlist.playlist_id.
Related MCP server: Spotify MCP Server
Requirements
uv and Python ≥ 3.12.
A Spotify Premium account. Since February 2026 the owner of a Development Mode app must have Premium, and the app allows at most 5 users.
Commands
What | Command |
Install deps |
|
One-time Spotify login |
|
Check the stored login |
|
Start the server (stdio) |
|
Run the tests |
|
The tests are fully mocked with respx, so they need no network and no credentials.
Spotify setup (one time)
Go to https://developer.spotify.com/dashboard and choose Create app.
Under Which API/SDKs are you planning to use?, tick Web API.
Add the redirect URI
http://127.0.0.1:8888/callback. Spotify does not acceptlocalhost; it must be the loopback IP.
In the app's User Management tab, add the email of your Spotify account.
cp .env.example .envand setSPOTIFY_CLIENT_ID. The client secret is not needed because the server uses PKCE.Run
uv run spotify-mcp-login. A browser opens; approve the requested scopes.The refresh token is stored in
.spotify_token.jsonwith mode 0600. The file is git-ignored.The server refreshes access tokens from it automatically.
Requested scopes:
playlist-read-privateandplaylist-read-collaborative, to list your playlists.playlist-modify-privateandplaylist-modify-public, to create playlists and add tracks.user-read-private, for search and your profile.user-read-recently-playedanduser-top-read, for your listening history.
Connect to Claude Code
Copy
.mcp.json.templateto.mcp.json, in the directory where you start Claude Code. Or add the same entry to your user-level MCP config.Replace
<ABSOLUTE_PATH_TO_REPO>with the path to this repository and<your-spotify-client-id>with your Client ID..mcp.jsonis git-ignored because it contains the Client ID.If the
envblock is left out, the server falls back to this repository's.env.
Start
claudeand approve thespotifyserver./mcpshould showspotify · connectedwith 6 tools.
Then you can ask things like: "Find five songs like my top tracks from the last month and put them in a new private playlist called Discoveries. Show me what you'll add first."
Design notes
Auth. OAuth Authorization Code with PKCE.
Only the public Client ID appears in config, so there is no client secret that could leak.
Login is a separate command, because a stdio server cannot run an interactive browser flow in the middle of a tool call.
The server refreshes the token before it expires, and on a
401it refreshes once and retries. If Spotify returns a new refresh token, it is saved.
Errors. Every failure becomes
CATEGORY (HTTP n): what failed. Retryable: yes/no [(after Ns)]. Next step: ….Categories:
INVALID_INPUT,AUTH_REQUIRED,CONFIG_ERROR,PERMISSION_DENIED,NOT_FOUND,RATE_LIMITED,QUOTA_EXCEEDED,UPSTREAM_UNAVAILABLE.A
429is not retried silently: the agent getsRetry-Afterand decides.
Inputs. Schema bounds and patterns reject wrong input before any API call: Spotify's real
limitranges, a 22-character playlist ID,spotify:track:URIs, and 1–20 tracks per call.Outputs. Compact pydantic models keep only names and IDs; images, hrefs and markets are dropped.
Safety. Writes only add; nothing is removed or overwritten.
add_tracks_to_playlistdefaults to a dry run, andcreate_playlistreads the playlist back because Spotify can echopublic=falsefor a playlist it stores as public.
Layout
src/spotify_mcp/
server.py FastMCP instance + the 6 tools; main() serves stdio
client.py async httpx wrapper: auth header, 401 refresh-retry, error mapping
auth.py PKCE login CLI, token store (0600), refresh
errors.py error categories + agent-facing messages
models.py compact output models + mappers
tests/ pytest tests; tools are called through MCP (fastmcp.Client), Spotify is mocked with respxLicense
Available Tools
6 toolsadd_tracks_to_playlistAdd tracks to a playlist (dry run by default)A
Preview (dry_run=true, the default) or perform adding tracks to one of the user's playlists.
Both modes check that the playlist exists, that the user can edit it, and that every track URI exists, and they return the resolved track names. A dry run changes nothing. With dry_run=false the tracks are added to the live playlist. This is not idempotent: repeating the call adds the tracks again as duplicates. Recommended flow: search_tracks -> list_my_playlists/create_playlist -> this tool with dry_run=true -> user confirms -> same arguments with dry_run=false.
Inputs: track_uris (required), playlist_id (required), dry_run, position. Returns: tracks, dry_run, message, playlist, +3 more
create_playlistCreate a Spotify playlistA
Create a new, empty playlist owned by the signed-in user.
WRITE: this changes the user's Spotify account immediately and cannot be undone by these
tools. Calling it twice creates two playlists. Only call it when the user asked for a new
playlist; to extend an existing one, use list_my_playlists instead.
The returned id is the playlist_id for add_tracks_to_playlist. Check warnings and tell
the user about them before adding tracks.
Inputs: name (required), public, description. Returns: id, name, owner, public, +3 more
get_my_top_tracksGet my top tracksARead-onlyIdempotent
List the signed-in user's most played tracks for a time range, ranked by Spotify.
Each uri can be passed to add_tracks_to_playlist.track_uris. Read-only.
Inputs: limit, offset, time_range. Returns: total, tracks, time_range, next_offset
get_recently_playedGet my recently played tracksARead-onlyIdempotent
List the signed-in user's recently played tracks (Spotify keeps only the last ~50 plays).
Each uri can be passed to add_tracks_to_playlist.track_uris. Read-only.
For "what does the user listen to over the last weeks", prefer get_my_top_tracks.
Inputs: limit, before. Returns: before, tracks
list_my_playlistsList my Spotify playlistsARead-onlyIdempotent
List playlists in the signed-in user's library (owned, collaborative and followed).
Each playlist's id is the playlist_id for add_tracks_to_playlist. Only playlists with
can_edit: true (owned by the user or collaborative) accept new tracks. Read-only.
Inputs: limit, offset. Returns: total, playlists, next_offset
search_tracksSearch Spotify tracksARead-onlyIdempotent
Search the Spotify catalog for tracks.
Returns unique, ranked, compact track entries. Each uri (spotify:track:…) can be passed
directly to add_tracks_to_playlist.track_uris. Read-only; nothing in the user's account
changes.
Inputs: query (required), limit, offset. Returns: query, total, tracks, next_offset, +1 more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool targets a distinct resource+action: catalog search, playlist listing, recently played, top tracks, playlist creation, and track addition. The only potential confusion is between get_recently_played and get_my_top_tracks, but the descriptions explicitly cross-reference each other to steer selection.
All names use a clear, readable snake_case verb_noun pattern (search_tracks, create_playlist, add_tracks_to_playlist). The only deviation is the inconsistent inclusion of 'my' in list_my_playlists and get_my_top_tracks versus the plain forms elsewhere, but this is minor and never ambiguous.
Six tools is a tight, well-scoped set for a read-heavy Spotify integration with a single write path, and each tool clearly earns its place. It sits at the low end of the ideal 3-15 range but is not thin enough to hurt usability.
The create/search/add flow is well covered, but the surface has notable gaps: there is no way to read the contents of an existing playlist, remove or reorder tracks, or undo the warned-about non-idempotent add. An agent can build playlists but cannot inspect or clean them up afterward, creating dead ends.
Maintenance
Related MCP Connectors
Music industry tools for AI agents: artist research, catalogs, release plans and content.
Spotify MCP server for ChatGPT, Claude and any AI agent: search songs and artists, list playlists, read playlist songs, create playlist, add songs to playlist, remove songs from playlist, set playlist public or private and save to Liked Songs in your own Spotify account. Cotlet works in the account through your Cloud Browser, a real Chrome where you sign in to Spotify yourself; Cotlet does not store your password and you need no Spotify API key. About the official Spotify API: Spotify has a full Web API and, since 23 Apr 2026, an official connector for Claude (checked 5 Nov 2026). The API needs an app you register, and in development mode the app owner must have Premium and the app allows 5 users; unlimited users need a registered business with at least 250,000 monthly users. Setup and FAQ: https://cotlet.dev/integrations/spotify-api-mcp-server
Spotify tracks, artists and albums from URLs, IDs or keywords, with audio features (BPM, key).
Find active Spotify playlists for a song and check a playlist's integrity. No curator contacts.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to create, manage, and populate Spotify playlists using the Spotify Web API.3MIT
- AlicenseNot gradedqualityNot gradedmaintenanceEnables AI agents to search Spotify, inspect playback state, manage devices, and control music through the official Spotify Web API using OAuth authentication.3MIT
- AlicenseBqualityCmaintenanceEnables AI agents to search Spotify tracks and control playback (play, pause, skip, queue, volume) through the Spotify Web API.132MIT
- AlicenseNot gradedqualityCmaintenanceEnables an AI agent to search, create, add, remove, reorder, dedupe and rename Spotify playlists and build lists from song titles, while auditing every write, supporting undo, and restricting changes to playlists the user owns.PolyForm Noncommercial 1.0.0