Cadence
Detects your work mode and plays Spotify music matched to the task, learning your taste over time to keep you in flow.
README
<p align="center"> <img src="assets/banner.svg" alt="Cadence โ focus music for Claude Code" width="100%"> </p>
<p align="center"> <b>Cadence</b> detects what you're working on and plays Spotify music matched to the task โ tuned to your taste, learned over time, to keep you in flow. <br><br> <a href="#install"><img src="https://img.shields.io/badge/Claude_Code-plugin-7C5CFC?style=flat-square" alt="Claude Code plugin"></a> <img src="https://img.shields.io/badge/license-MIT-22D3A6?style=flat-square" alt="MIT"> <img src="https://img.shields.io/badge/Spotify-Web_API-1DB954?style=flat-square" alt="Spotify Web API"> <img src="https://img.shields.io/badge/node-%E2%89%A518-339933?style=flat-square" alt="node >= 18"> </p>
What it does
You code. Cadence quietly reads the shape of your work โ debugging, writing docs, planning, reviewing, crunching โ and plays music chosen to suit it: lyric-free deep-focus beats while you implement, warm steady jazztronica while you debug, peaceful piano while you write, driving DnB when you're shipping under pressure.
- ๐๏ธ Auto-switches music as your task changes โ or stays fully manual. Your call.
- ๐ง Learns your taste per work mode from your feedback (love / like / dislike / ban / more-like-this) and your listening โ all 100% local.
- ๐ฏ 9 curated vibes mapped to work modes, each grounded in focus/attention research.
- ๐ Spotify Web API (OAuth PKCE) with a playerctl/AppleScript fallback so basic control works even without Premium on Linux/macOS.
- ๐ Private by design โ tokens in your OS keychain, preferences in a local file, nothing phoned home.
How it works
Claude Code session
โ
hooks (UserPromptSubmit / SessionStart) โ ~5ms, non-blocking
โ one-line event over a Unix socket
โผ
Cadence MCP server โโ the single "brain" โโโโโโโโโโโโโโโ
โ โ
โโโโโโดโโโโโโฌโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโค
detect curation learning Spotify local
work mode 9-vibe map (local, no-ML) Web API playerctl
/ AppleScript
โฒ
slash commands (/cadence:play, /cadence:vibe, โฆ) โ mcp__cadence__* tools
One MCP server owns everything (OAuth, state, curation, learning, playback). Hooks are deliberately dumb โ they fire a tiny event at the brain and exit immediately, so they never stall your turn. Discovery is built entirely on Spotify's surviving API surface (search + your own library) and a local, fully-deterministic preference model โ no ML training on Spotify content.
Install
Requires: Node.js โฅ 18, a free Spotify account (Premium for Web API playback control โ see limitations), and your own Spotify app Client ID (one-time, 2 minutes โ below).
1. Create your Spotify app (one time)
- Go to the Spotify Developer Dashboard โ Create app.
- Add this exact Redirect URI:
http://127.0.0.1:8888/callback- use the
127.0.0.1loopback IPv4 literal โlocalhostis rejected by Spotify http(nothttps) is allowed because it's loopback- if port
8888is taken on your machine, set a differentauth_portin the plugin config and register the matchinghttp://127.0.0.1:<port>/callback
- use the
- Copy the Client ID.
2. Add the plugin
/plugin marketplace add lomartins/cadence
/plugin install cadence@cadence-marketplace
When prompted, paste your Client ID and pick your market (e.g. US, GB, BR).
3. Connect & play
/cadence:connect # opens your browser, waits for the callback, shows status
/cadence:play # start focus music for what you're doing
connect blocks until you click Agree in the browser, then reports the live
connection status.
Auto-switch is on by default but deliberately gentle: it never cuts the
current track โ it queues the new vibe to play next, so your song finishes
first. It only acts when music is already playing and only in response to
your prompts (never tool activity), with a 4-minute debounce, and never
starts music on its own. Manual /cadence:vibe / /cadence:play switch
immediately (that's your call). Turn auto off any time with /cadence:auto off.
Commands
Plugin commands are namespaced under cadence: (type /cadence: to see them all):
| Command | What it does |
|---|---|
/cadence:connect [url] |
Authorize Spotify (waits for callback). Optional pasted URL for headless/SSH |
/cadence:disconnect |
Clear stored tokens |
/cadence:play [vibe] [0-4] |
Start music for the current task |
/cadence:pause ยท /cadence:resume ยท /cadence:skip |
Transport controls |
/cadence:vibe <slug> |
Switch vibe |
/cadence:intensity <0-4> |
Energy: 0 minimal โฆ 4 peak |
/cadence:auto [on|off|toggle] |
Automatic switching |
/cadence:love ยท /cadence:dislike ยท /cadence:ban |
Teach your taste |
/cadence:status |
What's happening |
/cadence:reset [all|vibe] |
Reset learned preferences |
/cadence:focus [vibe] [0-4] |
Shortcut to start instantly |
You can also just talk to Claude: "play something calmer", "I love this one", "stop changing the music" โ the bundled skill maps that to the right MCP tool.
The vibes
| Vibe | For | Character |
|---|---|---|
deep-focus |
implementation / deep-focus coding | lo-fi, ambient, chillhop โ lyric-free, steady |
steady-flow |
debugging | warm chillhop / nu-jazz โ predictable, frustration-buffering |
wordless-write |
writing & docs | solo piano / neoclassical โ zero lyrics, protects verbal WM |
open-think |
planning / architecture | ambient / generative โ spacious, aids divergent thinking |
calm-read |
code review / reading | quiet ambient / drone โ low-arousal, preserves comprehension |
alert-study |
learning / research | chillhop / baroque โ alert but unobtrusive |
momentum |
repetitive / mechanical | house / nu-disco / funk โ upbeat, lyrics OK |
decompress |
breaks | indie folk / bossa nova โ high-valence, restorative |
drive |
crunch / shipping | DnB / techno / epic score โ high-energy, propulsive |
Each vibe carries an intensity scale (0โ4) that widens/narrows the BPM and energy
band of the search. Rationale for every choice lives in
src/data/presets.json.
How learning works
Every signal โ explicit (love/like/dislike/ban/more) and implicit (completed,
skipped-early, replayed, accepted/rejected auto-switch) โ is appended to a local
feedback.jsonl and folded into per-vibe preference profiles: artist/genre/track
scores (weighted updates + exponential decay), an audio-intent centroid, and a
time-of-day histogram. Candidate tracks are ranked with an explainable weighted
sum, and selection is epsilon-greedy (explore vs exploit) with a per-artist
diversity cap so it never goes stale.
It is deterministic statistics, not ML (counts, decay, Welford mean/var) โ
both to stay explainable and to respect Spotify's terms. state.json is just a
fold over the log โ it can be recomputed from scratch (the rebuild tool).
Everything customizable lives in config.json (ranking weights, signal deltas,
thresholds, decay half-life, explore epsilon, auto-switch debounce/confidence).
Privacy
- Local only. No telemetry. The only network calls are to your own authenticated Spotify API.
- Tokens live in your OS keychain (libsecret / Keychain / Credential Manager),
falling back to a
0600file. Never instate.json, never in the repo. - Track titles are not stored by default (
privacy.store_track_titles: false) โ only opaque Spotify URIs. /cadence:reset(plusexport/forget <uri>/rebuildโ just ask Claude) give you full control.
Spotify 2026 limitations (read this)
Spotify heavily restricted the Web API for new apps (Nov 2024 + Feb/Mar 2026). Cadence is built around what survives, but you should know:
- You supply your own Client ID. A dev-mode app is capped at 5 users, so sharing one app doesn't scale โ each user registers their own (2 min, above).
- The app owner (you) must have an active Spotify Premium subscription for the app to function at all, and playback control (play/pause/skip) requires the listening account to be Premium.
- No Premium? On Linux (
playerctl) and macOS (AppleScript) Cadence falls back to controlling your desktop Spotify app for play/pause/next (no track selection). Windows without Premium can't control playback. - Recommendations / audio-features / related-artists endpoints are gone for new apps โ Cadence discovers via Search + your library instead, which is why curated search queries and your own taste do the heavy lifting.
- Refresh tokens expire after ~6 months โ you'll re-run
/cadence:connectabout twice a year.
Develop
npm install # also builds dist/ via the prepare hook
npm run build # esbuild bundle -> dist/
npm run typecheck # tsc --noEmit
npm test # vitest
npm run dev # run the MCP server directly (uses .env)
Architecture details: docs/ARCHITECTURE.md.
License
MIT ยฉ Luisa Martins. See LICENSE.
<p align="center"><sub>Built to keep you in flow. ๐ง</sub></p>
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.