spotify-direct-mcp
Provides tools for searching tracks, getting track details (BPM, key, energy, danceability), retrieving artist discography, getting recommendations based on seeds or mood, checking the currently playing track on the user's account, and creating playlists via the Spotify API.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@spotify-direct-mcpRecommend me some chill electronic tracks"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
spotify-direct-mcp
A FastMCP server that exposes Spotify as a set of tools for Claude.
Ask Claude things like:
"What's the full discography of Sade?"
"What key and BPM is 'Isn't She Lovely' in?"
"Recommend 20 tracks with the same vibe as Stevie Wonder — high energy, soulful"
"What am I listening to right now?"
"Create a private playlist called 'Late Night Drive' from those recommendations"
Tools
Tool | Description | Auth required |
| Search the Spotify catalog | No |
| Audio features (BPM, key, energy, danceability) + metadata | No |
| Full album/track list for an artist | No |
| Mood/seed-based track recommendations | No |
| What's playing on your account right now | Yes |
| Create a playlist in your account | Yes |
Note: As of late 2024, Spotify restricts the
audio-featuresandrecommendationsendpoints to apps approved for "Extended Quota Mode". If your app doesn't have that approval,get_track_detailswill still return track metadata butaudio_featureswill contain an explanatory message instead of BPM/key data, andget_recommendationswill return anerrorfield with the same explanation. Request access at https://developer.spotify.com/documentation/web-api/concepts/quota-modes.
Related MCP server: Spotify MCP Server
Prerequisites
Python 3.10+ (required by FastMCP and the underlying MCP SDK — see below if you're not sure what you have)
A Spotify account (free or premium)
A Spotify Developer app (developer.spotify.com/dashboard)
Checking your Python version
python3 --versionIf this prints 3.10.x, 3.11.x, 3.12.x, or 3.13.x, you're good — skip to Step 1.
If it prints 3.9.x or lower (common on macOS, which ships an old system Python),
you need to install a newer Python before creating the virtual environment in
Step 2. pip install -r requirements.txt will fail with
Could not find a version that satisfies the requirement fastmcp>=2.0 if you try to
use Python 3.9 or earlier.
Installing Python 3.10+
macOS (Homebrew):
brew install python@3.12This installs a separate python3.12 binary alongside your system Python — it won't
replace or break anything else. Verify with:
python3.12 --versionmacOS (no Homebrew): Download the installer from
python.org/downloads and run it. After
installing, use python3.12 (or whichever version you installed) in place of
python3 below.
Windows: Download the installer from python.org/downloads, run it, and check "Add python.exe to PATH" during install. Verify with:
python --versionLinux (Debian/Ubuntu):
sudo apt update
sudo apt install python3.12 python3.12-venvUsing pyenv (any OS, if you manage multiple Python versions):
pyenv install 3.12.7
pyenv local 3.12.7 # sets this version for the spotify-direct-mcp directoryOnce you have a 3.10+ interpreter available, use that binary (e.g. python3.12)
instead of python3 when creating the virtual environment in Step 2.
Step 1: Spotify Developer Setup
Click Create app
Fill in:
App name:
spotify-direct-mcpApp description: anything
Redirect URI:
http://localhost:8888/callbackCheck: Web API
Click Save
Copy your Client ID and Client Secret from the app settings
Step 2: Local Setup
# Clone or copy the project
cd spotify-direct-mcp
# Create virtual environment using Python 3.10+
# If `python3 --version` showed 3.10+, use python3 below.
# Otherwise, substitute the 3.10+ binary you installed above (e.g. python3.12).
python3 -m venv .venv
source .venv/bin/activate # Mac/Linux
# .venv\Scripts\activate # Windows
# Confirm the venv is using Python 3.10+
python --version
# Install dependencies
pip install -r requirements.txt
# Copy env template and fill in your credentials
cp .env.example .envIf pip install -r requirements.txt fails with
Could not find a version that satisfies the requirement fastmcp>=2.0, your venv was
created with Python <3.10. Delete it and recreate using a 3.10+ binary:
rm -rf .venv
python3.12 -m venv .venv # use whichever 3.10+ binary you installed
source .venv/bin/activate
pip install -r requirements.txtEdit .env:
SPOTIFY_CLIENT_ID=your_client_id_here
SPOTIFY_CLIENT_SECRET=your_client_secret_here
SPOTIFY_REDIRECT_URI=http://localhost:8888/callbackStep 3: OAuth Setup (one-time)
Tools that access your personal account (get_currently_playing, create_playlist) require
a one-time OAuth authorization:
python oauth_setup.pyThis will:
Open a browser window to Spotify's auth page
Ask you to authorize the app
Redirect you to
localhost:8888/callback(the page won't load — that's fine)Ask you to paste the full redirect URL
Cache your token to
.spotify_cache
You only need to do this once. The token auto-refreshes.
Step 4: Run Locally
Option A: stdio (for Claude Desktop)
python server.py
# or explicitly:
python server.py stdioOption B: SSE (for Railway / remote clients)
python server.py sse
# Server starts on http://localhost:8000Step 5: Connect to Claude Desktop
Add this to your Claude Desktop config file:
Mac: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"spotify-direct-mcp": {
"command": "/absolute/path/to/.venv/bin/python",
"args": ["/absolute/path/to/spotify-direct-mcp/server.py"],
"env": {
"SPOTIFY_CLIENT_ID": "your_client_id_here",
"SPOTIFY_CLIENT_SECRET": "your_client_secret_here",
"SPOTIFY_REDIRECT_URI": "http://localhost:8888/callback"
}
}
}
}Replace /absolute/path/to/ with your actual paths.
Restart Claude Desktop after saving. You should see spotify-direct-mcp in the tools list.
Step 6: Deploy to Railway
First-time setup
# Install Railway CLI
npm install -g @railway/cli
# Login
railway login
# Initialize project
railway init
# Set environment variables
railway variables set SPOTIFY_CLIENT_ID=your_client_id_here
railway variables set SPOTIFY_CLIENT_SECRET=your_client_secret_here
railway variables set SPOTIFY_REDIRECT_URI=https://your-app.railway.app/callbackUpdate Redirect URI on Spotify
Before deploying, add your Railway URL as an allowed redirect URI in your Spotify app settings:
Click your app → Edit Settings
Add
https://your-app.railway.app/callbackto Redirect URIsSave
Deploy
railway upRailway reads railway.toml and automatically:
Detects Python via Nixpacks
Installs
requirements.txtRuns
python server.py sseSets
PORTenvironment variable
Get your deployed URL
railway domain
# Returns something like: https://spotify-direct-mcp-production.up.railway.appConnect Claude to your Railway deployment
Once deployed, your MCP server is accessible via SSE at:
https://your-app.railway.app/sseAdd this to your Claude Desktop config:
{
"mcpServers": {
"spotify-direct-mcp": {
"url": "https://your-app.railway.app/sse"
}
}
}Important: OAuth on Railway
get_currently_playing and create_playlist require an OAuth token tied to your Spotify account.
The .spotify_cache file generated locally is not automatically available on Railway. You have two options:
Option A (Recommended for personal use): Complete OAuth locally, then set the token contents as a Railway environment variable:
# After running oauth_setup.py locally:
cat .spotify_cache
# Copy the JSON output, then:
railway variables set SPOTIFY_TOKEN_CACHE='{"access_token": "...", ...}'Then update server.py to read from this env var if the cache file doesn't exist — or simply use the server for catalog tools only (search, details, discography, recommendations) which don't need user auth.
Option B: Use a token refresh endpoint pattern (more complex, not scaffolded here).
For the interview demo, Option A or catalog-only is perfectly sufficient.
Project Structure
spotify-direct-mcp/
├── server.py # FastMCP server — all tools live here
├── oauth_setup.py # One-time OAuth flow helper
├── requirements.txt # Python dependencies
├── railway.toml # Railway deployment config
├── .env.example # Environment variable template
├── .env # Your actual credentials (gitignored)
├── .spotify_cache # OAuth token cache (gitignored)
└── README.md # This fileExample Prompts for Claude
Once connected, try these:
Search for "Isn't She Lovely" and give me the BPM and musical key.
What's Sade's full discography sorted by year?
Recommend 15 tracks similar to Anita Ward with high danceability and moderate energy.
What am I currently listening to? What key is it in?
Create a private playlist called "Sunday Morning Soul" from these track URIs: [paste URIs]
Search for top tracks by Stevie Wonder from the 1970s.Architecture Notes
Client Credentials flow is used for all catalog tools (no user login required)
OAuth PKCE flow is used for user-context tools (currently playing, create playlist)
FastMCP handles the MCP protocol — all tools are decorated with
@mcp.tool()Transport is switchable:
stdiofor local/Claude Desktop,ssefor Railway/remoteRailway auto-detects Python via Nixpacks — no Dockerfile needed
Built With
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/thejaredchapman/spotify-direct-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server