How alexandermolano-spec/spotify-mcp-server works
Spotify MCP Server exposes Spotify catalog, account, playback, device, playlist, and queue operations as Streamable HTTP MCP tools. An agent sends requests to the HTTP app; the MCP handler manages sessions and authentication context, then dispatches registered tools to the Spotify Web API client. Local OAuth is a separate login-and-callback path that stores and refreshes one token; delegated tokens arrive with MCP requests and are kept in session memory. Edges reflect shown calls or README-documented behavior; unsampled internals are represented only where documented.
Main entry points: auth.routes.ts Local OAuth routes · spotifyAccountsClient.ts Accounts client · tokenStore.ts Local token store · authProvider.ts Auth provider
Components 14
HTTP transport
- HTTP app
src/http/app.ts - MCP session handler
src/mcp/handler.ts
MCP tools
- MCP server
src/mcp/server.ts - Spotify tool registry
src/mcp/tools.ts
Spotify API
- Spotify API client
src/spotify/spotifyWebApiClient.ts - Spotify Web API
Authentication
- Local OAuth routes
src/spotify/auth.routes.ts - OAuth state
src/spotify/oauthState.ts - Accounts client
src/spotify/spotifyAccountsClient.ts - Local token store
src/spotify/tokenStore.ts - Auth provider
src/spotify/authProvider.ts - Environment config
src/config/env.ts
Other components
- AI agent
- Spotify Accounts
Connections 18
- AI agent → HTTP app: sends MCP requests
README.md - HTTP app → MCP session handler: routes MCP
src/http/app.ts - HTTP app → Local OAuth routes: mounts OAuth
src/http/app.ts - MCP session handler → MCP server: creates server
src/mcp/handler.ts - MCP server → Spotify tool registry: registers tools
src/mcp/server.ts - Spotify tool registry → Spotify API client: calls operations
src/mcp/tools.ts - Spotify API client → Auth provider: gets access token
src/spotify/spotifyWebApiClient.ts - Spotify API client → Spotify Web API: sends API requests
src/spotify/spotifyWebApiClient.ts - Local OAuth routes → OAuth state: creates and consumes
src/spotify/auth.routes.ts - Local OAuth routes → Accounts client: builds URL and exchanges code
src/spotify/auth.routes.ts - Local OAuth routes → Local token store: saves token
src/spotify/auth.routes.ts - Local OAuth routes → Auth provider: reads auth status
src/spotify/auth.routes.ts - Accounts client → Spotify Accounts: exchanges and refreshes tokens
src/spotify/spotifyAccountsClient.ts - Auth provider → Local token store: uses local tokens
src/spotify/authProvider.ts - Local token store → Accounts client: refreshes expired token
src/spotify/tokenStore.ts - Local token store → Environment config: reads store path
src/spotify/tokenStore.ts - Accounts client → Environment config: reads OAuth settings
src/spotify/spotifyAccountsClient.ts - MCP session handler → Auth provider: sets delegated context
src/mcp/handler.ts