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
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。