Spotify MCP Server
A comprehensive Model Context Protocol (MCP) server that provides seamless integration between AI assistants (like Claude Desktop) and the Spotify Web API. This server enables AI assistants to interact with Spotify's music streaming service through a well-structured, type-safe interface.
π΅ Overview
This MCP server acts as a bridge between AI assistants and Spotify's Web API, allowing users to:
- Search for music, artists, albums, and playlists
- Control playback (play, pause, skip, volume control)
- Manage playlists (create, modify, add/remove tracks)
- Access user profiles and music libraries
- Retrieve detailed audio features and recommendations
β¨ Key Features
π οΈ 44 Comprehensive Tools across 7 categories:
- Albums (4 tools): Album information and new releases
- Artists (7 tools): Artist data, top tracks, and related artists
- Tracks (9 tools): Track details, audio features, and library management
- Playlists (10 tools): Complete playlist management and discovery
- Playback (11 tools): Full player control and device management
- User (1 tool): User profile information
- Search (2 tools): General search and search-to-play functionality
ποΈ Clean Architecture:
- Modular Design: Feature-based tool organization
- Type Safety: Full TypeScript implementation with Zod validation
- Reusable Components: Common schema builders eliminate code duplication
- Automatic Registration: Tools are automatically discovered and registered
- Error Handling: Comprehensive error management with descriptive messages
π§ Developer Experience:
- Easy Extension: Simple pattern for adding new tools
- Maintainable Code: Clear separation of concerns
- Documentation: Self-documenting schema definitions
- Debugging: Detailed logging and error reporting
π Quick Start
1. Clone and Install
git clone <repository-url>
cd Spotify-OAuth-MCP-server
npm install
2. Get Spotify Access Token
3. Build and Start
# Build the TypeScript code
npm run build
# Start the MCP server
npm start
# For development with auto-reload
npm run dev
π§ Claude Desktop Integration
To use this MCP server with Claude Desktop, add it to your MCP configuration:
macOS/Linux: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"spotify": {
"command": "node",
"args": ["/path/to/your/project/src/mcp/server.js"]
}
}
}
π Usage Examples
Once integrated with Claude Desktop, you can use natural language commands:
"Play my Discover Weekly playlist"
"Search for songs by The Beatles"
"Add this song to my favorites"
"Skip to the next track"
"Create a new playlist called 'Morning Vibes'"
"Show me the audio features of this track"
"Find similar artists to Radiohead"
"What's currently playing?"
ποΈ Project Architecture
src/
βββ mcp/
β βββ server.ts # Main MCP server entry point
β βββ helpers/
β β βββ utils.ts # Utility functions and helpers
β βββ schemas/
β β βββ common.ts # Reusable schema builders
β βββ tools/
β βββ index.ts # Tool registry and registration system
β βββ albums.ts # Album-related tools (4 tools)
β βββ artists.ts # Artist-related tools (7 tools)
β βββ tracks.ts # Track-related tools (9 tools)
β βββ playlists.ts # Playlist management tools (10 tools)
β βββ playback.ts # Playback control tools (11 tools)
β βββ user.ts # User profile tools (1 tool)
β βββ search.ts # Search functionality tools (2 tools)
βββ spotify.ts # Spotify Web API service class
Architecture Benefits
- Modularity: Each tool category is self-contained
- Type Safety: Full TypeScript and Zod validation throughout
- Reusability: Common schemas prevent code duplication
- Scalability: Easy to add new tools and categories
- Maintainability: Clear separation of concerns
- Performance: Efficient registration and validation
π οΈ Available Tools
Albums (4 tools)
get_album
: Retrieve detailed album informationget_album_tracks
: Get tracks from a specific albumget_new_releases
: Discover new album releasesget_albums
: Get multiple albums at once
Artists (7 tools)
get_artist
: Get detailed artist informationget_artist_albums
: Retrieve artist's albumsget_artist_top_tracks
: Get artist's most popular tracksget_related_artists
: Find similar artistsget_artists
: Get multiple artists at oncefollow_artist
: Follow an artistunfollow_artist
: Unfollow an artist
Tracks (9 tools)
get_track
: Get detailed track informationget_track_audio_features
: Analyze track's audio characteristicsget_recommendations
: Get personalized recommendationssave_track
: Add track to user's libraryremove_saved_track
: Remove track from librarycheck_saved_tracks
: Check if tracks are savedget_saved_tracks
: Get user's saved tracksget_tracks
: Get multiple tracks at onceget_audio_features
: Get audio features for multiple tracks
Playlists (10 tools)
get_playlist
: Retrieve playlist detailsget_playlist_tracks
: Get tracks from a playlistcreate_playlist
: Create a new playlistadd_tracks_to_playlist
: Add tracks to a playlistremove_tracks_from_playlist
: Remove tracks from a playlistupdate_playlist
: Modify playlist detailsget_user_playlists
: Get user's playlistsget_featured_playlists
: Discover featured playlistsfollow_playlist
: Follow a playlistunfollow_playlist
: Unfollow a playlist
Playback (11 tools)
get_playback_state
: Get current playback informationstart_playback
: Start or resume playbackpause_playback
: Pause current playbackskip_to_next
: Skip to next trackskip_to_previous
: Skip to previous trackseek_to_position
: Seek to specific position in trackset_repeat_mode
: Change repeat modeset_shuffle_state
: Toggle shuffle modeset_volume
: Adjust playback volumeget_available_devices
: List available playback devicestransfer_playback
: Switch playback between devices
User (1 tool)
get_current_user
: Get current user's profile information
Search (2 tools)
search
: Search for tracks, artists, albums, or playlistssearch_and_play
: Search for content and immediately start playback
Happy Music Streaming with AI! π΅π€