# marcelmarais/spotify-mcp-server architecture

> Architecture diagram of the GitHub repository marcelmarais/spotify-mcp-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/marcelmarais/spotify-mcp-server
- Repository: https://github.com/marcelmarais/spotify-mcp-server

## Overview

Spotify MCP Server exposes Spotify search, library, playlist, album, and playback operations as MCP tools. An MCP client connects through stdio or HTTP; the server registers domain tool handlers, which use shared Spotify access helpers and return formatted results. HTTP mode can validate per-request bearer tokens, while local configuration supports token refresh and authorization. The source excerpts show the main registration, transport, request-token, and API-call relationships; broader tool coverage follows the README, while unsampled implementation details are not inferred.

Main entry points: [`src/utils.ts`](https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/utils.ts) (Spotify API Access), [`src/server.ts`](https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/server.ts) (MCP Server), [`src/albums.ts`](https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/albums.ts) (Album Operations), [`src/tool.ts`](https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/tool.ts) (Tool Definition)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_transport["MCP Transport"]
  node_entry["Runtime Entry<br/>[index.ts]"]
  node_http["HTTP Transport<br/>[http.ts]"]
  node_server["MCP Server<br/>[server.ts]"]
end

subgraph group_tools["Spotify Tools"]
  node_read["Read Operations<br/>[read.ts]"]
  node_play["Playback Operations<br/>[play.ts]"]
  node_albums["Album Operations<br/>[albums.ts]"]
  node_playlist["Playlist Operations<br/>[playlist.ts]"]
  node_tool["Tool Definition<br/>[tool.ts]"]
  node_types["Spotify Types<br/>[types.ts]"]
end

subgraph group_access["Spotify Access"]
  node_context["Request Token Context<br/>[request-context.ts]"]
  node_utils["Spotify API Access<br/>[utils.ts]"]
end

subgraph group_auth["Authorization"]
  node_auth["Local OAuth Flow<br/>[auth.ts]"]
  node_config[("Spotify Config")]
end

node_client(("MCP Client"))
node_spotify["Spotify Web API"]

node_client -.->|"invokes"| node_entry
node_entry -->|"starts HTTP"| node_http
node_entry -->|"creates server"| node_server
node_http -->|"serves MCP"| node_server
node_server -->|"registers tools"| node_read
node_server -->|"registers tools"| node_play
node_server -->|"registers tools"| node_albums
node_server -->|"registers tools"| node_playlist
node_read -->|"defines tools"| node_tool
node_play -->|"defines tools"| node_tool
node_albums -->|"defines tools"| node_tool
node_playlist -->|"defines tools"| node_tool
node_albums -->|"uses types"| node_types
node_play -->|"calls API helpers"| node_utils
node_read -->|"calls API helpers"| node_utils
node_albums -->|"calls API helpers"| node_utils
node_playlist -->|"calls API helpers"| node_utils
node_http -->|"sets request token"| node_context
node_utils -->|"reads request token"| node_context
node_utils -.->|"requests data"| node_spotify
node_auth -->|"uses auth helpers"| node_utils
node_utils -.->|"reads and writes"| node_config

click node_entry "https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/index.ts"
click node_http "https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/http.ts"
click node_server "https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/server.ts"
click node_read "https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/read.ts"
click node_play "https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/play.ts"
click node_albums "https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/albums.ts"
click node_playlist "https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/playlist.ts"
click node_tool "https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/tool.ts"
click node_types "https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/types.ts"
click node_context "https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/request-context.ts"
click node_utils "https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/utils.ts"
click node_auth "https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/auth.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_http,node_server,node_client toneBlue
class node_read,node_play,node_albums,node_playlist,node_tool,node_types toneAmber
class node_context,node_utils,node_spotify toneMint
class node_auth,node_config toneRose
```

## Components

### MCP Transport

- [Runtime Entry](https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/index.ts): `src/index.ts`
- [HTTP Transport](https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/http.ts): `src/http.ts`
- [MCP Server](https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/server.ts): `src/server.ts`

### Spotify Tools

- [Read Operations](https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/read.ts): `src/read.ts`
- [Playback Operations](https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/play.ts): `src/play.ts`
- [Album Operations](https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/albums.ts): `src/albums.ts`
- [Playlist Operations](https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/playlist.ts): `src/playlist.ts`
- [Tool Definition](https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/tool.ts): `src/tool.ts`
- [Spotify Types](https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/types.ts): `src/types.ts`

### Spotify Access

- [Request Token Context](https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/request-context.ts): `src/request-context.ts`
- [Spotify API Access](https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/utils.ts): `src/utils.ts`

### Authorization

- [Local OAuth Flow](https://github.com/marcelmarais/spotify-mcp-server/blob/main/src/auth.ts): `src/auth.ts`
- **Spotify Config**

### Other components

- **MCP Client**
- **Spotify Web API**

## Connections

- MCP Client → Runtime Entry: invokes
- Runtime Entry → HTTP Transport: starts HTTP (evidence: `src/index.ts`)
- Runtime Entry → MCP Server: creates server (evidence: `src/index.ts`)
- HTTP Transport → MCP Server: serves MCP (evidence: `src/http.ts`)
- MCP Server → Read Operations: registers tools (evidence: `src/server.ts`)
- MCP Server → Playback Operations: registers tools (evidence: `src/server.ts`)
- MCP Server → Album Operations: registers tools (evidence: `src/server.ts`)
- MCP Server → Playlist Operations: registers tools (evidence: `src/server.ts`)
- Read Operations → Tool Definition: defines tools (evidence: `src/read.ts`)
- Playback Operations → Tool Definition: defines tools (evidence: `src/play.ts`)
- Album Operations → Tool Definition: defines tools (evidence: `src/albums.ts`)
- Playlist Operations → Tool Definition: defines tools (evidence: `src/playlist.ts`)
- Album Operations → Spotify Types: uses types (evidence: `src/albums.ts`)
- Playback Operations → Spotify API Access: calls API helpers (evidence: `src/play.ts`)
- Read Operations → Spotify API Access: calls API helpers (evidence: `src/read.ts`)
- Album Operations → Spotify API Access: calls API helpers (evidence: `src/albums.ts`)
- Playlist Operations → Spotify API Access: calls API helpers (evidence: `src/playlist.ts`)
- HTTP Transport → Request Token Context: sets request token (evidence: `src/http.ts`)
- Spotify API Access → Request Token Context: reads request token (evidence: `src/utils.ts`)
- Spotify API Access → Spotify Web API: requests data
- Local OAuth Flow → Spotify API Access: uses auth helpers (evidence: `src/auth.ts`)
- Spotify API Access → Spotify Config: reads and writes
