music-warehouse-mcp
An MCP server that lets an AI agent ask questions about years of your own Spotify listening history, stored in a music-warehouse Worker, using read-only tools over stdio.
Search artists and songs by name to get the ids the history tools need.
Read individual plays in a date window, newest first, paged, optionally showing the playlist or album each came from.
Rank top artists and top songs over any date range (up to ~10 years), with song editions folded together.
Count plays per day, week or month, including quiet days as zero.
Get one artist's or one song's whole history: all-time plays, minutes, first and last play, monthly trend, top songs.
Look back on this day in each earlier year.
Pull precomputed stats: on-repeat tracks, listening rhythm and streaks, top over time, era comparisons, most-played albums.
Produce Wrapped-style summaries of a finished range (minutes, top artists/songs/albums, biggest day, hour and weekday breakdown, discoveries).
Check live Spotify data: what's playing now, Spotify's recent plays (including ones not yet stored), and Spotify's own short/medium/long-term top lists.
See upcoming concerts for your top artists in the regions your warehouse watches.
Provides read-only access to a user's Spotify listening history and live Spotify data through a music-warehouse Worker, enabling queries for search, individual plays, top artists and tracks, daily play counts, artist/track history, on-this-day stats, Wrapped-style summaries, now playing, recently played, and Spotify's own top tracks and artists.
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., "@music-warehouse-mcp what was I into in spring 2022?"
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.
An MCP server that lets an AI agent (Claude Code, Claude Desktop, Cursor and others) query the Spotify listening history stored by a music-warehouse Worker. The agent answers from your own data, years of it, not Spotify's last 50 plays. It runs locally over stdio and only reads.
This needs your own music-warehouse deployment. If you don't have one yet, start with the warehouse'squick start.
What it does
Ask things like:
"What was I into in spring 2022?"
"When did I first play Shelter?"
"How has my listening changed since I moved?"
and the agent picks the right tools: fifteen of them, all read-only, covering search, plays, top artists and songs over any range, per-artist and per-song history, precomputed stats, Wrapped-style summaries, upcoming concerts, and what's playing now.
Responses are trimmed for an agent: no image URLs or Spotify API links, play times shown in the local zone, Spotify objects cut to name, artists, album and id.
Related MCP server: Luminous MCP Server
How it works
flowchart LR
A[AI agent] <-->|stdio| M[music-warehouse-mcp]
M -->|"GET /api/* (read token)"| W[music-warehouse Worker]Every tool calls the Worker's /api/* routes with a read-only token. The
Worker does the storage and aggregation; this server only shapes the answers.
Why stdio, not a remote server
Running locally keeps the token on your machine and needs no change to the Worker beyond the read routes. The trade-off is that claude.ai on the web and mobile can't use it: their custom connectors need a remote server with OAuth.
Requirements
A deployed music-warehouse Worker at a version that has
/api/searchand/api/top-tracks(October 2026 or later), and/api/concertsforupcoming_concerts. To sign in with Spotify instead of copying a token, it also needs Spotify sign-in.Node.js 20 or later.
It isn't published to npm; install it from source as below.
Quick start
git clone https://github.com/rcnsh/music-warehouse-mcp && cd music-warehouse-mcp
npm install
npm run login -- --url https://music-warehouse.<you>.workers.dev
claude mcp add --scope user music-warehouse \
-e MUSIC_WAREHOUSE_URL=https://music-warehouse.<you>.workers.dev \
-- node "$PWD/dist/index.js"Then /mcp in Claude Code shows it connected. Each step is explained below.
Setup
1. Build
git clone https://github.com/rcnsh/music-warehouse-mcp && cd music-warehouse-mcp
npm install # also builds dist/MCP clients run dist/index.js directly, so after a git pull run
npm run build and restart the client. If you forget, the server notices that
src/ is newer than dist/ when it starts, says so on stderr, and asks the
agent to tell you.
2. Get a read token
Sign in with Spotify (easiest). Use the Spotify account that owns the warehouse:
npm run login -- --url https://music-warehouse.<you>.workers.devIt opens your browser (and prints the URL in case it doesn't), and once you
approve, saves a read token for that warehouse. On macOS it goes in the
Keychain (service music-warehouse-mcp, your Worker's host as the account),
replacing any token there. Elsewhere it goes in
~/.config/music-warehouse-mcp/tokens.json ($XDG_CONFIG_HOME if set),
readable only by you. A token an older version saved to that file on macOS is
moved to the Keychain the first time the server uses it, and removed from the
file once the Keychain has it. The token is listed on the warehouse as
MCP (<hostname>) (see the warehouse's
device tokens); pass
--name to choose another. It expires after 90 days: the tools then say so,
and you run the same command again. A new sign-in needs no restart.
--url defaults to MUSIC_WAREHOUSE_URL. If you install the clone globally
(npm install -g .), the same command is
music-warehouse-mcp login --url ….
Or store a token yourself. On macOS, put the Worker's READ_TOKEN in the
Keychain, under the service music-warehouse-mcp and your Worker's host as the
account. security prompts for it, so it never lands in your shell history:
security add-generic-password -s music-warehouse-mcp -a music-warehouse.<you>.workers.dev -wElsewhere, set MUSIC_WAREHOUSE_TOKEN in the MCP client's config instead (see
Configuration). Either one wins over a token in the file.
Use a read token, neverADMIN_TOKEN: nothing here needs more.
3. Add it to your client
For every project:
claude mcp add --scope user music-warehouse \
-e MUSIC_WAREHOUSE_URL=https://music-warehouse.<you>.workers.dev \
-- node "$PWD/dist/index.js"Run it from the clone, so $PWD is the right path. Then /mcp in Claude Code
shows it connected. If you run more than one Claude Code config directory
(CLAUDE_CONFIG_DIR), run the command once under each.
They take the same thing as JSON, in their MCP server config:
{
"mcpServers": {
"music-warehouse": {
"command": "node",
"args": ["/absolute/path/to/music-warehouse-mcp/dist/index.js"],
"env": { "MUSIC_WAREHOUSE_URL": "https://music-warehouse.<you>.workers.dev" }
}
}
}A GUI app may not see your shell'sPATH; if it can't start node, give its
absolute path (which node).
4. Check it
MUSIC_WAREHOUSE_URL=https://music-warehouse.<you>.workers.dev npm run smokecalls every tool once against your Worker and prints the start of each
answer. Or explore interactively with npm run inspect.
Configuration
Variable | Required | Meaning |
| yes | The Worker's origin. Must be |
| no | A read token, overriding the Keychain and a signed-in token. |
| no | IANA zone for local dates and times. Defaults to the system's. |
| no | Where |
| no |
|
The token is the first of:
MUSIC_WAREHOUSE_TOKEN.The macOS Keychain entry for the Worker's host (service
music-warehouse-mcp), wherenpm run loginsaves it on macOS.The token
npm run loginsaved in the file for the Worker's origin. Tokens are saved per origin, so one is only ever sent to the warehouse that minted it.
A missing or expired token doesn't stop the server starting: each tool says how to provide one, and a call soon after (the Keychain is asked again after 30 s) picks it up without a restart. A rejected token (401) names the login command, and the next call looks the token up afresh.
Tools
Fifteen tools, all read-only. Dates are YYYY-MM-DD local days in the
configured zone. Tools that take or return dates include today and tz in
their result, read at call time, so a server left running for days never
works from a stale date.
Tool | Answers | Worker route |
| Artists and songs by name, with all-time plays. The way in to the history tools. |
|
| Individual plays, newest first, in a window, up to 200 a page. Pages with |
|
| Plays per artist between two dates. |
|
| Plays per song between two dates, editions folded. |
|
| Ticketmaster gigs in the regions your warehouse watches, for your top artists; |
|
| Plays per day, or summed per week or month, with a total. |
|
| One artist's plays, minutes, first and last play, months, top songs. |
|
| The same for one song, editions folded together. |
|
| Top songs on this date in each earlier year. |
|
|
|
|
| Which ranges |
|
| A Wrapped-style summary of a finished range. |
|
| What's playing right now. |
|
| Spotify's last plays, including ones not stored yet. |
|
| Spotify's own top tracks and artists. |
|
The last three are live and need the Worker's Spotify grant; the rest read stored rows and keep working when it lapses.
When a tool fails, its message says why and what to do: a rejected token names
npm run login, a lapsed grant names npm run authorize in the
music-warehouse repo, a stat still computing is waited out (up to 25 s) before
giving up.
Names in results (tracks, artists, playlists, concerts) are other people's text, so each stays in its own field, and the server's instructions tell the agent to treat results as data, never as instructions.
get_plays pages with the Worker's own next_before cursor when it sends one.
An older Worker only pages by millisecond, which would skip plays sharing the
last row's millisecond (common in imported history), so for those the server
issues its own cursor (mcp:<ms>:<track ids>) and drops plays it already
returned.
Development
Command | Does |
|
|
| vitest: the client, formatting, sign-in, and every tool over an in-memory MCP connection |
| Type-checks source and tests |
| Calls every tool once against a real Worker (needs |
| Opens the MCP Inspector on |
Tests fake fetch, so they need no Worker. The sign-in test runs the real
loopback listener and plays the browser's redirect itself. npm run smoke is
the end-to-end check against a real one.
Related projects
Project | |
The Worker: records your plays and serves the API | |
Desktop app for browsing your history on macOS, Linux and Windows | |
music-warehouse-mcp (this repo) | MCP server so AI agents can query your history |
Stats inside the Spotify desktop client | |
Wrapped-style stories for any range, in the browser |
Licence
MIT. See LICENSE.
Available Tools
14 toolsartist_historyOne artist's whole historyARead-onlyIdempotent
An artist's all-time plays, estimated minutes, first and last play, plays per month, and their most-played songs. Counts only plays where they are the primary artist. Give the id from search, or the name (which also catches plays from the imported export), or both.
Inputs: id, name.
daily_play_countsPlays per day, week or monthARead-onlyIdempotent
How many plays on each local day between two dates, quiet days as 0, optionally summed into weeks (from Monday) or months. Use month or week for spans longer than a few months.
Inputs: to, from, group_by.
get_playsIndividual playsARead-onlyIdempotent
Individual stored plays, newest first, with local time, track, artists and album. Give after and before to read a window (newest first within it). If next_before is returned, pass it as before for the next, older page. For counts over a range prefer daily_play_counts or top_artists, which are far cheaper.
Inputs: after, limit, before.
get_statPrecomputed listening statsARead-onlyIdempotent
All-time aggregates, refreshed every few hours. on-repeat: songs and albums played far more than usual in the last 14 days. rhythm: listening streaks and plays by hour. top-over-time: top artists and songs per quarter and per year. eras: how taste changed between the two eras the warehouse is configured with (e.g. before and after a move). albums: most-played albums, all time and per year.
Inputs: name (required).
get_wrappedWrapped-style summaryARead-onlyIdempotent
A Spotify-Wrapped-style summary of a finished date range: minutes, top artists, songs and albums, biggest day, streak, listening by hour and weekday, each month’s top artist and song, discoveries and a listening age. Use a range from list_wrapped_ranges; others may be refused.
Inputs: to (required), from (required).
list_wrapped_rangesWrapped ranges availableARead-onlyIdempotent
The date ranges get_wrapped can summarise: each year with plays, and this year so far.
Inputs: no named parameters.
now_playingPlaying right nowARead-only
What Spotify is playing right now, live, or null when nothing is. Needs the warehouse's Spotify grant.
Inputs: no named parameters.
on_this_dayOn this day in earlier yearsBRead-onlyIdempotent
The most-played songs on this calendar date in each earlier year, with that day’s total plays.
Inputs: date.
recently_played_liveRecently played, live from SpotifyARead-only
Spotify's own last plays (at most 50), including ones the warehouse has not stored yet (it polls every 30 minutes). For anything older use get_plays. Needs the Spotify grant.
Inputs: limit.
searchSearch artists and songsARead-onlyIdempotent
Find artists and songs in the stored listening history by name (case-insensitive substring), with all-time play counts. Use this first to turn a name into the id that artist_history and track_history take. An artist with id null is known only from the imported export: pass its name to artist_history instead.
Inputs: query (required), limit, artist.
spotify_topSpotify's top listsARead-only
Spotify's own top tracks and artists, live. short_term is about 4 weeks, medium_term about 6 months, long_term about a year. For exact counts over any range, use top_artists or get_stat instead. Needs the Spotify grant.
Inputs: type, limit, range.
top_artistsTop artists over a date rangeARead-onlyIdempotent
Play counts per artist between two local dates (inclusive), most played first. Credits every artist on a track. Defaults to the last 30 days. Ranges up to 3,660 days.
Inputs: to, from, limit.
top_tracksTop songs over a date rangeARead-onlyIdempotent
Play counts per song between two local dates (inclusive), most played first, with editions of a song (single, album, remaster) folded together. Use this for "my top songs in July" or "most played song last year". Defaults to the last 30 days. Ranges up to 3,660 days.
Inputs: to, from, limit.
track_historyOne song's whole historyARead-onlyIdempotent
A song's all-time plays, estimated minutes, first and last play, and plays per month, with every edition of it (single, album, remaster) folded together. Takes a track id: use search to find one by name.
Inputs: id (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 14 tools
Most tools target clearly distinct query types: name search, raw plays, top lists, daily counts, entity histories, Wrapped summaries, precomputed aggregates, and live Spotify state. Some overlap remains between top_artists/top_tracks, get_stat aggregates, get_wrapped, and stored vs live recent plays, but descriptions provide explicit guidance on when to use which.
All names use readable snake_case with no camelCase or chaotic variation. The set is not a strict verb_noun pattern throughout, since many tools are noun phrases like artist_history, now_playing, and spotify_top, but the convention is still predictable and consistent.
Fourteen tools fits comfortably within the ideal 3-15 range for an analytics-style server. Each tool covers a distinct listening-history or Spotify-live query, and there is no excessive filler or fragmentation.
The surface strongly covers read-only listening analytics: search, raw plays, top artists/tracks, daily counts, artist/track histories, on-this-day, Wrapped, precomputed stats, and live Spotify tools. Minor gaps remain, such as no direct per-artist or per-track query over an arbitrary date range beyond top lists, and no metadata/import management, but core workflows are covered.
Maintenance
Related MCP Connectors
Music industry tools for AI agents: artist research, catalogs, release plans and content.
The media memory layer for AI agents and their humans. Your AI client can search your collection, add and log what you've finished, update ratings and lists, and find patterns across everything you've read, watched, played, and listened to.
Anonymous public tools for Zachary Roth Music. See the published agent boundary before use.
Persistent memory, hybrid search and a goal graph for AI agents, over stdio or remote HTTP.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables AI agents to access public Spotify data (tracks, albums, artists, playlists, podcasts) without an API key, including lyrics and podcast transcripts with optional login.281,912 PyPI324MIT
- AlicenseNot gradedqualityBmaintenanceConnects AI assistants to a local music library for full-text search and filtering of tracks, albums, artists, genres, composers, and lyrics, plus listening analytics and metadata hygiene audits. Also lets users generate and populate playlists and control playback (play, pause, seek, volume) in a running player instance.MIT
- AlicenseNot gradedqualityBmaintenanceExposes a self-hosted SQLite master of a user's complete Last.fm listening history over Streamable HTTP with OAuth 2.1, so ChatGPT or Claude can answer questions about any date range without hitting the Last.fm API. Provides 32 tools covering recent plays, period rankings, range comparisons, artist listening intensity, session segmentation, and shifts in taste over time.MIT
- AlicenseBqualityBmaintenanceEnables MCP clients such as ChatGPT, Claude, and Claude Code to search a music catalog, find and compare tracks, and create, edit, and delete playlists through the official streaming-service API. Supports remote Cloudflare Workers deployment with OAuth, or local stdio use with locally stored sessions.10MIT