Spotify MCP server

Provides a bridge to the Spotify API for controlling music playback, managing playlists, and getting personalized recommendations without leaving your conversation interface.
Back to servers
Setup instructions
Provider
imprvhub
Release date
Apr 20, 2025
Language
TypeScript
Stats
15 stars

MCP Claude Spotify is an integration that allows Claude Desktop to interact with Spotify using the Model Context Protocol. It enables features like searching for music, controlling playback, managing playlists, and getting personalized recommendations directly from Claude.

Requirements

  • Node.js 16 or higher
  • Spotify account
  • Claude Desktop
  • Spotify API credentials (Client ID and Client Secret)

Installation

Installing via Smithery

To install automatically via Smithery:

npx -y @smithery/cli install @imprvhub/mcp-claude-spotify --client claude

Installing Manually

  1. Clone or download the repository:
git clone https://github.com/imprvhub/mcp-claude-spotify
cd claude-spotify-mcp
  1. Install dependencies:
npm install
  1. Build the project (optional if you want to modify the source code):
npm run build

Setting up Spotify Credentials

To use this MCP, you need to obtain Spotify API credentials:

  1. Go to Spotify Developer Dashboard
  2. Log in with your Spotify account
  3. Click "Create App"
  4. Fill in your app information:
    • App name: "MCP Claude Spotify" (or whatever you prefer)
    • App description: "Spotify integration for Claude Desktop"
    • Website: You can leave this blank or put any URL
    • Redirect URI: Important - Add http://127.0.0.1:8888/callback
  5. Accept the terms and conditions and click "Create"
  6. In your app dashboard, you'll see the "Client ID"
  7. Click "Show Client Secret" to reveal your "Client Secret"

Save these credentials for the configuration steps.

Running the MCP Server

Option 1: Running manually

  1. Open a terminal or command prompt
  2. Navigate to the project directory
  3. Run the server directly:
node build/index.js

Keep this terminal window open while using Claude Desktop.

Option 2: Auto-starting with Claude Desktop

Claude Desktop can automatically start the MCP server when needed:

Configuration

Edit the Claude Desktop configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Add the Spotify MCP configuration:

{
  "mcpServers": {
    "spotify": {
      "command": "node",
      "args": ["ABSOLUTE_PATH_TO_DIRECTORY/mcp-claude-spotify/build/index.js"],
      "env": {
        "SPOTIFY_CLIENT_ID": "your_client_id_here",
        "SPOTIFY_CLIENT_SECRET": "your_client_secret_here"
      }
    }
  }
}

Important: Replace:

  • ABSOLUTE_PATH_TO_DIRECTORY with the complete absolute path where you installed the MCP
  • your_client_id_here with your Spotify Client ID
  • your_client_secret_here with your Spotify Client Secret

Usage

  1. Restart Claude Desktop after modifying the configuration
  2. In Claude, use the auth-spotify command to start the authentication process
  3. A browser window will open for you to authorize the application
  4. Log in with your Spotify account and authorize the application
  5. After successful authentication, restart Claude Desktop to properly initialize the MCP
  6. After restarting, all Spotify MCP tools will be available for use

Available Tools

auth-spotify

Initiates the Spotify authentication process.

search-spotify

Searches for tracks, albums, artists, or playlists.

Parameters:

  • query: Search text
  • type: Type of search (track, album, artist, playlist)
  • limit: Number of results (1-50)

play-track

Plays a specific track.

Parameters:

  • trackId: Spotify track ID
  • deviceId: (Optional) Spotify device ID to play on

get-current-playback

Gets information about the current playback.

pause-playback

Pauses the playback.

next-track

Skips to the next track.

previous-track

Returns to the previous track.

get-user-playlists

Gets the user's playlists.

create-playlist

Creates a new playlist.

Parameters:

  • name: Playlist name
  • description: (Optional) Description
  • public: (Optional) Whether it's public or private

add-tracks-to-playlist

Adds tracks to a playlist.

Parameters:

  • playlistId: Playlist ID
  • trackIds: Array of track IDs

get-recommendations

Gets recommendations based on seeds.

Parameters:

  • seedTracks: (Optional) Array of track IDs
  • seedArtists: (Optional) Array of artist IDs
  • seedGenres: (Optional) Array of genres
  • limit: (Optional) Number of recommendations (1-100)

get-top-tracks

Gets the user's most played tracks over a specified time range.

Parameters:

  • limit: (Optional) Number of tracks to return (1-50, default: 20)
  • offset: (Optional) Index of the first track to return (default: 0)
  • time_range: (Optional) Time frame for calculating affinity:
    • short_term: Approximately last 4 weeks
    • medium_term: Approximately last 6 months (default)
    • long_term: Several years of data

Troubleshooting

"Server disconnected" error

If you see "MCP Spotify: Server disconnected" in Claude Desktop:

  1. Verify the server is running:

    • Open a terminal and manually run node build/index.js from the project directory
    • If the server starts successfully, use Claude while keeping this terminal open
  2. Check your configuration:

    • Ensure the absolute path in claude_desktop_config.json is correct
    • Double-check that you've used double backslashes (\\) for Windows paths
    • Verify you're using the complete path from the root of your filesystem

Browser doesn't open automatically

If the browser doesn't open during authentication, manually visit: http://127.0.0.1:8888/login

Authentication error

Make sure you've correctly configured the redirect URI in your Spotify Developer dashboard: http://127.0.0.1:8888/callback

Tools not appearing in Claude

If the Spotify tools don't appear in Claude after authentication:

  • Make sure you've restarted Claude Desktop after successful authentication
  • Check the Claude Desktop logs for any MCP communication errors
  • Ensure the MCP server process is running
  • Verify that the MCP server is correctly registered in the Claude Desktop MCP registry

Checking if the server is running

To check if the server is running:

  • Windows: Open Task Manager, go to the "Details" tab, and look for "node.exe"
  • macOS/Linux: Open Terminal and run ps aux | grep node

If you don't see the server running, start it manually or use the auto-start method.

Security Notes

  • Never share your Client ID and Client Secret
  • Access token is stored in the user's home directory at ~/.spotify-mcp/tokens.json
  • No user data is stored on disk

Revoking Application Access

To revoke access:

  1. Go to your Spotify Account page
  2. Navigate to "Apps" in the menu
  3. Find "MCP Claude Spotify" (or the name you chose for your app)
  4. Click "REMOVE ACCESS"

This invalidates all access and refresh tokens. The next time you use the auth-spotify command, you'll need to authorize the application again.

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":["ABSOLUTE_PATH_TO_DIRECTORY/mcp-claude-spotify/build/index.js"],"env":{"SPOTIFY_CLIENT_ID":"your_client_id_here","SPOTIFY_CLIENT_SECRET":"your_client_secret_here"}}'

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": [
                "ABSOLUTE_PATH_TO_DIRECTORY/mcp-claude-spotify/build/index.js"
            ],
            "env": {
                "SPOTIFY_CLIENT_ID": "your_client_id_here",
                "SPOTIFY_CLIENT_SECRET": "your_client_secret_here"
            }
        }
    }
}

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": [
                "ABSOLUTE_PATH_TO_DIRECTORY/mcp-claude-spotify/build/index.js"
            ],
            "env": {
                "SPOTIFY_CLIENT_ID": "your_client_id_here",
                "SPOTIFY_CLIENT_SECRET": "your_client_secret_here"
            }
        }
    }
}

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