π§ Spotify MCP Server
April 5, 2025 Β· View on GitHub
This is an MCP (Model Context Protocol) server that connects to the Spotify Web API and exposes a set of playback and search tools to AI clients like Claude Desktop.
Built using:
spotipyβ lightweight Python wrapper for the Spotify Web APImcpβ for exposing tool functions over the Model Context ProtocolFastMCPβ for rapid server implementation.envanddotenvβ for securely managing credentials
π Features
This server exposes the following Spotify tools:
playβ Start or resume playbackpauseβ Pause playbacknext_trackβ Skip to the next songprevious_trackβ Go back to the previous songsearch_track(query: str)β Search for a track by nameget_current_track()β Get info on the currently playing songadd_to_queue(uri: str)β Add a track to the queue using its Spotify URI
π§ Setup
1. Clone the Repo
git clone https://github.com/your-username/spotify_mcp.git
cd spotify_mcp
2. Create a virtual environment
Using uv (recommended):
uv venv
source .venv/bin/activate
uv pip install spotipy mcp[cli] python-dotenv
Or using standard venv and pip:
python3 -m venv venv
source venv/bin/activate
pip install spotipy mcp[cli] python-dotenv
3. Set up environment variables
Create a .env file in the root of your project:
SPOTIPY_CLIENT_ID=your_spotify_client_id
SPOTIPY_CLIENT_SECRET=your_spotify_client_secret
SPOTIPY_REDIRECT_URI=http://localhost:8888/callback
π§ͺ Running the server
python main.py
π€ Using with Claude Desktop
- Open your claude_desktop_config.json
- Add an MCP server entry like this:
{
"mcpServers": {
"spotify_mcp": {
"command": "/absolute/path/to/venv/bin/python",
"args": ["/absolute/path/to/main.py"]
}
}
}
- Restart Claude Desktop.
- You should now see βSpotifyβ as a tool in your Claude interface.