Spotify MCP server

Integrates with Spotify to enable music search, playlist creation, personalized recommendations, and profile management through secure OAuth authentication.
Back to servers
Provider
Hrishi
Release date
Apr 07, 2025
Language
TypeScript
Stats
1 star

The Spotify MCP server allows Claude to interact with your Spotify account, enabling capabilities like searching songs, creating playlists, adding tracks, and getting personalized recommendations - all through natural language conversations.

Prerequisites

  • Node.js v16 or higher
  • npm
  • A Spotify account
  • A registered Spotify Developer application

Installation Process

Create a Spotify Developer App

  1. Go to Spotify Developer Dashboard
  2. Log in with your Spotify account
  3. Click "Create an App"
  4. Fill in the app name and description
  5. Add http://localhost:8888/callback as a Redirect URI
  6. Save your Client ID and Client Secret for later use

Install the Server

# Clone or download the project first
cd spotify-mcp-server

# Install dependencies
npm install

Configure Spotify Authentication

Edit the spotify-auth.js file with your credentials:

// Replace these with your Spotify app credentials
const CLIENT_ID = "your_client_id_here";
const CLIENT_SECRET = "your_client_secret_here";

Then run the authentication script:

node spotify-auth.js

This will:

  • Open a browser window for Spotify login
  • Ask for your permission to access your account
  • Save the authentication tokens to secrets.json

Build the MCP Server

npm run build

Configure Claude Desktop

Edit your Claude Desktop configuration file:

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

Add the following configuration:

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

Replace /full/path/to/spotify-mcp-server with the actual path to your project directory.

Restart Claude Desktop

Close and reopen Claude Desktop to apply the new configuration.

Using the Spotify MCP Server

Available Tools

The server provides several tools for interacting with Spotify:

  • set-spotify-credentials: Set your Spotify authentication credentials
  • check-credentials-status: Check if your credentials are valid and who is logged in
  • search-tracks: Search for tracks by name, artist, or keywords
  • get-current-user: Get your Spotify profile information
  • create-playlist: Create a new playlist on your account
  • add-tracks-to-playlist: Add tracks to an existing playlist
  • get-recommendations: Get recommendations based on seed tracks

Setting Up Credentials

First, you need to authenticate with Spotify in each new conversation with Claude:

I want to connect to my Spotify account. Here are my credentials from secrets.json:

Tool: set-spotify-credentials
Parameters:
{
  "clientId": "your_client_id",
  "clientSecret": "your_client_secret",
  "accessToken": "your_access_token",
  "refreshToken": "your_refresh_token"
}

Example Commands

Check your Spotify account:

Can you check who I'm logged in as on Spotify?

Tool: get-current-user
Parameters: {}

Search for songs:

Search for songs by Taylor Swift

Tool: search-tracks
Parameters:
{
  "query": "Taylor Swift",
  "limit": 5
}

Create a playlist:

Create a new playlist called "My Favorites"

Tool: create-playlist
Parameters:
{
  "name": "My Favorites",
  "description": "Created with Claude and the Spotify MCP server"
}

Multi-Step Tasks

You can also ask Claude to perform more complex operations that combine multiple tools:

Creating a playlist with songs:

I want to create a workout playlist with energetic songs. First, search for some high-energy songs. Then create a playlist called "Workout Mix" and add those songs to it.

Getting recommendations based on favorites:

I like the song "Blinding Lights" by The Weeknd. Can you search for it, then find similar songs, and create a playlist with those recommendations?

Troubleshooting

  • Error: No access token available: You need to set your credentials first using the set-spotify-credentials tool
  • Authentication failures: Your tokens may have expired. Run the authentication script again to get fresh tokens
  • Invalid credentials: Double check that you're using the correct Client ID and Client Secret

Remember that the server stores credentials in memory only, so you'll need to set credentials at the beginning of each new conversation with Claude.

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

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

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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