spotify-mcp-server
Spotify MCP Server: Control Spotify via AI. Play music, manage playlists, and more!

spotify-mcp-server Solution Overview
The Spotify MCP Server is a valuable tool for developers looking to integrate AI models with Spotify's vast music library. As an MCP server, it empowers AI assistants to control Spotify playback and manage playlists through a standardized interface.
This server provides a suite of tools, including searching for tracks, retrieving current playback information, accessing user playlists, and controlling music playback (play, pause, skip). It also enables AI to create new playlists and add tracks, opening up possibilities for intelligent music curation. By leveraging the Model Context Protocol, the Spotify MCP Server allows seamless interaction between AI models and the Spotify API, abstracting away the complexities of direct API integration.
The core value lies in enabling AI-driven music experiences, such as voice-controlled music selection, AI-generated playlists based on user preferences, and automated music management. Built with TypeScript, the server offers a robust and type-safe foundation for integration, typically deployed via Node.js.
spotify-mcp-server Key Capabilities
Spotify Content Search
The searchSpotify
function allows AI models to query Spotify's vast music library. It accepts a search term and the type of item (track, album, artist, playlist) as input, returning a list of matching items with details like IDs and names. This function empowers AI assistants to understand user requests like "find the latest album by The Weeknd" and translate them into specific Spotify searches. The AI can then present the search results to the user or use the IDs to perform further actions, such as playing the selected track. This bridges the gap between natural language and Spotify's API, making music discovery more intuitive. The function uses the Spotify API's search endpoint, supporting a limit
parameter to control the number of results returned, optimizing performance and relevance.
For example, a user could ask, "What are some popular jazz playlists?". The AI assistant would use searchSpotify("jazz", "playlist")
to retrieve a list of relevant playlists, displaying them to the user for selection.
Real-time Playback Control
The playMusic
, pausePlayback
, skipToNext
, and skipToPrevious
functions provide comprehensive control over Spotify playback. playMusic
can start playing a specific track, album, artist, or playlist, identified by its Spotify URI or ID. pausePlayback
pauses the current playback, while skipToNext
and skipToPrevious
navigate the playback queue. These functions enable AI assistants to act as intelligent music controllers, responding to voice commands like "play my Discover Weekly playlist," "pause the music," or "skip to the next song." This hands-free control enhances the user experience, especially in scenarios like driving or cooking. The functions interact directly with the Spotify API's playback endpoints, supporting device selection via the deviceId
parameter for multi-device control.
Imagine a user is working and asks, "Play some focus music." The AI assistant could use searchSpotify
to find a suitable playlist and then use playMusic
to start the playback seamlessly.
Dynamic Playlist Management
The createPlaylist
and addTracksToPlaylist
functions enable AI models to create and modify Spotify playlists. createPlaylist
allows the AI to generate new playlists with a specified name, description, and privacy setting. addTracksToPlaylist
adds tracks to an existing playlist, identified by its ID, with options to specify the insertion position. This functionality allows AI assistants to create personalized music experiences, such as automatically generating workout playlists based on user preferences or creating collaborative playlists with friends. This goes beyond simple playback control, enabling AI to curate and manage music libraries. The functions utilize the Spotify API's playlist management endpoints, ensuring seamless integration with the user's Spotify account.
For instance, a user could say, "Create a playlist called 'Road Trip' and add 'Bohemian Rhapsody' and 'Hotel California'." The AI would use createPlaylist
to create the playlist and then addTracksToPlaylist
to add the specified tracks.
Authentication and Refresh Tokens
The Spotify MCP Server handles the complexities of Spotify API authentication using OAuth 2.0. It guides the user through the initial authentication process, obtaining access and refresh tokens. The server securely stores these tokens and automatically refreshes the access token when it expires, ensuring continuous access to the Spotify API without requiring repeated user intervention. This simplifies the integration process for AI models, allowing them to focus on music-related tasks without managing authentication intricacies. The use of refresh tokens ensures long-term functionality and a seamless user experience.
Integration Advantages
The Spotify MCP Server offers a standardized interface for AI models to interact with Spotify, abstracting away the complexities of the Spotify API. By implementing the MCP protocol, the server provides a consistent and predictable way for AI clients to control Spotify playback, manage playlists, and search for music. This simplifies the development process for AI applications, allowing developers to focus on building intelligent features rather than dealing with the specifics of the Spotify API. The server acts as a bridge between the AI model and Spotify, enabling seamless integration and a richer user experience.