Spotify MCP Server
A Media Control Protocol server for controlling Spotify playback
Jopgood
README
Spotify MCP Server
A Media Control Protocol (MCP) server that provides a unified interface for controlling Spotify playback across different devices and applications.
Features
- Control Spotify playback (play, pause, skip, previous)
- Adjust volume
- Search for and play specific tracks, albums, or playlists
- Get current playback information
- RESTful API for easy integration with other applications
- AI Assistant integration for controlling Spotify with natural language
- Voice control interface for speaking commands to Spotify
Prerequisites
- Node.js (v16 or later)
- npm (v8 or later)
- Spotify Premium account
- Spotify Developer account and registered application
Setup
-
Clone this repository:
git clone https://github.com/Jopgood/spotify-mcp-server.git cd spotify-mcp-server
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory with the following content:CLIENT_ID=your_spotify_client_id CLIENT_SECRET=your_spotify_client_secret REDIRECT_URI=http://localhost:8888/callback PORT=8888 SESSION_SECRET=your_random_session_secret AI_WEBHOOK_API_KEY=your_secure_api_key_for_ai_assistant BRIDGE_PORT=3001 VOICE_PORT=3002
-
Register a Spotify application at Spotify Developer Dashboard and note your Client ID and Client Secret.
Usage
-
Start the MCP server:
npm start
-
Open a browser and navigate to
http://localhost:8888
to authenticate with Spotify. -
Once authenticated, you can use the API endpoints to control Spotify.
API Endpoints
GET /api/status
- Get current playback statusPOST /api/play
- Start or resume playbackPOST /api/pause
- Pause playbackPOST /api/next
- Skip to next trackPOST /api/previous
- Go to previous trackPOST /api/volume
- Set volume (body:{ "volume": 50 }
)POST /api/seek
- Seek to position (body:{ "position_ms": 30000 }
)POST /api/playTrack
- Play a specific track (body:{ "uri": "spotify:track:xxxx" }
)
Client Examples
Using curl
# Play
curl -X POST http://localhost:8888/api/play
# Pause
curl -X POST http://localhost:8888/api/pause
# Next track
curl -X POST http://localhost:8888/api/next
Using JavaScript (fetch)
// Play a specific track
fetch('http://localhost:8888/api/playTrack', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
uri: 'spotify:track:6rqhFgbbKwnb9MLmUQDhG6'
})
})
.then(response => response.json())
.then(data => console.log(data));
Command Line Interface
A command-line interface is included for controlling Spotify from the terminal:
# Run the CLI
node client/spotify-cli.js
# Available commands
status # Show current playback status
play # Start/resume playback
pause # Pause playback
next # Skip to next track
prev # Go to previous track
volume 50 # Set volume to 50%
search bohemian # Search for tracks with "bohemian" in the title
play-track spotify:track:xxxx # Play a specific track by URI
AI Assistant Integration
This MCP server includes an AI webhook that allows AI assistants like Claude to control your Spotify through natural language commands.
Setting up the Integration
-
Configure the webhook API key in your
.env
file:AI_WEBHOOK_API_KEY=your_secure_random_key
-
Start the Claude-Spotify bridge service:
node bridge/claude-spotify-bridge.js
-
The bridge will run on port 3001 by default. You can customize this by adding
BRIDGE_PORT=xxxx
to your.env
file.
Running Claude Spotify Commands
Use the provided client script to execute Claude's Spotify commands:
node client/claude-spotify-client.js "play bohemian rhapsody"
Supported Natural Language Commands
The AI webhook supports commands like:
- "Play Bohemian Rhapsody by Queen"
- "Play playlist chill vibes"
- "Pause the music"
- "Resume playback"
- "Skip to the next track"
- "Go back to the previous song"
- "Set volume to 50%"
- "Turn volume up"
- "Turn volume down"
- "What's currently playing?"
Voice Control
For hands-free operation, you can use the voice control interface to speak commands to Spotify.
Setting up Voice Control
-
Start the voice control server:
node speech/voice-server.js
-
Open a browser and navigate to
http://localhost:3002
to access the voice control interface. -
Make sure the bridge service is running:
node bridge/claude-spotify-bridge.js
-
Click the microphone button and speak your command, starting with "Claude" (e.g., "Claude, play some jazz music").
Browser Compatibility
The voice control interface uses the Web Speech API, which is not supported in all browsers. For best results, use:
- Google Chrome (recommended)
- Microsoft Edge
- Safari
Firefox has limited support for the Web Speech API and may not work as expected.
Customizing the Voice Trigger
You can change the trigger phrase from "Claude" to anything you prefer by:
- Going to the Settings section in the voice control interface
- Entering your preferred trigger phrase
- Clicking "Save Settings"
Your preferences will be saved in your browser for future sessions.
Running Everything at Once
To run the complete system (MCP server, bridge, and voice interface), you can:
-
Start each component in separate terminal windows:
# Terminal 1: Start MCP server npm start # Terminal 2: Start Claude bridge node bridge/claude-spotify-bridge.js # Terminal 3: Start voice interface node speech/voice-server.js
-
Or create a simple start script to run everything at once:
// Create a file called start-all.js in the root directory with: const { spawn } = require('child_process'); const mcp = spawn('npm', ['start'], { stdio: 'inherit' }); setTimeout(() => { const bridge = spawn('node', ['bridge/claude-spotify-bridge.js'], { stdio: 'inherit' }); const voice = spawn('node', ['speech/voice-server.js'], { stdio: 'inherit' }); }, 2000); // Usage: node start-all.js
Troubleshooting
-
"Port already in use" error:
- Change the port numbers in your
.env
file:PORT
,BRIDGE_PORT
,VOICE_PORT
- Change the port numbers in your
-
Authentication issues:
- Make sure you've visited the web interface at
http://localhost:8888
and authenticated with Spotify - Check that your Client ID and Secret are correct in
.env
- Make sure you've visited the web interface at
-
Voice control not working:
- Ensure you're using a compatible browser (Chrome recommended)
- Check that your microphone is working and has the necessary permissions
- Verify the bridge URL in the voice interface settings matches your bridge server address
-
"No active device" error:
- Start playing something in Spotify on any device, then try again
- Spotify requires an active device to control playback
Development
To run in development mode with automatic reloading:
npm run dev
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
MCP Package Docs Server
Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.
Claude Code MCP
An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.
@kazuph/mcp-taskmanager
Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.
Linear MCP Server
Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.
mermaid-mcp-server
A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.
Jira-Context-MCP
MCP server to provide Jira Tickets information to AI coding agents like Cursor

Linear MCP Server
A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.

Sequential Thinking MCP Server
This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.