LibreChat-AI/spotify-mcp
If you are the rightful owner of spotify-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This project is a fork of Stytch's MCP Consumer TODO List, adapted to demonstrate Spotify OAuth 2.0 integration with Model Context Protocol (MCP) using Cloudflare Workers.
The Spotify MCP OAuth Server is a specialized implementation designed to integrate Spotify's OAuth 2.0 system with the Model Context Protocol (MCP). This project leverages the OAuth Discovery Pattern to create endpoints compatible with MCP Inspector, replacing Stytch with Spotify as the OAuth provider. The focus is on the API layer, providing a robust backend infrastructure using Cloudflare Workers and Durable Objects for state management. The server supports OAuth 2.0 Authorization Code Flow with PKCE, automatic token refresh, and full integration with the Spotify Web API. It is optimized for development and testing with MCP clients, particularly with tools like LibreChat and MCP Inspector. While the server is not production-ready, it offers a solid foundation for developers to learn and test OAuth flows with MCP, with the potential for further enhancements in security, monitoring, and scalability for production use.
Features
- OAuth 2.0 Authorization Code Flow with PKCE support
- OAuth Discovery Endpoint for MCP Inspector compatibility
- Dynamic Client Registration for seamless MCP client integration
- Automatic Token Refresh for expired access tokens
- Cloudflare Durable Objects for state management
Usages
usage with Cloudflare Workers
bash # Deploy to Cloudflare Workers wrangler secret put SPOTIFY_CLIENT_ID wrangler secret put SPOTIFY_CLIENT_SECRET npm run deploy # Update Spotify app redirect URI to your new Workers URL # Example: https://your-worker.workers.dev/callback
usage with ngrok for Local Development
bash # Start your local MCP server VITE_ALLOWED_HOSTS="localhost,*.ngrok-free.app" npm run dev # Terminal 1: Tunnel for MCP Server (port 3000) ngrok http 3000 # Terminal 2: Tunnel for LibreChat if running locally (port 3080) ngrok http 3080
usage with Spotify Developer Dashboard
bash # Go to Spotify Developer Dashboard # Create a new app # Note your Client ID and Client Secret # Add redirect URIs for your application (e.g., http://localhost:3000/callback)
Tools
searchTracks
Search for tracks
searchArtists
Search for artists
searchAlbums
Search for albums
searchPlaylists
Search for playlists
getCurrentUserProfile
Get current user's profile
getCurrentPlayback
Get current playback state
pausePlayback
Pause playback
resumePlayback
Resume playback
skipToNext
Skip to next track
skipToPrevious
Skip to previous track
getUserPlaylists
Get user's playlists
getPlaylistTracks
Get tracks from a playlist
createPlaylist
Create a new playlist
addTracksToPlaylist
Add tracks to a playlist
getRecentlyPlayed
Get recently played tracks
getTopTracks
Get user's top tracks
getTopArtists
Get user's top artists