spotify-mcp

LibreChat-AI/spotify-mcp

3.4

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

  1. searchTracks

    Search for tracks

  2. searchArtists

    Search for artists

  3. searchAlbums

    Search for albums

  4. searchPlaylists

    Search for playlists

  5. getCurrentUserProfile

    Get current user's profile

  6. getCurrentPlayback

    Get current playback state

  7. pausePlayback

    Pause playback

  8. resumePlayback

    Resume playback

  9. skipToNext

    Skip to next track

  10. skipToPrevious

    Skip to previous track

  11. getUserPlaylists

    Get user's playlists

  12. getPlaylistTracks

    Get tracks from a playlist

  13. createPlaylist

    Create a new playlist

  14. addTracksToPlaylist

    Add tracks to a playlist

  15. getRecentlyPlayed

    Get recently played tracks

  16. getTopTracks

    Get user's top tracks

  17. getTopArtists

    Get user's top artists