home / mcp / spotify mcp server
Provides access to Spotify music data via MCP using the Spotify Web API for track, artist, and top-tracks queries.
Configuration
View docs{
"mcpServers": {
"akarnik23-mcp-spotify": {
"command": "python",
"args": [
"src/server.py"
],
"env": {
"SPOTIFY_CLIENT_ID": "YOUR_CLIENT_ID",
"SPOTIFY_CLIENT_SECRET": "YOUR_CLIENT_SECRET"
}
}
}
}You run an MCP server that exposes Spotify data through the Spotify Web API, letting you search tracks and artists and pull an artist’s top tracks directly through MCP clients. This server handles authentication, token refresh, and JSON responses so you can integrate Spotify data into your own tools and workflows.
Your MCP client will connect to the MCP endpoint at /mcp on the host where the server runs. You can search for tracks by name, artist, or lyrics, discover artists, and retrieve the top tracks for a given artist. All responses are JSON, making it straightforward to parse and display in your application. Ensure your Spotify credentials are correctly configured in the environment so the server can obtain access tokens automatically. If you encounter rate limits, the server handles automatic token refresh to continue providing results.
Prerequisites you need before starting are Python 3.8 or newer, a Spotify Developer account, and Spotify App credentials (Client ID and Client Secret). Follow these steps to set up and run the MCP server locally.
# 1) Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# 2) Install dependencies
pip install -r requirements.txt
# 3) Set up Spotify API credentials
export SPOTIFY_CLIENT_ID="your_client_id"
export SPOTIFY_CLIENT_SECRET="your_client_secret"
# 4) Run the server
python src/server.pyThe server starts on http://localhost:8000 with the MCP endpoint at http://localhost:8000/mcp. Make sure your environment variables are set before starting the server so the application can authenticate with Spotify.
Environment variables shown for the server include SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET. The server uses Spotify's Client Credentials flow, so no user login is required. All data is returned in JSON format. If you need to test the server locally, you can verify the health status at the root endpoint and make a sample MCP request to list tools or capabilities supported by the server.
Security and deployment considerations: store credentials securely in environment variables, and avoid committing them to source control. If you plan to deploy publicly, ensure your deployment platform supports setting environment variables and that the redirect/URL configuration on Spotify is kept consistent with your deployed domain.
The server exposes the following capabilities via the MCP interface:
Search for tracks on Spotify by name, artist, lyrics, or other query terms. Returns a list of matching tracks with metadata.
Search for artists on Spotify. Returns artist data matching the query.
Retrieve the top tracks for a specified artist in a given market. Includes track metadata and popularity.