Spotify MCP Server
A MCP server for controlling Spotify playback, searching for content, and managing playlists via OAuth authentication.
README
spotify_mcp
This package provides an MCP-compatible server exposing Spotify controls and queries via the Model Context Protocol (MCP).
Quick overview:
src/spotify_mcp_server/server.py— FastMCP server exposing tools for playback, search, queue, playlists and devices.- Tools advertise their input schemas using Pydantic models so MCP clients can introspect them.
Running tests (recommended in a virtualenv):
# create and activate venv (macOS/Linux)
python -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txt
python -m pytest -q
Start server locally (prints OAuth URL):
# Start in package root
python -m src.spotify_mcp_server.server
CI: a GitHub Actions workflow is included that installs dependencies and runs the test suite.
If you want additional changes (improved docs, example client calls, Dockerfile), tell me which and I'll add them.
Spotify MCP Server
A MCP (Model Context Protocol) server for controlling Spotify playback, searching for content, and managing playlists.
Features
- OAuth authentication with Spotify
- Playback control (play, pause, skip, queue management)
- Search for tracks, albums, artists, and playlists
- Playlist management (create, edit, add/remove tracks)
- Device management
Prerequisites
- Python 3.10+
- Spotify Developer Account
- Spotify Premium Account (required for playback control)
Setup
Spotify Developer Setup
- Go to Spotify Developer Dashboard
- Create a new app
- Add
http://127.0.0.1:8080/callbackto your app's redirect URIs - Note your Client ID and Client Secret
Environment Variables
Create a .env file in the project root with the following variables:
SPOTIFY_CLIENT_ID=your_client_id
SPOTIFY_CLIENT_SECRET=your_client_secret
SPOTIFY_REDIRECT_URI=http://127.0.0.1:8080/callback
Installation
- Install dependencies:
pip install -e .
- Run the server:
python -m spotify_mcp_server.server
Or using uvicorn directly:
uvicorn spotify_mcp_server.server:app --host 0.0.0.0 --port 8080
- Follow the authentication instructions printed in the console
Usage
The server exposes several MCP tools that can be used to control Spotify:
SpotifyPlayback: Control playback (get current track, start, pause, skip)SpotifySearch: Search for tracks, albums, artists, or playlistsSpotifyQueue: Manage the playback queueSpotifyGetInfo: Get detailed information about Spotify itemsSpotifyPlaylist: Manage playlistsSpotifyDevices: Get available devices
Project Structure
The server consists of several modules located in src/spotify_mcp_server/:
server.py: FastMCP server implementation with MCP tool handlersspotify_api.py: Spotify API client with OAuth handling and API interactionsspotify_helper.py: Comprehensive helper functions and utilitieslogging_config.py: Structured logging configuration
Authentication Flow
- Start the server
- Open the OAuth URL printed in the console
- Authenticate with Spotify
- The server will cache your authentication token
- Server is ready to handle MCP requests
Testing
The project includes comprehensive unit and integration tests.
Installing Test Dependencies
To install the package with test dependencies:
# Install in editable mode with test dependencies
pip install -e ".[test]"
Running Tests
Quick test run:
pytest
Run with coverage:
pytest --cov=src/spotify_mcp_server --cov-report=term-missing --cov-report=html
Run specific test types:
# Unit tests only
pytest tests/test_spotify_helper.py tests/test_spotify_api.py tests/test_server.py
# Integration tests only
pytest tests/test_integration.py
# Specific test file
pytest tests/test_spotify_helper.py
# Specific test function
pytest tests/test_spotify_helper.py::TestNormalizeRedirectUri::test_normalize_redirect_uri_localhost_to_127_0_0_1
Using the test runner script:
# Run all tests with coverage
python run_tests.py --coverage
# Run only unit tests
python run_tests.py --type unit
# Run only integration tests
python run_tests.py --type integration
# Fast run without coverage
python run_tests.py --fast
# Verbose output
python run_tests.py --verbose
# Run specific test file
python run_tests.py --file test_spotify_helper.py
# Run specific test function
python run_tests.py --function test_normalize_redirect_uri
Inspired by
Inspired by the work of varunneal on his spotify-mcp
Recommended Servers
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.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.