Spotify MCP server

Enables Claude to search and retrieve Spotify track, artist, and album information through a local Express.js server leveraging the Spotify Web API for real-time music data retrieval.
Back to servers
Provider
Husain K
Release date
Mar 17, 2025
Language
TypeScript

This Model Context Protocol (MCP) server allows you to access your Spotify playlist information through Claude Desktop. It provides seamless integration between your Spotify account and the Claude AI interface.

Installation

Prerequisites

  • Node.js installed on your system
  • A Spotify developer account
  • Claude Desktop application

Setup Instructions

  1. Clone the repository:

    git clone https://github.com/your-username/MCP-spotify.git
    cd MCP-spotify
    
  2. Install dependencies:

    npm install
    
  3. Create a Spotify Developer application:

    • Go to Spotify Developer Dashboard
    • Create a new application
    • Note your Client ID and Client Secret
    • Add http://localhost:3000/callback as a Redirect URI
  4. Configure environment variables:

    # Create a .env file in the root directory
    echo "SPOTIFY_CLIENT_ID=your_client_id" > .env
    echo "SPOTIFY_CLIENT_SECRET=your_client_secret" >> .env
    

Usage

Starting the MCP Server

Run the server using the following command:

npm start

The server will start running on localhost, typically on port 3000.

Connecting to Claude Desktop

  1. Open Claude Desktop
  2. Navigate to Settings > Model Context Protocols
  3. Add a new MCP connection pointing to your local server address
  4. Authenticate with your Spotify credentials when prompted

Available Commands

Once connected, you can interact with your Spotify account through Claude using natural language. Examples:

  • "Show me my playlists"
  • "What songs are in my 'Favorites' playlist?"
  • "How many tracks are in my 'Workout' playlist?"

Example Interactions

Asking about playlists:

You: What playlists do I have on Spotify?
Claude: I can see you have 5 playlists:
1. Workout Mix (32 tracks)
2. Relaxing Evening (18 tracks)
3. Focus Time (45 tracks)
4. Party Favorites (27 tracks)
5. New Discoveries (12 tracks)

Exploring playlist contents:

You: What songs are in my Focus Time playlist?
Claude: Your "Focus Time" playlist contains 45 tracks including:
1. "Deep Focus" by Brain.fm
2. "Concentration" by Ambient Music Therapy
3. "Study Session" by ChillHop Music
...and 42 more tracks

Troubleshooting

Common Issues

  • Authentication Failed: Ensure your Spotify Developer credentials are correct in the .env file
  • Connection Refused: Check that the server is running and Claude Desktop is configured with the correct address
  • Missing Data: Verify that your Spotify account has the playlists you're trying to access

Refreshing Authentication

If you encounter authentication issues, try:

npm run refresh-auth

This will clear existing tokens and prompt for a new authentication flow.

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