Spotify MCP server

Integrates with Spotify to enable music playback control, playlist management, and track searching through OAuth authentication and a lightweight stdio server.
Back to servers
Setup instructions
Provider
Marcel Marais
Release date
Mar 20, 2025
Language
TypeScript
Stats
108 stars

This MCP server lets you control Spotify through AI assistants like Claude and Cursor, allowing playlist management and playback control using natural language commands.

Installation

Prerequisites

  • Node.js v16+
  • Spotify Premium account
  • Registered Spotify Developer application

Setting Up the Server

  1. Clone the repository and install dependencies:
git clone https://github.com/marcelmarais/spotify-mcp-server.git
cd spotify-mcp-server
npm install
npm run build

Creating a Spotify Developer Application

  1. Go to the Spotify Developer Dashboard
  2. Log in with your Spotify account
  3. Click "Create an App"
  4. Fill in the app name and description
  5. Accept the Terms of Service
  6. Note your Client ID and Client Secret
  7. Click "Edit Settings" and add a Redirect URI (e.g., http://127.0.0.1:8888/callback)
  8. Save your changes

Configuring Spotify API Credentials

Create a configuration file with your Spotify credentials:

cp spotify-config.example.json spotify-config.json

Edit the file with your credentials:

{
  "clientId": "your-client-id",
  "clientSecret": "your-client-secret",
  "redirectUri": "http://127.0.0.1:8888/callback"
}

Authentication

  1. Run the authentication script:
npm run auth
  1. Open the generated authorization URL in your web browser
  2. Log in to Spotify and authorize your application
  3. After authorization, Spotify will redirect you to your specified URI
  4. The script will automatically exchange the code for access and refresh tokens
  5. These tokens will be saved to your spotify-config.json file

Integration with AI Assistants

Claude Desktop

Add the MCP server to your Claude configuration:

{
  "mcpServers": {
    "spotify": {
      "command": "node",
      "args": ["spotify-mcp-server/build/index.js"]
    }
  }
}

Cursor

  1. Go to the MCP tab in Cursor Settings (cmd/ctrl + shift + J)
  2. Add a server with this command:
node path/to/spotify-mcp-server/build/index.js

VSCode (via Cline extension)

Create a cline_mcp_settings.json file:

{
  "mcpServers": {
    "spotify": {
      "command": "node",
      "args": ["~/../spotify-mcp-server/build/index.js"],
      "autoApprove": ["getListeningHistory", "getNowPlaying"]
    }
  }
}

Usage

The server provides various tools that can be called by AI assistants to control Spotify. Here are the main categories:

Read Operations

Searching Spotify

searchSpotify("bohemian rhapsody", "track", 20)

Getting Current Playback

getNowPlaying()

Retrieving Playlists

getMyPlaylists(10, 0)

Viewing Playlist Tracks

getPlaylistTracks("37i9dQZEVXcJZyENOWUFo7")

Viewing Recently Played Tracks

getRecentlyPlayed({ limit: 10 })

Viewing Saved Tracks

getUsersSavedTracks({ limit: 20, offset: 0 })

Playback Controls

Playing Music

playMusic({ uri: "spotify:track:6rqhFgbbKwnb9MLmUQDhG6" })
// Or alternatively:
playMusic({ type: "track", id: "6rqhFgbbKwnb9MLmUQDhG6" })

Pausing Playback

pausePlayback()

Navigating Tracks

skipToNext()
skipToPrevious()

Adding to Queue

addToQueue({ uri: "spotify:track:6rqhFgbbKwnb9MLmUQDhG6" })

Playlist Management

Creating Playlists

createPlaylist({ 
  name: "Workout Mix", 
  description: "Songs to get pumped up", 
  public: false 
})

Adding Tracks to Playlists

addTracksToPlaylist({ 
  playlistId: "3cEYpjA9oz9GiPac4AsH4n", 
  trackUris: ["spotify:track:4iV5W9uYEdYUVa79Axb7Rh"] 
})

Album Operations

Getting Album Information

getAlbums("4aawyAB9vmqN3uQ7FjRGTy")
// Or for multiple albums:
getAlbums(["4aawyAB9vmqN3uQ7FjRGTy", "1DFixLWuPkv3KT3TnV35m3"])

Viewing Album Tracks

getAlbumTracks("4aawyAB9vmqN3uQ7FjRGTy", 10, 0)

Saving/Removing Albums

saveOrRemoveAlbumForUser(["4aawyAB9vmqN3uQ7FjRGTy"], "save")

Checking Saved Albums

checkUsersSavedAlbums(["4aawyAB9vmqN3uQ7FjRGTy", "1DFixLWuPkv3KT3TnV35m3"])

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "spotify" '{"command":"node","args":["spotify-mcp-server/build/index.js"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "spotify": {
            "command": "node",
            "args": [
                "spotify-mcp-server/build/index.js"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your 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

2. Add this to your configuration file:

{
    "mcpServers": {
        "spotify": {
            "command": "node",
            "args": [
                "spotify-mcp-server/build/index.js"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later