Spotify MCP Server

Spotify MCP Server

Integrates Spotify with Claude to enable voice-controlled music playback, playlist management, and personalized recommendations through conversational AI. It provides comprehensive tools for searching tracks, managing liked songs, and analyzing listening habits.

Category
Visit Server

README

๐ŸŽต Spotify MCP Server

A Model Context Protocol (MCP) server that integrates Spotify with Claude, enabling voice-controlled music playback, playlist management, and personalized music recommendations directly through conversational AI.

โœจ Features

๐ŸŽต Playback Control

  • Get currently playing track with full details
  • Play specific tracks by name or ID
  • Pause/resume playback
  • Skip to next/previous tracks
  • Adjust volume levels
  • Toggle shuffle mode

โค๏ธ Library Management

  • Like/unlike songs
  • Add tracks to Liked Songs
  • Remove tracks from Liked Songs

๐Ÿ“ Playlist Operations

  • Create new playlists
  • Add tracks to existing playlists
  • Search and discover music

๐Ÿ” Discovery & Search

  • Search for tracks, artists, albums, and playlists
  • Get personalized recommendations
  • View top tracks and artists (customizable time ranges)

๐Ÿ“Š Analytics

  • View your most played tracks
  • See your top artists
  • Analyze listening habits over different time periods

๐Ÿš€ Prerequisites

  • Node.js v18 or higher
  • Claude Desktop
  • Spotify Premium account (required for playback control)
  • Spotify Developer account

๐Ÿ“ฆ Installation

1. Create Spotify Developer App

  1. Go to Spotify Developer Dashboard
  2. Log in with your Spotify account
  3. Click "Create app"
  4. Fill in:
    • App name: Claude MCP Integration
    • App description: MCP server for Claude AI
    • Redirect URI: http://localhost:3000/callback โš ๏ธ CRITICAL
  5. Save and note your Client ID and Client Secret

2. Clone and Setup

# Clone the repository
git clone https://github.com/MadhurToshniwal/Spotify-MCP-Server.git
cd Spotify-MCP-Server

# Install dependencies
npm install

# Build the project
npm run build

3. Configure Environment Variables

Create a .env file in the project root:

SPOTIFY_CLIENT_ID=your_client_id_here
SPOTIFY_CLIENT_SECRET=your_client_secret_here
SPOTIFY_REFRESH_TOKEN=will_get_this_next

4. Authorize Your Spotify Account

Run the OAuth helper script:

npm run auth

This will:

  1. Start a local server on port 3000
  2. Open your browser to Spotify's authorization page
  3. After you authorize, display your refresh token
  4. Copy the refresh token and add it to your .env file

5. Configure Claude Desktop

Edit your Claude Desktop configuration file:

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

Add this configuration:

{
  "mcpServers": {
    "spotify": {
      "command": "node",
      "args": [
        "/absolute/path/to/spotify-mcp-server/dist/index.js"
      ],
      "env": {
        "SPOTIFY_CLIENT_ID": "your_client_id",
        "SPOTIFY_CLIENT_SECRET": "your_client_secret",
        "SPOTIFY_REFRESH_TOKEN": "your_refresh_token"
      }
    }
  }
}

Important for Windows users: Use double backslashes in paths:

"args": ["C:\\Users\\YourName\\Desktop\\spotify-mcp-server\\dist\\index.js"]

6. Restart Claude Desktop

Completely quit and restart Claude Desktop for changes to take effect.

๐ŸŽฎ Usage Examples

Once configured, you can ask Claude:

Playback Control

  • "What song am I listening to?"
  • "Pause the music"
  • "Play the next song"
  • "Set volume to 70%"
  • "Turn shuffle on"

Search & Discovery

  • "Search for songs by The Weeknd"
  • "Find some jazz playlists"
  • "Search for the album 'Abbey Road'"

Library Management

  • "Add this song to my liked songs"
  • "Unlike this track"
  • "Create a playlist called 'Workout Mix'"
  • "Add these 3 songs to my playlist"

Analytics

  • "What are my top 10 songs this month?"
  • "Show me my most played artists"
  • "What have I been listening to recently?"

Advanced

  • "Search for 'Bohemian Rhapsody' and play it"
  • "Create a playlist called 'Study Music' and add 5 calm songs"
  • "Find electronic music playlists and play the most popular one"

๐Ÿ› ๏ธ Available Tools

Tool Description
search_music Search for tracks, artists, albums, or playlists
get_current_track Get the currently playing track
play_track Play a specific track by URI or ID
pause_playback Pause current playback
resume_playback Resume playback
skip_to_next Skip to next track
skip_to_previous Skip to previous track
like_track Add track to Liked Songs
unlike_track Remove track from Liked Songs
create_playlist Create a new playlist
add_to_playlist Add tracks to a playlist
get_top_tracks Get your top tracks
get_top_artists Get your top artists
set_volume Set playback volume (0-100)
toggle_shuffle Enable/disable shuffle

๐Ÿ”’ Security Notes

  • Never commit your .env file to version control
  • Keep your Client Secret secure
  • Refresh tokens are long-lived - store them safely
  • The server uses OAuth 2.0 with automatic token refresh

๐Ÿ“Š API Limits

Spotify Web API rate limits:

  • Web API calls are rate-limited by Spotify
  • Most endpoints allow several requests per second
  • The server handles token refresh automatically

๐Ÿ› Troubleshooting

"No active device found"

Solution: Open Spotify on your device and play any song to activate a device.

"Invalid refresh token"

Solution: Run npm run auth again to get a new refresh token.

Tools not appearing in Claude

Solution:

  1. Verify the path in claude_desktop_config.json is correct
  2. Ensure all environment variables are set
  3. Restart Claude Desktop completely

"Premium required" errors

Solution: Some features (playback control) require Spotify Premium.

๐Ÿ“ Project Structure

spotify-mcp-server/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ index.ts                # Main MCP server
โ”‚   โ””โ”€โ”€ get-refresh-token.ts    # OAuth helper script
โ”œโ”€โ”€ dist/                       # Compiled JavaScript
โ”œโ”€โ”€ .env                        # Environment variables (not in repo)
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ tsconfig.json
โ””โ”€โ”€ README.md

๐Ÿš€ Development

# Build the project
npm run build

# Run the OAuth helper
npm run auth

# Run in development
npm start

๐Ÿงช Technologies Used

  • TypeScript: Type-safe development
  • Model Context Protocol (MCP): Claude integration standard
  • Spotify Web API: Music streaming service API
  • OAuth 2.0: Secure authentication protocol
  • Express.js: Web server for OAuth flow
  • Axios: HTTP client for API requests

๐Ÿ“œ License

MIT

๐Ÿ‘ค Author

Madhur Toshniwal

๐Ÿ“ง Email: madhurtoshniwal03@gmail.com

๐Ÿ™ Acknowledgments

  • Spotify for their comprehensive Web API
  • Anthropic for the Model Context Protocol
  • Claude Desktop for AI integration

Built to showcase API integration, OAuth implementation, and modern development practices for campus placement interviews.

๐ŸŽ“ Learning Outcomes

This project demonstrates:

  • OAuth 2.0 authentication flow implementation
  • RESTful API integration and error handling
  • Secure credential management
  • Real-time data synchronization
  • TypeScript for type-safe development
  • MCP protocol implementation
  • Asynchronous programming patterns

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured