Spotify
About
Connects your Spotify account to AI tools, allowing access to your music library, playlists, and playback controls.
Details
- Author
- tdp2003
- Categories
- Other, Media
Jump to
Setup
Install Spotify in your MCP client (Claude Desktop, Cursor, Windsurf, and others).
Repository: https://github.com/tdp2003/spotify-mcp
Follow the installation instructions in the repository README, then restart your MCP client.
Connect your Spotify account to AI tools and automate your music experience with the Model Context Protocol (MCP).
TheSpotify MCP Serverimplements theModel Context Protocolto bridge your Spotify account with AI-powered tools like Cursor, Claude, VS Code, and more. It enables AI models to search, analyze, and manage your Spotify music library, playlists, and playback through natural language instructions.
- π΅ Music Search & Discovery: Find tracks, albums, artists, playlists, shows, and episodes
- π Playlist Management: View, create, update, reorder, and manage playlists
- π User Library Access: Access and modify your saved tracks, albums, and shows
- π― Personalized Recommendations: Get music suggestions based on your taste
- π Audio Analysis: Retrieve audio features (danceability, energy, tempo, etc.) for tracks
- π§ Playback Control: (Premium only) Play, pause, skip, and control playback devices
- π User Insights: View your top tracks, artists, and listening history
- π Queue Management: Add tracks to your queue and view upcoming songs
- π± Device Management: Transfer playback between devices
- A Spotify account (Premium required for playback control)
- Spotify API credentials (see below)
- Node.js 18 or newer
- Go to theSpotify Developer Dashboard
- Create a new application
- Note yourClient IDandClient Secret
- Set theRedirect URIto:http://127.0.0.1:8000/callback
Create a.envfile in your project root:
SPOTIFY_CLIENT_ID=your-client-id SPOTIFY_CLIENT_SECRET=your-client-secret SPOTIFY_REDIRECT_URI=http://127.0.0.1:8000/callback
Note: You no longer need to manually obtain access tokens! The server will handle the OAuth flow automatically.
# Install dependencies npm install # Build the server npm run build # Start the server npm start
Add this configuration to your MCP-compatible application (example for Cursor):
{ "mcpServers": { "spotify": { "command": "npx", "args": ["-y", "@tdp2003/spotify-mcp@latest"], "env": { "SPOTIFY_CLIENT_ID": "your-client-id", "SPOTIFY_CLIENT_SECRET": "your-client-secret", "SPOTIFY_REDIRECT_URI": "http://127.0.0.1:8000/callback" } } } }
- Call theget_initial_contexttool in your AI application
- If not already authorized, you'll receive an authorization URL
- Open the URL in your browser and log in to Spotify
- Authorize the application - you'll be redirected automatically
- Callget_initial_contextagain to confirm the connection
β οΈ Important: Always callget_initial_contextfirst to initialize your Spotify connection before using any other tools.
Required first step- Initializes your Spotify connection and provides usage instructions. This tool must be called before any other operations.
- Validates your Spotify API credentials
- Initiates OAuth flow if needed
- Retrieves your user profile and account information
- Provides connection status and available features
- Returns usage instructions for the AI assistant
Retrieve playlists for the current user or a specific user.
- limit(optional): Number of playlists to return (1-50, default: 20)
- offset(optional): Index of the first playlist to return (default: 0)
- userId(optional): User ID to get playlists for (defaults to current user)
Returns:Playlist metadata including name, description, track count, privacy settings, and owner information.
Create a new playlist with customizable settings.
- name(required): Playlist name
- description(optional): Playlist description
- public(optional): Whether playlist is public (default: false)
- collaborative(optional): Whether playlist is collaborative (default: false)
- userId(optional): User ID to create playlist for (defaults to current user)
Returns:Created playlist details including Spotify URI and ID.
Update playlist metadata including name, description, privacy settings, and collaborative status.
- playlistId(required): Spotify playlist ID
- name(optional): New playlist name
- description(optional): New playlist description
- public(optional): New public/private setting
- collaborative(optional): New collaborative setting
Returns:Updated playlist details with change summary.
Add tracks to a playlist with precise position control.
- playlistId(required): Spotify playlist ID
- uris(required): Array of Spotify track URIs (max 100)
- position(optional): Position to insert tracks (defaults to end)
Returns:Confirmation with snapshot ID and updated track count.
Remove tracks from a playlist with precision control.
- playlistId(required): Spotify playlist ID
- tracks(required): Array of track objects with URIs and optional positions
- snapshot_id(optional): Playlist snapshot ID for concurrency safety
Returns:Confirmation with snapshot ID and removal details.
Reorder tracks within a playlist by moving a range of tracks to a new position.
- playlistId(required): Spotify playlist ID
- range_start(required): Starting position of tracks to move
- range_length(required): Number of tracks to move
- insert_before(required): Position to move tracks to
- snapshot_id(optional): Playlist snapshot ID for concurrency safety
Returns:Confirmation with snapshot ID and reorder details.
Search Spotify's catalog for albums, artists, tracks, playlists, shows, and episodes.
- query(required): Search query string
- type(optional): Content type filter (track, album, artist, playlist, show, episode)
- limit(optional): Number of results (1-50, default: 20)
- offset(optional): Result offset (default: 0)
- market(optional): Country code for market-specific results
Returns:Detailed metadata for each result type with pagination information.
Get new album releases available on Spotify.
- limit(optional): Number of releases (1-50, default: 20)
- offset(optional): Result offset (default: 0)
- country(optional): Country code for regional releases
Returns:Recently released albums with artist information, release dates, and metadata.
Get featured playlists from Spotify's editorial team.
- limit(optional): Number of playlists (1-50, default: 20)
- offset(optional): Result offset (default: 0)
- country(optional): Country code for regional content
- locale(optional): Language/locale for descriptions
Returns:Curated playlists prominently featured on Spotify with descriptions and metadata.
Get the current user's top artists or tracks based on calculated affinity.
- type(required): Item type ('artists' or 'tracks')
- time_range(optional): Time range ('short_term' ~4 weeks, 'medium_term' ~6 months, 'long_term' ~1 year)
- limit(optional): Number of items (1-50, default: 20)
- offset(optional): Result offset (default: 0)
Returns:User's top items with popularity scores and metadata.
Note: These tools require a Spotify Premium account
Get current playing track and device information.
Returns:Current playback state including track, device, and queue information.
Control playback (play, pause, skip, volume).
- action(required): Playback action (play, pause, next, previous, volume)
- device_id(optional): Target device ID
- volume_percent(optional): Volume level (0-100, for volume action)
Returns:Confirmation of playback action.
Add tracks to queue and view upcoming tracks.
- action(required): Queue action ('add' or 'get')
- uris(optional): Track URIs to add (for 'add' action)
- device_id(optional): Target device ID
Returns:Queue information or confirmation of track addition.
- device_id(required): Target device ID
- play(optional): Whether to start playback on transfer (default: false)
Returns:Confirmation of device transfer.
- track_ids(required): Array of Spotify track IDs
- Danceability: How suitable for dancing (0.0-1.0)
- Energy: Intensity and power (0.0-1.0)
- Speechiness: Presence of spoken words (0.0-1.0)
- Acousticness: Whether track is acoustic (0.0-1.0)
- Instrumentalness: Whether track has no vocals (0.0-1.0)
- Liveness: Presence of audience (0.0-1.0)
- Valence: Musical positivity/happiness (0.0-1.0)
- Tempo: Speed in beats per minute (BPM)
*These tokens are automatically obtained through the OAuth flow when you first use the server.
- developer: Full access to all tools and features
- editor: Restricted to content-focused tools (no admin features)
Set the role in your MCP client configuration if supported.
If you use a Node version manager (nvm,mise,fnm, etc.), you may need to create symlinks so MCP servers can access Node.js:
sudo ln -sf "$(which node)" /usr/local/bin/node && sudo ln -sf "$(which npx)" /usr/local/bin/npx
Update these symlinks if you change Node versions. Remove them with:
sudo rm /usr/local/bin/node /usr/local/bin/npx
You can use the MCP inspector for debugging:
npx @modelcontextprotocol/inspector -e SPOTIFY_CLIENT_ID=... -e SPOTIFY_CLIENT_SECRET=... -e SPOTIFY_REDIRECT_URI=... -e SPOTIFY_API_TOKEN=... -e SPOTIFY_REFRESH_TOKEN=... node path/to/build/index.js
This provides a web interface for inspecting and testing the available tools.
The OAuth flow has been improved with the following security and usability enhancements:
- State validation: Uses cryptographically secure random state parameters to prevent CSRF attacks
- Redirect URI validation: Ensures redirect URI uses localhost/127.0.0.1 for automatic token exchange
- Proper error handling: Comprehensive error handling for all OAuth failure scenarios
- Automatic browser opening: Automatically opens the authorization URL in your default browser
- Better user feedback: Clear error messages and status updates throughout the process
- Graceful server shutdown: Properly closes the OAuth callback server after completion
Theoauth-helper.jsscript provides a standalone way to obtain Spotify tokens:
- Validate your environment configuration
- Start a local callback server
- Automatically open your browser to the Spotify authorization page
- Handle the callback and exchange the code for tokens
- Display the tokens for you to add to your.envfile
Make sure your redirect URI is configured correctly:
SPOTIFY_REDIRECT_URI=http://127.0.0.1:8000/callback
The redirect URImustuselocalhostor127.0.0.1for the automatic token exchange to work properly.
Allows users to generate music videos using Freebeat through MCP
The first artist-owned MCP server for AI Agent use. Discover, narrate, and stream Matthew Hartley's debut album The Time Is Now: A Journey in Chapters from any AI client. Powered by Harmonic Wave.
Producer AI is an online AI music generator that accepts a song description or lyric draft and advertises full tracks with vocals, fast generation, and royalty-free output language.
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.




