A Model Context Protocol server to access Spotify: search tracks/albums/artists, read playlists, and control playback (play/pause/next/previous). Runs over stdio for IDE agents.
First, you need to create a Spotify application to get your Client ID:
- Visit the Spotify Developer Dashboard: https://developer.spotify.com/dashboard
- Log in with your Spotify account
- Create a new app:
- Click "Create app"
- Fill in the app name and description
- Set the redirect URI to:
http://127.0.0.1:5173/callback(or use your custom port) - Accept the terms and create the app
- Copy your Client ID from the app settings
For detailed instructions, see the Spotify Web API Getting Started Guide.
Copy the .env.example file to create your local environment configuration:
cp .env.example .envThen edit .env with your Spotify credentials:
# .env
SPOTIFY_CLIENT_ID=your_spotify_client_id_here
SPOTIFY_REDIRECT_PORT=5173Important:
- Replace
your_spotify_client_id_herewith your actual Spotify Client ID - The
SPOTIFY_REDIRECT_PORTmust match the port in your Spotify app's redirect URI - Never commit
.envto version control (it's already in.gitignore)
npm install
npm run buildHere's a complete working example for Cursor IDE:
{
"spotify-mcp": {
"command": "/Users/yourusername/.nvm/versions/node/v22.11.0/bin/node",
"args": [
"--env-file",
"/Users/yourusername/spotify-mcp/.env",
"/Users/yourusername/spotify-mcp/dist/index.js"
]
}
}Important customization steps:
- Replace
/Users/yourusernamewith your actual home directory path - Update the node version path if you're using nvm (check with
which node) - Update the project path to where you cloned
spotify-mcp
To find your paths:
# Your node path (if using nvm)
which node
# Your project path
cd /path/to/spotify-mcp
pwdWhy this configuration?
- Uses
--env-fileflag to automatically load your.envfile - No need to manually set environment variables
- Works reliably with nvm-managed Node.js installations
- Development mode:
npm run dev - MCP stdio server:
npm run mcp
On first run, a browser will open for OAuth authentication. Tokens are stored securely via the OS keychain under service spotify-mcp.
-
Complete the setup steps above (Spotify Developer Setup, Environment Configuration, Install and Build)
-
Configure Cursor to use this MCP server:
- Open Cursor Settings (Cmd+, on macOS or Ctrl+, on Windows/Linux)
- Go to "Features" → "Model Context Protocol"
- Click "Add Server" or edit your MCP configuration file directly (
~/.cursor/mcp.json) - Use the configuration from the "Quick Configuration Example" section above
- Customize the paths to match your system (see instructions in that section)
Alternative: Simple npm configuration (may not work with nvm)
{ "spotify-mcp": { "command": "npm", "args": ["run", "mcp"], "cwd": "/absolute/path/to/your/spotify-mcp" } } -
Restart Cursor after adding the configuration
-
Verify the connection:
- Open a new chat in Cursor
- Type: "ping" - you should get a "pong" response from the Spotify MCP server
- Type: "get devices" - should list your available Spotify devices
-
First-time authentication:
- On first use, a browser window will open automatically for Spotify OAuth
- Log in and authorize the application
- Your tokens will be stored securely in your system's keychain
- After authorization, return to Cursor - the server will be ready to use
-
Start using Spotify tools in your Cursor chat:
- "Search for songs by The Beatles"
- "Show my playlists"
- "Play the next song"
- "What's currently playing?"
- "List my available devices"
-
Complete the setup steps above (Spotify Developer Setup, Environment Configuration, Install and Build)
-
Add to Claude Desktop configuration:
- Locate your Claude Desktop configuration file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
- macOS:
- Edit the configuration file and add the MCP server:
{ "mcpServers": { "spotify-mcp": { "command": "/Users/yourusername/.nvm/versions/node/nodeversion/bin/node", "args": [ "--env-file", "/Users/yourusername/spotify-mcp/.env", "/Users/yourusername/spotify-mcp/dist/index.js" ] } } }Important:
- Customize the paths as described in the "Quick Configuration Example" section
- Use absolute paths, not relative paths
- Ensure the
distfolder exists by runningnpm run buildfirst - Save the configuration file after editing
Alternative: Simple npm configuration (may not work with nvm)
{ "mcpServers": { "spotify-mcp": { "command": "npm", "args": ["run", "mcp"], "cwd": "/absolute/path/to/your/spotify-mcp" } } } - Locate your Claude Desktop configuration file:
-
Restart Claude Desktop completely
-
First-time authentication:
- On first use, a browser window will open automatically for Spotify OAuth
- Log in and authorize the application
- Your tokens will be stored securely in your system's keychain
-
Use Spotify commands in your conversations:
- Ask Claude to search for music, control playback, or browse your playlists
- Examples: "Search for songs by Coldplay", "What's playing on my Spotify?", "Skip to next track"
Once configured, you can use natural language commands like:
- "Search for jazz albums"
- "Play my liked songs playlist"
- "Skip to the next track"
- "What devices are available for playback?"
- "Show me songs from my 'Chill' playlist"
The MCP server provides the following Spotify integration tools:
search(type, q, limit?)- Search for tracks, albums, or artistsget_playlists(limit?, offset?)- Get user's playlistsget_playlist_items(playlistId, limit?, offset?)- Get items from a specific playlistplayback_control(action, deviceId?)- Control playback (play, pause, next, previous)current_playback()- Get current playback statedevices()- List available playback devices
-
"Client ID not found" error:
- Ensure your
.envfile exists and containsSPOTIFY_CLIENT_ID - Verify the Client ID is correct (copy from Spotify Developer Dashboard)
- Ensure your
-
"Redirect URI mismatch" error:
- Check that
SPOTIFY_REDIRECT_PORTin.envmatches your Spotify app's redirect URI - The redirect URI should be
http://127.0.0.1:5173/callback(replace 5173 with your port)
- Check that
-
Authentication issues:
- Clear stored tokens: The tokens are stored in your OS keychain under
spotify-mcp - On macOS: Use Keychain Access app to delete
spotify-mcpentries - Try running the server again to re-authenticate
- Clear stored tokens: The tokens are stored in your OS keychain under
-
MCP server not connecting:
- Ensure the server builds successfully:
npm run build - Check that the
cwdpath in your MCP configuration is correct - Verify Node.js and npm are installed and up to date
- Ensure the server builds successfully:
- Check the Spotify Web API documentation
- Review the Model Context Protocol specification
- Open an issue on the project repository for bugs or feature requests