Skip to content

popand/SpotifyMCP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spotify MCP Server

A Model Context Protocol (MCP) server that provides Claude with tools to interact with the Spotify API — search music, manage playlists, control playback, and explore your listening history.

Prerequisites

  • Node.js 18+
  • A Spotify account
  • A Spotify Developer application (free or Premium — Premium required for playback control)

Spotify Developer Setup

  1. Go to Spotify Developer Dashboard
  2. Click Create App
  3. Fill in the details:
    • App Name: anything (e.g., "Claude MCP")
    • Redirect URI: http://127.0.0.1:8888/callback
    • APIs used: Web API
  4. Save and note your Client ID and Client Secret

Installation

git clone https://github.com/popand/SpotifyMCP.git
cd SpotifyMCP
npm install
npm run build

Authorization

Set your credentials and run the auth flow:

export SPOTIFY_CLIENT_ID=your_client_id
export SPOTIFY_CLIENT_SECRET=your_client_secret
node dist/index.js auth

This opens a browser window for Spotify login. After approval, tokens are saved to ~/.spotify-mcp/tokens.json (auto-refreshed on expiry).

Configuration

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "spotify": {
      "command": "node",
      "args": ["/path/to/SpotifyMCP/dist/index.js"],
      "env": {
        "SPOTIFY_CLIENT_ID": "your_client_id",
        "SPOTIFY_CLIENT_SECRET": "your_client_secret"
      }
    }
  }
}

Claude Code

Add to your project's .mcp.json:

{
  "mcpServers": {
    "spotify": {
      "command": "node",
      "args": ["/path/to/SpotifyMCP/dist/index.js"],
      "env": {
        "SPOTIFY_CLIENT_ID": "your_client_id",
        "SPOTIFY_CLIENT_SECRET": "your_client_secret"
      }
    }
  }
}

Tools

search_music

Search Spotify for tracks, artists, albums, or playlists.

Parameter Type Default Description
query string required Search query
type "track" | "artist" | "album" | "playlist" "track" Content type
limit number (1-50) 10 Number of results

get_user_playlists

Get the current user's playlists.

Parameter Type Default Description
limit number (1-50) 20 Number of playlists
offset number 0 Pagination offset

get_playlist_tracks

Get tracks in a playlist.

Parameter Type Default Description
playlist_id string required Spotify playlist ID
limit number (1-50) 20 Number of tracks
offset number 0 Pagination offset

create_playlist

Create a new playlist.

Parameter Type Default Description
name string required Playlist name
description string "" Playlist description
public boolean false Public visibility

add_tracks_to_playlist

Add tracks to a playlist.

Parameter Type Default Description
playlist_id string required Spotify playlist ID
track_uris string[] required Array of Spotify track URIs
position number end Insert position (0-based)

remove_tracks_from_playlist

Remove tracks from a playlist.

Parameter Type Default Description
playlist_id string required Spotify playlist ID
track_uris string[] required Array of Spotify track URIs

get_library_songs

Get the user's saved/liked tracks.

Parameter Type Default Description
limit number (1-50) 20 Number of tracks
offset number 0 Pagination offset

get_recently_played

Get recently played tracks.

Parameter Type Default Description
limit number (1-50) 20 Number of tracks

get_top_items

Get top artists or tracks by listening history.

Parameter Type Default Description
type "artists" | "tracks" required Item type
time_range "short_term" | "medium_term" | "long_term" "medium_term" Time range
limit number (1-50) 20 Number of items
offset number 0 Pagination offset

get_now_playing

Get current playback state. No parameters.

control_playback

Control playback (requires Spotify Premium).

Parameter Type Description
action "play" | "pause" | "next" | "previous" | "shuffle" | "repeat" | "volume" Action to perform
device_id string? Target device (uses active device if omitted)
context_uri string? Context to play (album/playlist URI). play only.
track_uris string[]? Track URIs to play. play only. Mutually exclusive with context_uri.
offset_position number? Position in context. play with context_uri only.
shuffle_state boolean? Required for shuffle action
repeat_state "off" | "track" | "context"? Required for repeat action
volume_percent number (0-100)? Required for volume action

Note: Playback control requires a Spotify Premium subscription. Free accounts will receive a "Premium Required" error.

Example Usage

Ask Claude things like:

  • "Search for Taylor Swift's latest album"
  • "Show me my playlists"
  • "Create a playlist called 'Chill Vibes' and add some lo-fi tracks"
  • "What am I listening to right now?"
  • "Skip to the next track"
  • "Show me my top artists from the last month"

License

MIT

About

Spotify MCP server for Claude - search, playlists, library, playback control

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors