Provides comprehensive Spotify integration including search for tracks/albums/artists/playlists, playback control (play/pause/skip/volume/shuffle), library management (saving and removing tracks), playlist operations (create/modify playlists), and personalized music recommendations based on mood, genre, and listening history.
Spotify MCP Server
Model Context Protocol (MCP) server that provides Spotify integration for Claude Desktop.
⚠️ This project is experimental / for personal use only
This repository is a personal project created for fun and learning. It has not been exhaustively tested or production hardened. Use at your own risk — including re-authenticating if scopes change and backing up any important data.
Features
🔍 Search
Search for tracks, albums, artists, and playlists
🎵 Playback Control
Get current playback state
Play/pause, skip, previous track
Control volume and shuffle
Seek within tracks
📚 Library Management
Get saved tracks
Save and remove tracks from library
Check if tracks are saved
🎼 Playlists
Get user playlists
Create new playlists
Add/remove tracks from playlists
Get playlist details
🎯 Recommendations
Get personalized recommendations based on:
Seed tracks, artists, or genres
Mood preferences (energy, danceability, valence)
Automatic recommendations from recent listening history
Get available genre seeds
💬 Intelligent Prompts
Discover Music: Get recommendations based on mood and preferences
Analyze Now Playing: Deep analysis of currently playing track
Create Themed Playlist: Build playlists around themes or activities
Setup
1. Create Spotify App
Click "Create app"
Fill in:
App name: "MCP Spotify" (or any name)
App description: "Personal Spotify MCP Server"
Redirect URI:
http://localhost:3000/callback
Check "Web API" under "Which API/SDKs are you planning to use?"
Agree to terms and click "Save"
Click "Settings" to view your Client ID and Client Secret
2. Configure Environment
Create a .env file in the project root:
3. Build the Server
4. Configure Claude Desktop
Edit your Claude Desktop config file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Add the MCP server configuration:
Replace C:\\path\\to\\mcp-spotify with the actual path to this project.
5. First Run Authentication
Restart Claude Desktop
The server will automatically open a browser for Spotify authentication
Log in and authorize the app
You'll be redirected to a success page
Tokens are saved to
~/.mcp-spotify/tokens.json
Available Tools
Search
search_tracks- Search for trackssearch_albums- Search for albumssearch_artists- Search for artistssearch_playlists- Search for playlists
Playback
get_playback_state- Get current playback informationplayback_control- Control playback (play, pause, skip, previous, shuffle, volume, seek)
Library
get_saved_tracks- Get user's saved trackssave_tracks- Save tracks to libraryremove_saved_tracks- Remove tracks from libraryget_recently_played- Get recently played tracks (useful for recommendations)
Playlists
get_playlists- Get user's playlistscreate_playlist- Create a new playlistadd_tracks_to_playlist- Add tracks to a playlist
Recommendations
get_recommendations- Get track recommendations based on seeds and preferences (supportsuse_recent_listeningparameter)get_genre_seeds- Get list of available genre seeds
Available Prompts
discover_music
Discover new music based on your mood, genres, and listening preferences.
Arguments:
mood(optional): Desired mood (energetic, chill, happy, melancholic)genre(optional): Preferred genre
Example: "Discover energetic electronic music"
analyze_now_playing
Get detailed analysis of the currently playing track including audio features and recommendations.
Example: "Analyze what I'm listening to"
create_themed_playlist
Create a playlist based on a theme, mood, or activity.
Arguments:
theme: Theme or mood (e.g., "Workout", "Study", "Road Trip")size(optional): Number of tracks (default: 20)
Example: "Create a chill study playlist with 30 songs"
Example Interactions
Project Structure
Troubleshooting
"Spotify API error: 401"
Tokens may be expired. Delete
~/.mcp-spotify/tokens.jsonand restart ClaudeCheck that your Client ID and Client Secret are correct in
.env
"No playback device found"
Open Spotify on any device (desktop, mobile, web)
Start playing any track to activate a device
The API requires an active device for playback control
Recommendations returning 404
This is expected! Spotify deprecated the old recommendations API
The server now uses Search API with filters as a replacement
Technical Details
Language: TypeScript
Runtime: Node.js v23.9.0
MCP SDK: @modelcontextprotocol/sdk v1.20.0
Transport: stdio
Auth: OAuth 2.0 Authorization Code Flow with refresh tokens
Token Storage:
~/.mcp-spotify/tokens.json(auto-refreshed)
License
MIT
This server cannot be installed