josuemj/spotify-mcp
If you are the rightful owner of spotify-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A Model Context Protocol (MCP) server that enables AI assistants to control Spotify playback through natural language commands.
Spotify MCP Server
A Model Context Protocol (MCP) server that enables AI assistants to control Spotify playback through natural language commands.
Features
This MCP server provides AI assistants with the following Spotify control capabilities:
đ Music Discovery
- Search and Play: Find and immediately play any song by searching for artist, song name, album, or any combination
- Example: "Play some David Guetta"
- Example: "Play Bohemian Rhapsody by Queen"
đĩ Playback Controls
- Play/Resume: Resume paused music on your active device
- Pause: Pause the currently playing track
- Next Track: Skip to the next song in your queue
- Previous Track: Go back to the previous song
âšī¸ Track Information
- Current Track: Get detailed information about what's currently playing, including:
- Song title and artist
- Album name
- Playback status (playing/paused)
- Track duration
Requirements
- Spotify Premium account (required for playback control via API)
- Python 3.x
- Active Spotify device (mobile app, desktop app, or web player)
Setup
1. Create Spotify App
-
Create a new app
- App name --> my-spotify-mcp
- Description --> my first mcp with spotify (whatever, irrelevant)
- Website --> Leave empty
- Redirect URIs (This is crucial) --> https://github.com/josuemj/spotify-mcp
- Which API/SDKs are you planning to use? --> Select Web API
- Click Save
-
Note your
Client ID
andClient Secret
-
Add
https://github.com/josuemj/spotify-mcp
as a redirect URI
2. Clone the mcp locally
git clone https://github.com/josuemj/spotify-mcp
cd spotify-mcp
python -m venv .venv
# Windows
.venv\Scripts\activate
# Linux/Mac
source .venv/bin/activate
pip install -r requirements.txt
3. Environment Configuration
Create a .env
file in the project root:
SPOTIFY_CLIENT_ID=your_client_id_here
SPOTIFY_CLIENT_SECRET=your_client_secret_here
4. Authentication
Run the authentication script:
python src/spotify_auth.py
This will:
-
Open your browser for Spotify OAuth.
-
Redirect you to GitHub with an authorization code. Copy the link generated by GitHub
-
Prompt you to paste the full redirect URL on your terminal.
-
Automatically save your access token to
.env
Note: Access tokens expire after 1 hour. Re-run authentication when needed.
5. Start the MCP Server
python src/spotify_mcp.py
6. Usage with AI Assistant
Claude Desktop Integration
Once you have everything set up, configure Claude Desktop to use your Spotify MCP server:
- Locate Claude Desktop config file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
- Add the MCP server configuration:
"mcpServers": {
"spotify-mcp": {
"command": "C:/Users/Someone/Mcps/spotify-mcp/.venv/Scripts/python.exe",
"args": [
"C:/Users/Someone/Mcps/spotify-mcp/src/spotify_mcp.py"
]
},
// other mcps
},
- Update paths for your system:
- Windows example:
"C:/Users/YourName/Projects/spotify-mcp/.venv/Scripts/python.exe"
- macOS/Linux example:
"/Users/YourName/Projects/spotify-mcp/.venv/bin/python"
- Restart Claude Desktop to load the new MCP server
Once configured, you can control Spotify through natural language in Claude:
- "Play some music by The Beatles"
- "Skip to the next song"
- "What song is currently playing?"
- "Pause the music"
- "Play Bohemian Rhapsody"
Important Notes:
- Environment variables (.env file) are automatically loaded by the MCP server
- No additional environment configuration needed in Claude Desktop config
- Ensure Spotify is open and active on at least one device before using commands
- The MCP server will automatically handle device detection and API authentication
Troubleshooting
- "No active device": Make sure you have Spotify open on at least one device
- "Token expired": Re-run
python src/spotify_auth.py
to refresh your token - "Premium required": This server requires a Spotify Premium subscription for playback control