tianyoul/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 Claude Desktop to interact with Spotify, allowing users to manage their Spotify library using natural language.
Spotify MCP Server
A Model Context Protocol (MCP) server that enables Claude Desktop to interact with Spotify. Create playlists, search for tracks, and manage your Spotify library using natural language.
Features
- Search Tracks: Find songs by artist, album, genre, or natural language queries
- Create Playlists: Generate new playlists with custom names and descriptions
- Add Tracks: Add multiple tracks to playlists at once
- View Playlists: List your existing Spotify playlists
- Get Recommendations: Discover new music based on seeds (tracks, artists, or genres)
Prerequisites
- Node.js (v18 or higher)
- A Spotify account
- Claude Desktop app
- Spotify Developer App credentials
Setup Instructions
1. Clone the Repository
git clone https://github.com/tianyoul/spotify-mcp.git
cd spotify-mcp
2. Install Dependencies
npm install
3. Create Spotify App
- Go to Spotify Developer Dashboard
- Click "Create app"
- Fill in the details:
- App name: Spotify MCP Server (or any name)
- App description: MCP server for Claude Desktop
- Redirect URI:
http://127.0.0.1:8888/callback
- Save your app
- Copy your Client ID and Client Secret
4. Configure Environment Variables
Create a .env
file in the project root:
SPOTIFY_CLIENT_ID=your_client_id_here
SPOTIFY_CLIENT_SECRET=your_client_secret_here
SPOTIFY_REDIRECT_URI=http://127.0.0.1:8888/callback
Replace your_client_id_here
and your_client_secret_here
with your actual Spotify credentials.
5. Build the Project
npm run build
6. Authenticate with Spotify
npm run auth
This will:
- Open a browser window for Spotify authentication
- Request necessary permissions
- Save your access token locally
7. Configure Claude Desktop
Add the following to 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
{
"mcpServers": {
"spotify": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/spotify-mcp/dist/index.js"],
"env": {
"SPOTIFY_CLIENT_ID": "your_client_id_here",
"SPOTIFY_CLIENT_SECRET": "your_client_secret_here",
"SPOTIFY_REDIRECT_URI": "http://127.0.0.1:8888/callback"
}
}
}
}
Important: Replace /ABSOLUTE/PATH/TO/spotify-mcp
with the actual absolute path to your project directory.
8. Restart Claude Desktop
Close and reopen Claude Desktop. The Spotify MCP server should now be connected.
Usage Examples
Once configured, you can interact with Spotify through Claude using natural language:
Search for music:
"Find me some chill jazz music"
Create a playlist:
"Create a playlist called 'Road Trip' with upbeat rock songs"
Add tracks to a playlist:
"Search for Taylor Swift songs and add the top 5 to my Road Trip playlist"
View your playlists:
"Show me my Spotify playlists"
Get recommendations:
"Recommend songs similar to Bohemian Rhapsody"
Available Tools
The MCP server exposes the following tools to Claude:
search_tracks
- Search for tracks on Spotifycreate_playlist
- Create a new playlist in your accountadd_tracks_to_playlist
- Add tracks to an existing playlistget_user_playlists
- List your playlistsget_recommendations
- Get track recommendations based on seeds
Troubleshooting
Server disconnected error
If you see "Server disconnected" in Claude Desktop:
- Check the logs:
~/Library/Logs/Claude/mcp-server-spotify.log
(macOS) - Ensure the build completed successfully:
npm run build
- Verify authentication:
npm run auth
- Check that the path in
claude_desktop_config.json
is absolute and correct
Token expired
If you get a "Token expired" error:
npm run auth
This will refresh your Spotify authentication.
Cannot find module errors
Make sure all dependencies are installed:
npm install
npm run build
Development
Project Structure
spotify-mcp/
āāā src/
ā āāā index.ts # Main MCP server implementation
ā āāā auth.ts # Spotify OAuth flow
āāā dist/ # Compiled JavaScript (generated)
āāā .env # Environment variables (create this)
āāā package.json
āāā tsconfig.json
Scripts
npm run build
- Compile TypeScript to JavaScriptnpm run dev
- Run in development modenpm run auth
- Authenticate with Spotifynpm start
- Start the server (for testing)
Security Notes
- Never commit your
.env
file or.spotify-token.json
to version control - Keep your Spotify Client Secret private
- The authentication token is stored locally in
.spotify-token.json
- Tokens are automatically refreshed when needed
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.