~/.mibyan/auth.json and refreshed automatically on 401; you only log in once per machine (refresh tokens expire after ~6 months; re-run mibyan auth spotify when they do).
Unlike Mibyan’ built-in OAuth integrations (Google, GitHub Copilot, Codex), Spotify requires every user to register their own lightweight developer app. Spotify does not let third parties ship a public OAuth app that anyone can use. It takes about two minutes and mibyan auth spotify walks you through it.
Prerequisites
- A Spotify account. Free works for search, playlist, library, and activity tools. Premium is required for playback control (play, pause, skip, seek, volume, queue add, transfer).
- Mibyan installed and running.
- For playback tools: an active Spotify Connect device — the Spotify app must be open on at least one device (phone, desktop, web player, speaker) so the Web API has something to control. If nothing is active you’ll get a
403 Forbiddenwith a “no active device” message; open Spotify on any device and retry.
Setup
One-shot: mibyan tools or first-run setup
The fastest path. Run:
🎵 Spotify, press space to toggle it on, then s to save. The same toggle is also available during the first-run mibyan setup / mibyan setup tools flow. Spotify stays opt-in, so enabling it there runs the same provider-aware configuration as mibyan tools.
Mibyan drops you straight into the OAuth flow — if you don’t have a Spotify app yet, it walks you through creating one inline. Once you finish, the toolset is enabled AND authenticated in one pass.
If you prefer to do the steps separately (or you’re re-authing later), use the two-step flow below.
Two-step flow
1. Enable the toolset
🎵 Spotify on, save, and when the inline wizard opens, dismiss it (Ctrl+C). The toolset stays on; only the auth step is deferred.
2. Run the login wizard
mibyan_SPOTIFY_CLIENT_ID is set, Mibyan walks you through the app registration inline:
- Opens
https://developer.spotify.com/dashboardin your browser - Prints the exact values to paste into Spotify’s “Create app” form
- Prompts you for the Client ID you get back
- Saves it to
~/.mibyan/.envso future runs skip this step - Continues straight into the OAuth consent flow
providers.spotify in ~/.mibyan/auth.json. The active inference provider is NOT changed — Spotify auth is independent of your LLM provider.
Creating the Spotify app (what the wizard asks for)
When the dashboard opens, click Create app and fill in:
Agree to the terms and click Save. On the next page click Settings → copy the Client ID and paste it into the Mibyan prompt. That’s the only value Mibyan needs — PKCE doesn’t use a client secret.
Running over SSH / in a headless environment
IfSSH_CLIENT or SSH_TTY is set, Mibyan skips the automatic browser open during both the wizard and the OAuth step. Copy the dashboard URL and the authorization URL Mibyan prints, open them in a browser on your local machine, and proceed normally — the local HTTP listener still runs on the remote host on port 43827. Your laptop’s browser can’t reach the remote loopback without an SSH local-forward:
Verify
mibyan auth logout spotify.
Using it
Once logged in, the agent has access to 7 Spotify tools. You talk to the agent naturally — it picks the right tool and action. For the best behavior, the agent loads a companion skill that teaches canonical usage patterns (single-search-then-play, when not to preflightget_state, etc.).
Tool reference
All playback-mutating actions accept an optionaldevice_id to target a specific device. If omitted, Spotify uses the currently active device.
spotify_playback
Control and inspect playback, plus fetch recently played history.
spotify_devices
Home Assistant-managed speakers
If Home Assistant manages speakers that already support Spotify Connect (for example Sonos, Echo, Nest, or other Connect-capable speakers), they appear inspotify_devices list automatically whenever Spotify can see them. Mibyan does not need a Home Assistant ↔ Spotify bridge for this path — Spotify handles the device routing natively.
Ask Mibyan to transfer playback by the speaker’s display name (for example, “transfer Spotify to the kitchen speaker”), or call spotify_devices list and pass the exact device_id to spotify_devices transfer when scripting. If the speaker is missing, open the Spotify app or the speaker’s Spotify integration once so Spotify registers it as an active Connect target.
spotify_queue
spotify_search
Search the catalog. query is required. Optional: types (array of track / album / artist / playlist / show / episode), limit, offset, market.
spotify_playlists
spotify_albums
spotify_library
Unified access to saved tracks and saved albums. Pick the collection with the kind arg.
Required:
kind = tracks or albums, plus action.
Feature matrix: Free vs Premium
Read-only tools work on Free accounts. Anything that mutates playback or the queue requires Premium.Scheduling: Spotify + cron
Because Spotify tools are regular Mibyan tools, a cron job running in a Mibyan session can trigger playback on any schedule. No new code needed.Morning wake-up playlist
- Cron spins up a headless Mibyan session.
- Agent reads the prompt, calls
spotify_devices listto find “kitchen speaker” by name, thenspotify_devices transfer→spotify_playback set_volume→spotify_playback set_shuffle→spotify_search+spotify_playback play. - Music starts on the target speaker. Total cost: one session, a few tool calls, no human input.
Wind-down at night
Gotchas
- An active device must exist when the cron fires. If no Spotify client is running (phone/desktop/Connect speaker), playback actions return
403 no active device. For morning playlists, the trick is to target a device that’s always on (Sonos, Echo, a smart speaker) rather than your phone. - Premium required for anything that mutates playback — play, pause, skip, volume, transfer. Read-only cron jobs (scheduled “email me my recently played tracks”) work fine on Free.
- The cron agent inherits your active toolsets. Spotify must be enabled in
mibyan toolsfor the cron session to see the Spotify tools. - Cron jobs run with
skip_memory=Trueso they don’t write to your memory store.
Sign out
~/.mibyan/auth.json. To also clear the app config, delete mibyan_SPOTIFY_CLIENT_ID (and mibyan_SPOTIFY_REDIRECT_URI if you set it) from ~/.mibyan/.env, or run the wizard again.
To revoke the app on Spotify’s side, visit Apps connected to your account and click REMOVE ACCESS.
Troubleshooting
403 Forbidden — Player command failed: No active device found — You need Spotify running on at least one device. Open the Spotify app on your phone, desktop, or web player, start any track for a second to register it, and retry. spotify_devices list shows what’s currently visible.
403 Forbidden — Premium required — You’re on a Free account trying to use a playback-mutating action. See the feature matrix above.
204 No Content on get_currently_playing — nothing is currently playing on any device. This is Spotify’s normal response, not an error; Mibyan surfaces it as an explanatory empty result (is_playing: false).
INVALID_CLIENT: Invalid redirect URI — the redirect URI in your Spotify app settings doesn’t match what Mibyan is using. The default is http://127.0.0.1:43827/spotify/callback. Either add that to your app’s allowed redirect URIs, or set mibyan_SPOTIFY_REDIRECT_URI in ~/.mibyan/.env to whatever you registered.
429 Too Many Requests — Spotify’s rate limit. Mibyan returns a friendly error; wait a minute and retry. If this persists, you’re probably running a tight loop in a script — Spotify’s quota resets roughly every 30 seconds.
401 Unauthorized keeps coming back — Your refresh token was revoked (usually because you removed the app from your account, or the app was deleted). Run mibyan auth spotify again.
Wizard doesn’t open the browser — If you’re over SSH or in a container without a display, Mibyan detects it and skips the auto-open. Copy the dashboard URL it prints and open it manually.
Advanced: custom scopes
By default Mibyan requests the scopes needed for every shipped tool. Override if you want to restrict access:Advanced: custom client ID / redirect URI
~/.mibyan/.env:

