Spotify Playlist MCP Server
Provides comprehensive Spotify integration for playlist management, track search, recommendations, and advanced similarity analysis. Features include creating playlists with natural language, finding similar tracks using multiple algorithms (audio features, genre matching), and managing user's Spotify library with sophisticated filtering and recommendation capabilities.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Spotify Playlist MCP Server create a workout playlist with high-energy tracks similar to 'Eye of the Tiger'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Spotify Playlist MCP Server
A Model Context Protocol server for creating playlists on the fly with natural language, including using one of several similarity methods for similar tracks.
This was built to scratch two personal itches:
To build playlists using natural language and with one of several similarity metrics. The ideal would be ephemeral playlists, but alas.
To play with the new Claude skills and see how much it aids in AI-assisted coding. Verdict: It may chew up tokens but works very well.
** WARNING **: This still needs to put through its paces in real-world testing and have some evaluations written for it.
Features
Core Playlist Management
Create and manage Spotify playlists
Search tracks across Spotify's catalog
Get track details and recommendations
Browse user playlists and playlist contents
Advanced Similarity Engine
Audio Feature Analysis: Extract and analyze acousticness, danceability, energy, tempo, valence, and more
Multiple Similarity Algorithms: Choose from 8 different strategies (Euclidean, Cosine, Weighted, Manhattan, Energy Match, Mood Match, Rhythm Match, Genre Match)
Genre-Based Matching: Find tracks with similar artist genres within playlists or collections
Customizable Feature Weights: Fine-tune similarity calculations by weighting specific audio features
Flexible Search Scopes: Search entire catalog, within playlists, artist discographies, albums, or saved tracks
Automated Actions: Find similar tracks and automatically create playlists or add to existing ones
Related MCP server: mcp-spotify
Available Tools
Basic Tools
spotify_search_tracks- Search for tracks by name, artist, or queryspotify_get_track- Get detailed information about a specific trackspotify_get_recommendations- Get track recommendations with tunable parametersspotify_create_playlist- Create a new Spotify playlistspotify_add_tracks_to_playlist- Add tracks to an existing playlistspotify_get_user_playlists- List user's playlists with paginationspotify_get_playlist_tracks- Get tracks from a specific playlist
Advanced Similarity Tools
spotify_get_audio_features- Get detailed audio features for tracksspotify_find_similar_tracks- Advanced similarity engine (see below)
Similarity Engine
How It Works
The similarity engine finds similar tracks using two approaches:
Audio Feature Analysis: Analyzes sonic characteristics like energy, tempo, and danceability
Genre Matching: Compares artist genres for style-based similarity
For audio feature analysis, the engine uses Spotify's audio analysis API to extract features like:
Acousticness (0-1): Confidence that track uses acoustic instruments
Danceability (0-1): How suitable for dancing
Energy (0-1): Intensity and activity level
Instrumentalness (0-1): Likelihood of no vocals
Valence (0-1): Musical positiveness (happiness/cheerfulness)
Tempo (BPM): Speed of the track
Loudness (dB): Overall volume
Speechiness (0-1): Presence of spoken words
Liveness (0-1): Audience presence (live performance)
Similarity Strategies
Choose from 8 different algorithms:
euclidean(Default) - Overall similarity across all features using Euclidean distanceweighted- Custom weighted similarity - specify importance of each featurecosine- Angular similarity (good for high-dimensional matching)manhattan- City-block distance metricenergy_match- Focus on energy and danceability for workout/party playlistsmood_match- Focus on valence and acousticness for mood-based matchingrhythm_match- Focus on tempo for rhythm-based similaritygenre_match- Match tracks based on artist genres (exact and partial matches)
Search Scopes
Control where to search for similar tracks:
catalog- Search entire Spotify catalog (uses recommendations API)playlist- Find similar tracks within a specific playlistartist- Search within an artist's discographyalbum- Find similar tracks within a specific albumsaved_tracks- Search within user's saved library
Actions
Choose what to do with similar tracks:
return_tracks- Just return the list with similarity scorescreate_playlist- Automatically create a new playlist with similar tracksadd_to_playlist- Add similar tracks to an existing playlist
Installation
Prerequisites
Python 3.12+ (managed with mise)
uv for dependency management
Spotify Developer Account and API credentials
Setup
Clone the repository:
git clone <repository-url>
cd spotify-playlist-mcpInstall dependencies:
uv syncConfigure environment variables:
cp .env.example .env
# Edit .env and add your SPOTIFY_ACCESS_TOKENGet your Spotify access token (see
.env.examplefor detailed instructions):Create an app
Get your Client ID and Client Secret
Generate an access token with required scopes:
playlist-modify-publicplaylist-modify-privateplaylist-read-privateuser-read-private
Usage
Running the Server
Development Mode (with MCP Inspector)
uv run mcp dev server.pyDirect Execution
uv run python server.pyInstall for Claude Desktop
uv run mcp install server.pyExample Use Cases
Find Similar Tracks in a Playlist
"Find songs similar to track [ID] within my workout playlist"Create a Playlist Based on a Track
"Find tracks similar to [track name] using the energy_match strategy
and create a playlist called 'High Energy Workout'"Custom Weighted Similarity
"Find tracks similar to this song, but prioritize energy and danceability
more than other features (weights: energy=5.0, danceability=5.0)"Mood-Based Playlist from Artist
"Create a calm acoustic playlist based on [artist name]'s style
using the mood_match strategy"Search Saved Tracks
"Find all tracks in my saved library that sound similar to this song"Genre-Based Playlist Filtering
"Create a playlist with tracks from my Discover Weekly that have
the same genre as this track I'm listening to"Similarity Engine Examples
Example 1: Find Similar Tracks in a Playlist
{
"track_id": "3n3Ppam7vgaVa1iaRUc9Lp",
"strategy": "euclidean",
"scope": "playlist",
"scope_id": "37i9dQZF1DXcBWIGoYBM5M",
"limit": 10,
"action": "return_tracks"
}Example 2: Create High-Energy Workout Playlist
{
"track_id": "4iV5W9uYEdYUVa79Axb7Rh",
"strategy": "energy_match",
"scope": "catalog",
"limit": 30,
"action": "create_playlist",
"playlist_name": "High Energy Workout"
}Example 3: Custom Weighted Similarity
{
"track_id": "7qiZfU4dY1lWllzX7mPBI",
"strategy": "weighted",
"weights": {
"energy": 5.0,
"danceability": 5.0,
"valence": 3.0,
"acousticness": 0.5,
"tempo": 2.0
},
"scope": "catalog",
"limit": 20,
"action": "create_playlist",
"playlist_name": "Custom Mix"
}Example 4: Find Similar Tracks by Artist Style
{
"artist_id": "0OdUWJ0sBjDrqHygGUXeCF",
"strategy": "cosine",
"scope": "saved_tracks",
"limit": 15,
"action": "add_to_playlist",
"target_playlist_id": "5FqPqTauQoRPRxJBQC8C2N"
}Example 5: Genre-Based Playlist Filtering
Find tracks from a playlist that match the genre of a specific track:
{
"track_id": "3n3Ppam7vgaVa1iaRUc9Lp",
"strategy": "genre_match",
"scope": "playlist",
"scope_id": "37i9dQZF1DXcBWIGoYBM5M",
"limit": 20,
"action": "create_playlist",
"playlist_name": "Same Genre from Discover Weekly"
}Note: genre_match strategy requires a specific scope (playlist, artist, album, or saved_tracks) and does not work with the catalog scope.
Architecture
Modular Design
The similarity engine is built with modularity in mind:
Feature Normalization - Normalizes audio features to 0-1 range
Similarity Calculators - Pluggable distance/similarity functions
Scope Handlers - Extract candidate tracks from different sources
Action Executors - Handle different output actions
Adding Custom Strategies
To add a new similarity strategy:
Add the strategy to the
SimilarityStrategyenumImplement the calculation logic in
_calculate_similarity()Document the strategy in tool descriptions
API Reference
spotify_find_similar_tracks
Parameters:
track_id(Optional[str]): Source track IDartist_id(Optional[str]): Source artist IDplaylist_id(Optional[str]): Source playlist IDstrategy(SimilarityStrategy): Algorithm to useweights(Optional[FeatureWeights]): Custom feature weightsscope(SearchScope): Where to searchscope_id(Optional[str]): ID for scope (playlist/artist/album)limit(int): Number of results (1-100)min_similarity(Optional[float]): Minimum similarity thresholdaction(SimilarityAction): What to do with resultsplaylist_name(Optional[str]): Name for new playlisttarget_playlist_id(Optional[str]): Target for adding tracksresponse_format(ResponseFormat): 'markdown' or 'json'
Returns:
List of similar tracks with similarity scores
OR playlist creation confirmation
OR add to playlist confirmation
Troubleshooting
Audio Features Deprecated Error
If you encounter errors about audio features being deprecated:
Ensure you have extended mode access on your Spotify app
Note: Audio features endpoint was deprecated for NEW applications in November 2024
Existing applications with extended mode access can still use it
Authentication Errors
Access tokens expire after 1 hour - refresh regularly
Ensure all required scopes are granted
Check that your token is correctly set in
.env
Rate Limiting
Spotify API has rate limits - the server handles 429 errors gracefully
If searching large playlists, be patient as it may take time
Best Practices
Token Management: Implement token refresh logic for production use
Scope Selection: Use specific scopes (playlist/artist/album) for better performance
Strategy Choice:
Use
euclideanfor general similarityUse
energy_matchfor workout/party playlistsUse
mood_matchfor relaxation/study playlistsUse
rhythm_matchfor tempo-based matching (running, dancing)Use
genre_matchto filter playlists by genre similarityUse
weightedwhen you know which features matter most
Genre Match Considerations:
Requires specific scope (playlist, artist, album, or saved_tracks)
Does not work with catalog scope
Best for filtering existing collections by genre
Uses artist genres (tracks without artist genre data will be skipped)
Batch Operations: When analyzing multiple tracks, use batch endpoints
Error Handling: Always check response for errors before proceeding
Contributing
Contributions are welcome! Areas for improvement:
Additional similarity strategies
More sophisticated feature weighting algorithms
Tempo range matching with BPM bands
Key and mode compatibility checking
Audio analysis integration (bars, beats, segments)
Advanced genre hierarchies and taxonomy
Multi-artist collaboration detection
Acknowledgments
Built with FastMCP as it appears in the MCP Python SDK
Uses Spotify Web API
Follows Model Context Protocol specification
Uses the mcp-builder Claude skill to improve code generation.
Support
For issues, questions, or feature requests, please open an issue on GitHub.
Available Tools
9 toolsspotify_add_tracks_to_playlistA
Add tracks to an existing Spotify playlist.
Adds 1-100 tracks to a playlist. Tracks can be inserted at a specific position or
appended to the end. Playlist must be owned by user or be collaborative.
Args:
- playlist_id: Spotify playlist ID (not URI)
- track_uris: List of track URIs, 1-100 (format: "spotify:track:ID", not just IDs)
- position: Optional 0-indexed position to insert (default: append to end)
Returns:
JSON: {"success": true, "snapshot_id": "...", "tracks_added": N, "message": "..."}
Examples:
- "Add this track to my playlist" -> track_uris=["spotify:track:ID"], playlist_id="..."
- "Add 10 songs to workout mix" -> track_uris=[list of URIs]
- "Insert at the beginning" -> position=0
Errors: Returns error for invalid playlist (404), no permission (403), auth failure (401), rate limits (429).
Inputs: params (required). Returns: result
spotify_create_playlistA
Create a new empty Spotify playlist for the authenticated user.
Creates an empty playlist in the user's library. Use spotify_add_tracks_to_playlist
to add tracks after creation.
Args:
- name: Playlist name, 1-100 characters
- description: Optional description, max 300 characters
- public: Whether playlist is public (default: True)
- collaborative: Whether others can modify (default: False, cannot be True if public is True)
Returns:
JSON: {"success": true, "playlist_id": "...", "name": "...", "url": "...", "message": "..."}
Examples:
- "Create a new workout playlist" -> name="Workout Mix"
- "Make a private playlist" -> name="My Mix", public=False
- "Create collaborative playlist" -> collaborative=True, public=False
Errors: Returns error for collaborative+public, auth failure (401), missing scopes (403), rate limits (429).
Inputs: params (required). Returns: result
spotify_find_similar_tracksA
Find tracks similar to a track, artist, or playlist using audio analysis or genre matching.
Centerpiece of the similarity engine. Supports 8 strategies, custom weighting, and automated
playlist creation. For curated playlists, music discovery, and mood-based mixes.
Args:
Source (one required): track_id, artist_id, or playlist_id
Strategy (default: euclidean): euclidean, weighted (needs weights), cosine, manhattan,
energy_match (workout), mood_match (relaxation), rhythm_match (running), genre_match (non-catalog scope only)
Scope (default: catalog): catalog (recommendations API), playlist (needs scope_id),
artist (needs scope_id), album (needs scope_id), saved_tracks
Action (default: return_tracks): return_tracks, create_playlist (needs playlist_name),
add_to_playlist (needs target_playlist_id)
- limit: Results to return, 1-100 (default: 20)
- min_similarity: Optional threshold, 0.0-1.0
- weights: Optional custom weights for 'weighted' strategy (e.g., {"energy": 5.0, "danceability": 5.0})
- response_format: 'markdown' or 'json'
Returns:
return_tracks: List with similarity scores (Markdown or JSON: {"strategy": "...", "scope": "...", "count": N, "tracks": [{track, similarity}]})
create_playlist: {"success": true, "action": "create_playlist", "playlist_id": "...", "playlist_name": "...", "playlist_url": "...", "tracks_added": N, "message": "..."}
add_to_playlist: {"success": true, "action": "add_to_playlist", "playlist_id": "...", "tracks_added": N, "message": "..."}
Examples:
- "Find songs similar to this track" -> track_id, catalog scope
- "Create workout playlist like this" -> track_id, energy_match, create_playlist
- "Filter playlist by genre" -> track_id, genre_match, playlist scope
- "Custom similarity for energy/dance" -> weighted strategy, custom weights
Errors: Returns errors for missing source, missing scope_id, missing action params, genre_match with catalog, no genres, no matches, auth (401), permissions (403), rate limits (429).
Inputs: params (required). Returns: result
spotify_get_audio_featuresARead-onlyIdempotent
Get detailed audio analysis features for one or more Spotify tracks.
Retrieves sonic characteristics (energy, tempo, danceability, valence, acousticness, etc.)
that power the similarity engine. Supports batch processing of up to 100 tracks.
Args:
- track_ids: List of Spotify track IDs, 1-100 tracks
- response_format: 'markdown' or 'json' (default: JSON)
Returns:
Markdown: Per-track audio features (acousticness, danceability, energy, instrumentalness, liveness, loudness, speechiness, valence, tempo, key, mode, time_signature)
JSON: {"track_count": N, "features": [{id, acousticness, danceability, energy, instrumentalness, liveness, loudness, speechiness, valence, tempo, key, mode, time_signature, duration_ms, analysis_url, track_href, type, uri}]}
Examples:
- "Analyze the audio features of this track" -> Get sonic characteristics
- "What's the tempo and energy of these songs?" -> Extract specific features
Errors: Returns "No audio features available" if not found, or error for auth failure (401), rate limits (429). Note: Audio features endpoint deprecated for NEW apps (Nov 2024), but existing apps with extended mode access can still use it.
Inputs: params (required). Returns: result
spotify_get_playlist_tracksARead-onlyIdempotent
Get tracks from a specific Spotify playlist.
Retrieves tracks from a playlist with detailed information (artists, album, duration, IDs).
Results are paginated for large playlists.
Args:
- playlist_id: Spotify playlist ID (get from spotify_get_user_playlists or playlist URL)
- limit: Number of tracks to return, 1-50 (default: 20)
- offset: Starting position for pagination (default: 0)
- response_format: 'markdown' or 'json'
Returns:
Markdown: Numbered list with track details (name, artists, album, duration, ID, URI, popularity)
JSON: {"total": N, "count": N, "offset": N, "tracks": [{id, name, artists, album, duration_ms, popularity, uri, external_urls}], "has_more": bool}
Examples:
- "Show me what's in my workout playlist" -> View playlist contents
- "Get track IDs from this playlist" -> Extract IDs for operations
Errors: Returns "No tracks found" if empty, or error for invalid playlist (404), auth failure (401), rate limits (429).
Inputs: params (required). Returns: result
spotify_get_recommendationsARead-onlyIdempotent
Get track recommendations from Spotify based on seed tracks, artists, or genres.
Generates personalized recommendations using up to 5 seeds (any combination) with
tunable audio features (energy, danceability, valence, tempo).
Args:
- seed_tracks/seed_artists/seed_genres: Up to 5 total seeds (track IDs, artist IDs, or genre names)
- limit: Results to return, 1-100 (default: 20)
- min/max/target audio features: Energy, danceability, valence (0.0-1.0), tempo (BPM)
- response_format: 'markdown' (formatted) or 'json' (structured data)
Returns:
Markdown: Numbered list with track details (name, artists, album, duration, ID, popularity)
JSON: {"total": N, "tracks": [{id, name, artists, album, duration_ms, popularity, uri, external_urls}]}
Examples:
- "Find energetic workout music" -> seed_genres=['electronic'], target_energy=0.9
- "Songs like this track" -> seed_tracks=['track_id']
- "Happy danceable songs" -> target_valence=0.8, target_danceability=0.8
Errors: Returns error for no seeds, >5 seeds, auth failure (401), rate limits (429), or no results.
Inputs: params (required). Returns: result
spotify_get_trackARead-onlyIdempotent
Get detailed information about a specific Spotify track by ID.
Retrieves comprehensive metadata for a single track including artists, album, duration,
popularity, URIs, and external URLs.
Args:
- track_id: Spotify track ID (not URI), extract from URIs or search results
- response_format: 'markdown' or 'json'
Returns:
Markdown: Track details (name, artists, album, duration, ID, URI, popularity)
JSON: Full API response (id, name, artists, album, duration_ms, popularity, uri, external_urls, preview_url, track_number, disc_number, explicit, available_markets)
Examples:
- "Get details for track ID 4u7EnebtmKWzUH433cf5Qv" -> Retrieve track info
- "Show me info about this track" -> When you have the track ID
Errors: Returns error for invalid track (404), auth failure (401), rate limits (429).
Inputs: params (required). Returns: result
spotify_get_user_playlistsARead-onlyIdempotent
Get a list of the current user's Spotify playlists.
Retrieves all playlists owned by or followed by the authenticated user. Results are
paginated. Use to browse playlists or find playlist IDs.
Args:
- limit: Number of playlists to return, 1-50 (default: 20)
- offset: Starting position for pagination (default: 0)
- response_format: 'markdown' or 'json'
Returns:
Markdown: List with playlist name, ID, track count, public status, description, URL
JSON: {"total": N, "count": N, "offset": N, "playlists": [{id, name, description, public, collaborative, tracks, owner, external_urls}], "has_more": bool}
Examples:
- "Show me my playlists" -> List all user playlists
- "Find my workout playlist" -> Browse to find specific one
- Need playlist ID -> Get ID from the list
Errors: Returns "No playlists found." if none exist, or error for auth failure (401), missing scopes (403), rate limits (429).
Inputs: params (required). Returns: result
spotify_search_tracksARead-onlyIdempotent
Search for tracks on Spotify by name, artist, album, or keywords.
Searches Spotify's entire catalog using intelligent matching. Results ranked by relevance.
Args:
- query: Search text, 1-200 chars (e.g., "Bohemian Rhapsody", "artist:Queen", "album:...", or keywords)
- limit: Results to return, 1-50 (default: 20)
- offset: Starting position for pagination (default: 0)
- response_format: 'markdown' or 'json'
Returns:
Markdown: Search results with track details (name, artists, album, duration, ID, URI, popularity)
JSON: {"total": N, "count": N, "offset": N, "tracks": [{id, name, artists, album, duration_ms, popularity, uri, external_urls}], "has_more": bool}
Examples:
- "Find Bohemian Rhapsody by Queen" -> query="Bohemian Rhapsody Queen"
- "Search for songs by Taylor Swift" -> query="artist:Taylor Swift"
- "Look for indie rock songs" -> query="indie rock"
Errors: Returns "No tracks found" if no results, or error for auth failure (401), rate limits (429). Truncates if exceeds character limit.
Inputs: params (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Each tool has a clearly distinct purpose with no ambiguity. The tools cover specific operations like playlist management (create, add tracks, get tracks), track discovery (search, recommendations, similarity), and metadata retrieval (track info, audio features). The descriptions clearly differentiate their functions, making misselection unlikely.
All tool names follow a consistent 'spotify_verb_noun' pattern (e.g., spotify_create_playlist, spotify_get_track). The naming is uniform throughout, using snake_case with clear verbs like 'get', 'create', 'add', 'find', and 'search', making the tool set predictable and easy to navigate.
With 9 tools, the server is well-scoped for managing Spotify playlists and tracks. Each tool serves a distinct and necessary function, covering core operations from playlist creation and modification to track discovery and analysis. The count is appropriate for the domain without being overwhelming or insufficient.
The tool set provides comprehensive coverage for playlist and track management, including CRUD-like operations (create playlist, add tracks, get playlists/tracks) and advanced features (similarity, recommendations, audio analysis). A minor gap exists in playlist modification (e.g., no tool to remove tracks or update playlist details), but agents can work around this with the available tools.
Maintenance
Related MCP Connectors
AI playlist engine that turns music prompts into real YouTube playlists and filters bad versions.
Spotify MCP server for ChatGPT, Claude and any AI agent: search songs and artists, list playlists, read playlist songs, create playlist, add songs to playlist, remove songs from playlist, set playlist public or private and save to Liked Songs in your own Spotify account. Cotlet works in the account through your Cloud Browser, a real Chrome where you sign in to Spotify yourself; Cotlet does not store your password and you need no Spotify API key. About the official Spotify API: Spotify has a full Web API and, since 23 Apr 2026, an official connector for Claude (checked 5 Nov 2026). The API needs an app you register, and in development mode the app owner must have Premium and the app allows 5 users; unlimited users need a registered business with at least 250,000 monthly users. Setup and FAQ: https://cotlet.dev/integrations/spotify-api-mcp-server
Find active Spotify playlists for a song and check a playlist's integrity. No curator contacts.
Find independent music by how it sounds: similar tracks and playlists from a track link.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables interaction with Spotify through natural language for music discovery, playback control, library management, and playlist creation. Supports searching for music, controlling playback, managing saved tracks, and getting personalized recommendations based on mood and preferences.5ISC
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to create, manage, and populate Spotify playlists using the Spotify Web API.3MIT
- FlicenseBqualityDmaintenanceEnables natural-language creation, management, and optimization of Spotify playlists via MCP tools like search, generate, analyze, and recommend.12-
- AlicenseAqualityBmaintenanceEnables AI assistants to control Spotify playback, manage playlists, and plan DJ sets using BPM, key, and energy data.37MIT