Spotify MCP Server

Control Spotify from Claude Desktop using the Model Context Protocol. Search tracks, manage playback, and handle playlists — all through natural language.

CI CodeQL MIT Node.js TypeScript
ℹ This server implements the Model Context Protocol (MCP), allowing Claude Desktop to interact with the Spotify Web API through a secure OAuth 2.0 flow.

Features

Eight tools covering the full Spotify playback lifecycle.

🔍

Search Tracks

Query Spotify's entire catalog by track name, artist, album, or keywords.

▶️

Playback Control

Play, pause, skip, seek, and set volume from Claude Desktop.

📋

Playlist Management

List your playlists and browse their tracks without leaving the chat.

📱

Device Control

Discover and switch between all active Spotify-connected devices.

🔒

OAuth 2.0 Auth

Secure authentication using Spotify's official authorization code flow.

✅

95%+ Test Coverage

113 tests across Node 18, 20 & 22 on Linux, macOS, and Windows.

Quick Start

  1. Create a Spotify Developer App

    Go to developer.spotify.com/dashboard, create an app, and save your Client ID and Client Secret.

  2. Clone the repo and generate a Refresh Token

    # Clone the repo
    git clone https://github.com/yennanliu/SpotifyMCP2.git
    cd SpotifyMCP2
    
    # Install dependencies and run the token generator
    npm install
    node get-refresh-token.js
  3. Configure Claude Desktop

    Add the server to your claude_desktop_config.json:

    {
      "mcpServers": {
        "spotify": {
          "command": "node",
          "args": ["/path/to/SpotifyMCP2/dist/index.js"],
          "env": {
            "SPOTIFY_CLIENT_ID":     "your_client_id",
            "SPOTIFY_CLIENT_SECRET": "your_client_secret",
            "SPOTIFY_REFRESH_TOKEN": "your_refresh_token"
          }
        }
      }
    }
  4. Restart Claude Desktop & start using Spotify

    Fully quit and reopen Claude Desktop. Try: "Play some jazz", "Pause the music", or "Show my playlists".

✓ Full walkthrough in the Claude Desktop Setup Guide.

MCP Tools Reference

Eight tools are registered with the MCP server.

Tool Description Key Parameters
search_tracksSearch Spotify catalogquery, limit
play_trackPlay a specific track by URIuri, device_id
playback_controlPlay, pause, next, previous, seek, volumeaction, value
get_current_playbackGet current playback state—
get_user_playlistsList current user's playlistslimit, offset
get_playlist_tracksGet tracks in a playlistplaylist_id
add_to_queueAdd a track to the playback queueuri
get_available_devicesList all active Spotify devices—

Development

# Install dependencies
npm install

# Compile TypeScript
npm run build

# Run all tests
npm test

# Run integration tests
npm run test:integration

# Start MCP server
npm run start:mcp

Project Stats

1,442
Lines of production code
1,013
Lines of test code
113
Passing tests
8
MCP tools
95%+
Code coverage
MIT
Open source license