mcp-spotify
MCP server for Spotify implementing the Authorization specification.
claude mcp add --transport stdio tony-artz-mcp-spotify node index.ts \ --env PORT="3000" \ --env DATABASE_URL="postgresql://user:password@host:5432/dbname" \ --env SPOTIFY_CLIENT_ID="your_spotify_client_id" \ --env BETTER_AUTH_SECRET="your_better_auth_secret" \ --env SPOTIFY_REDIRECT_URI="https://your-domain/sign-in/callback" \ --env SPOTIFY_CLIENT_SECRET="your_spotify_client_secret"
How to use
This MCP server, Spotify MCP Server, provides a set of MCP tools to control Spotify playback and retrieve user data via an OAuth-based flow. It uses a StreamableHTTPServerTransport pattern to communicate efficiently with MCP clients and handles token management automatically, including refreshing access tokens when they near expiry. The available tools include playback controls (getCurrentlyPlaying, pausePlayback, resumePlayback, skipToNext, skipToPrevious, setVolume), track discovery tools (searchTracks, playTrack), and user information access (getUserProfile). To get started, authenticate with Spotify through the sign-in flow exposed by the server, which then provisions a session and stores refresh tokens securely in PostgreSQL via Drizzle ORM. From your MCP client you can call these tools to perform actions or query state, and the server will manage token lifecycles in the background.
How to install
Prerequisites:
- Node.js or Bun environment (the project uses Bun for tooling in practice)
- PostgreSQL database available and accessible
- Access to Spotify for client credentials and a redirect URI configured
Installation steps:
- Install dependencies
bun install
- Configure environment variables Create a .env file or set environment variables as shown:
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
SPOTIFY_REDIRECT_URI=https://your-domain/sign-in/callback
DATABASE_URL=postgresql://user:password@host:5432/dbname
BETTER_AUTH_SECRET=your_better_auth_secret
PORT=3000
- Setup database and migrations
bun run drizzle-kit push
- Run the server
bun run index.ts
Notes:
- Adjust the DATABASE_URL to point to your PostgreSQL instance.
- Ensure the redirect URI matches what you configure in Spotify and in your BetterAuth setup.
Additional notes
Tips and considerations:
- Ensure your PostgreSQL user has read/write permissions for the Drizzle ORM setup.
- The server uses BetterAuth with a Drizzle adapter; keep the BETTER_AUTH_SECRET secure and rotate as needed.
- If you encounter token refresh issues, verify that the refresh token is stored correctly in the database and that the Spotify client credentials are valid.
- Environment variables can be overridden per deployment; consider using a secrets manager for production.
- The MCP tools expect an MCP client that supports StreamableHTTPServerTransport for best performance.
- Port 3000 is the default; update PORT in the environment if needed.
Related MCP Servers
XcodeBuildMCP
A Model Context Protocol (MCP) server and CLI that provides tools for agent use when working on iOS and macOS projects.
Matryoshka
MCP server for token-efficient large document analysis via the use of REPL state
sonarqube
Model Context Protocol (MCP) server for SonarQube
pluggedin-app
The Crossroads for AI Data Exchanges. A unified, self-hostable web interface for discovering, configuring, and managing Model Context Protocol (MCP) servers—bringing together AI tools, workspaces, prompts, and logs from multiple MCP sources (Claude, Cursor, etc.) under one roof.
Agentic -Skill
Agentic-MCP, Progressive MCP client with three-layer lazy loading. Validates AgentSkills.io pattern for efficient token usage. Use MCP without pre-install & wasting full-loading
mcp -python-template
This template provides a streamlined foundation for building Model Context Protocol (MCP) servers in Python. It's designed to make AI-assisted development of MCP tools easier and more efficient.