Provides 51 granular tools for controlling Spotify playback, managing playlists and library, searching for music, monitoring playback state, controlling devices and volume, and accessing detailed track, artist, and album information through the Spotify API.
Spotify MCP Server
A comprehensive Model Context Protocol (MCP) server for Spotify
Provides 51 granular tools perfect for building dynamic HUDs, music visualizers, and AI-powered music control interfaces
Why This MCP Server?
This MCP server is specifically designed for dynamic HUD applications where you need individual data points. Instead of parsing large JSON responses, each tool returns exactly what you need.
Use Case | Traditional Approach | This Server |
Get track name | Parse JSON → Extract |
|
Get artist | Parse JSON → Extract |
|
Show countdown timer | Parse JSON → Calculate remaining time → Format |
|
Progress bar | Parse JSON → Calculate percentage |
|
Play/pause button | Parse JSON → Check |
|
Complete Tool Coverage
51 tools organized into 9 categories for maximum flexibility
Category | Tool Count | Description |
Bulk State Tools | 2 | Get complete playback state or track info in one call |
Granular Track Info | 16 | Individual tools for artist, track name, album, duration, progress, artwork, and more |
Granular Device Info | 6 | Get device name, type, volume, ID, and active status individually |
Granular Playback State | 5 | Individual tools for play state, shuffle, repeat mode, and context |
Playback Control | 7 | Play, pause, next, previous, seek, shuffle, and repeat controls |
Volume & Device Control | 2 | Set volume and transfer playback between devices |
Queue Management | 3 | View queue, add tracks, and see recently played |
Search & Discovery | 5 | Search tracks, albums, artists, and get detailed information |
Library Management | 5 | Manage saved tracks and playlists |
Key Features
Feature | Description |
Granular Data Access | 51 specialized tools for precise data retrieval |
HUD Optimized | Returns plain text values perfect for UI components |
Production Ready | Comprehensive error handling and automatic token refresh |
Full Test Coverage | 94 tests covering all 51 tools and edge cases |
Type Safe | Built with TypeScript and Zod schema validation |
OAuth Authentication | Automatic token management and refresh |
Zero Dependencies | Only requires Node.js 18+ and Spotify account |
Installation
Step | Instructions |
1. Prerequisites | • Node.js 18+ installed • Spotify Account (Premium recommended) • Spotify Developer App credentials |
2. Get Credentials | 1. Go to Spotify Developer Dashboard 2. Create a new app 3. Note your Client ID and Client Secret 4. Add |
3. Install |
|
4. Configure | Copy example env: Edit
|
5. Authenticate |
(Opens browser to log in and saves tokens) |
6. Build |
|
7. Configure Client | Add to { "mcpServers": { "spotify": { "command": "node", "args": ["/PATH/TO/dist/index.js"], "env": { ... } } } } |
Usage
Once configured, restart your MCP client and you'll have access to all 51 tools!
Example Queries
Category | User Query | Tool Used |
Dynamic HUDs | "What's the current track name?" |
|
"Get the artist" |
| |
"What's the time remaining?" |
| |
"What's the playback progress percentage?" |
| |
"Is music playing?" |
| |
Playback Control | "Pause the music" |
|
"Skip to the next song" |
| |
"Set volume to 50%" |
| |
"Enable shuffle" |
| |
Discovery | "Search for tracks by The Beatles" |
|
"Add this song to my library" |
|
Complete API Reference
Bulk State Tools (2)
Tool | Returns | Use Case |
| Complete playback state (JSON) | Get all playback info at once |
| Complete track info (JSON) | Get all track info at once |
Granular Track Info Tools (16)
Tool | Returns | Perfect For |
| Track name only | HUD track display |
| Primary artist name | HUD artist display |
| All artists (comma-separated) | Full artist credits |
| Album name only | HUD album display |
| Duration in milliseconds | Calculations |
| Duration as "M:SS" | HUD duration display |
| Current position in ms | Calculations |
| Current position as "M:SS" | HUD position display |
| Time left in ms | Calculations |
| Time left as "M:SS" | HUD countdown timer |
| Progress as 0-100 | Progress bars |
| Spotify URI | Playback control |
| Spotify ID | API calls |
| Album artwork URL | HUD artwork display |
| "true" or "false" | Explicit content indicator |
| Popularity 0-100 | Track metrics |
Granular Device Tools (6)
Tool | Returns | Perfect For |
| Device name | HUD device display |
| Device type | Device icons |
| Volume 0-100 | Volume displays |
| Device ID | Device switching |
| "true" or "false" | Active device indicator |
| All devices (JSON) | Device selection |
Granular Playback State Tools (5)
Tool | Returns | Perfect For |
| "true" or "false" | Play/pause button states |
| "true" or "false" | Shuffle button states |
| "off", "track", or "context" | Repeat button states |
| Context type | Playlist/album indicators |
| Context URI | Context switching |
Playback Control Tools (7)
Tool | Parameters | Description |
| device_id?, context_uri?, uris?, position_ms? | Start/resume playback |
| device_id? | Pause playback |
| device_id? | Skip to next track |
| device_id? | Skip to previous track |
| position_ms, device_id? | Seek to position |
| state (bool), device_id? | Toggle shuffle |
| state (track/context/off), device_id? | Set repeat mode |
Volume & Device Control Tools (2)
Tool | Parameters | Description |
| volume_percent (0-100), device_id? | Set playback volume |
| device_id, play? | Transfer playback to device |
Queue Management Tools (3)
Tool | Parameters | Description |
| - | Get current playback queue |
| uri, device_id? | Add track to queue |
| limit? | Get recently played tracks |
Search & Discovery Tools (5)
Tool | Parameters | Description |
| query, type[], limit? | Search for tracks/albums/artists/playlists |
| track_id | Get detailed track information |
| album_id | Get detailed album information |
| artist_id | Get detailed artist information |
| artist_id, market? | Get artist's top tracks |
Library Management Tools (5)
Tool | Parameters | Description |
| limit?, offset? | Get user's saved tracks |
| track_id | Save (like) a track |
| track_id | Remove (unlike) a track |
| limit?, offset? | Get user's playlists |
| playlist_id | Get playlist details |
Architecture
Token Management
Token Details |
Tokens are stored in |
Access tokens are automatically refreshed when they expire |
You only need to run |
Tokens persist across server restarts |
Error Handling
The server provides clear, actionable error messages:
Error Code | Meaning |
401 Unauthorized | Re-run |
403 Forbidden | Feature may require Spotify Premium |
404 Not Found | No active device or track |
429 Rate Limit | Too many requests, wait a moment |
Development
Task | Command |
Run Tests |
|
Run Linter |
|
Clean Build |
|
Debugging | Server logs to stderr |
Use Cases
Dynamic HUD Applications
Perfect for creating real-time music displays:
Music Visualizers
Get precise timing and state info:
AI Music Assistants
Natural language control: