Skip to main content
Glama
README.md
# Spotify MCP

Stateless Spotify MCP server over Streamable HTTP. It exposes the requested
tools and uses an OAuth 2.1 broker flow:

```text
MCP client / CLYE -> /oauth/authorize -> Spotify -> /oauth/spotify/callback
                   -> MCP client callback -> /oauth/token -> /mcp
```

No OAuth sessions, codes, refresh tokens, or user data are persisted by this
server. OAuth artifacts are short-lived AES-256-GCM sealed values derived from
`MCP_STATE_SECRET`; Spotify refresh tokens remain inside encrypted MCP refresh
tokens held by the MCP client. PKCE is mandatory and redirect URIs are checked
exactly against the stateless signed client registration.

## Configuration

Copy `.env.example` to the deployment's secret/environment configuration. The
CLYE callback is:

```text
MCP_CLIENT_REDIRECT_URI=https://chat.z-code.ai/api/mcp/oauth/callback
```

That URL is the MCP client's callback and must not be used as Spotify's own
callback. In the Spotify Developer Dashboard register the server URL from
`SPOTIFY_REDIRECT_URI`, for example:

```text
https://spotify-mcp.example.com/oauth/spotify/callback
```

`SPOTIFY_CLIENT_SECRET` and `MCP_STATE_SECRET` must be injected by the runtime
secret manager and must never be committed, logged, or placed in a catalog file.

## Run

```sh
npm install
npm run build
npm start
```

The MCP endpoint is `PUBLIC_URL/mcp`. OAuth discovery is available at
`/.well-known/oauth-protected-resource/mcp` and
`/.well-known/oauth-authorization-server`.

`spotify_delete_playlist` intentionally unfollows a playlist: Spotify does not
provide a playlist-delete Web API endpoint.

`spotify_set_playlist_cover_image` accepts a public HTTPS image URL and converts,
resizes, and compresses it internally to a Spotify-compatible JPEG of at most
256 KB before uploading. Source images may be up to 10 MB. For compatibility,
the tool also accepts a `data:image/*;base64,...` value via `image_base64`.