Skip to main content
Glama
README.md
# 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
- Manage user's music library (save/remove tracks)
- Get user's listening history and top content
- Retrieve plain text song lyrics

## ✨ Key Features

### šŸ› ļø **29 Comprehensive Tools** across 7 categories:

- **Albums** (4 tools): Album information and new releases
- **Artists** (6 tools): Artist data, top tracks, and discovery
- **Tracks** (8 tools): Track details, lyrics, and library management
- **Playlists** (10 tools): Complete playlist management and discovery
- **Playback** (10 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

```bash
git clone <repository-url>
cd Spotify-OAuth-MCP-server
npm install
```

### 2. Get Spotify Access Token

### 3. Build and Start

```bash
# 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`

```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'"
"Search for playlists with chill music"
"Show me my top artists this month"
"What's currently playing?"
"Add this song to my queue"
"Get my recently played tracks"
"Show me the lyrics for this song"
"Get the plain text lyrics for analysis"
```

## šŸ—ļø 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 (6 tools)
│       ā”œā”€ā”€ tracks.ts         # Track-related tools (8 tools)
│       ā”œā”€ā”€ playlists.ts      # Playlist management tools (10 tools)
│       ā”œā”€ā”€ playback.ts       # Playback control tools (10 tools)
│       ā”œā”€ā”€ user.ts           # User profile tools (1 tool)
│       └── search.ts         # Search functionality tools (2 tools)
└── spotify.ts                # Spotify Web API service class
```

### Architecture Benefits

1. **Modularity**: Each tool category is self-contained
2. **Type Safety**: Full TypeScript and Zod validation throughout
3. **Reusability**: Common schemas prevent code duplication
4. **Scalability**: Easy to add new tools and categories
5. **Maintainability**: Clear separation of concerns
6. **Performance**: Efficient registration and validation

## šŸ› ļø Available Tools

### Albums (4 tools)

- `get_album`: Retrieve detailed album information
- `get_album_tracks`: Get tracks from a specific album
- `get_new_releases`: Discover new album releases
- `search_albums`: Search for albums by keywords

### Artists (6 tools)

- `get_artist`: Get detailed artist information
- `get_artist_albums`: Retrieve artist's albums
- `get_artist_top_tracks`: Get artist's most popular tracks
- `search_artists`: Search for artists by keywords
- `get_followed_artists`: Get user's followed artists
- `get_top_artists`: Get user's top artists

### Tracks (8 tools)

- `get_track`: Get detailed track information
- `search_tracks`: Search for tracks by keywords
- `get_liked_tracks`: Get user's saved/liked tracks
- `save_tracks`: Add tracks to user's library
- `remove_tracks`: Remove tracks from user's library
- `get_top_tracks`: Get user's top tracks
- `get_recently_played`: Get recently played tracks
- `get_track_lyrics`: Get plain text lyrics for tracks

### Playlists (10 tools)

- `get_playlist`: Retrieve playlist details
- `get_user_playlists`: Get user's playlists
- `get_playlist_tracks`: Get tracks from a playlist
- `create_playlist`: Create a new playlist
- `add_to_playlist`: Add tracks to a playlist
- `remove_from_playlist`: Remove tracks from a playlist
- `search_playlists`: Search for playlists by keywords
- `get_categories`: Get browse categories
- `save_playlist`: Follow/save a user-created playlist
- `unsave_playlist`: Unfollow/unsave a playlist

### Playback (10 tools)

- `get_currently_playing`: Get current playback information
- `start_playback`: Start music playback
- `resume_player`: Resume paused playback
- `pause_player`: Pause current playback
- `skip_to_next`: Skip to next track
- `skip_to_previous`: Skip to previous track
- `set_volume`: Adjust playback volume
- `add_to_queue`: Add song to playback queue
- `get_devices`: Get available playback devices
- `transfer_playback`: Switch playback between devices

### User (1 tool)

- `get_user_profile`: Get current user's profile information

### Search (2 tools)

- `search_music`: Search for tracks, artists, albums, or playlists
- `search_and_play_music`: Search for content and immediately start playback

---

**Happy Music Streaming with AI! šŸŽµšŸ¤–**

TDQS

A4.1/5.0

Scored across 41 tools

Disambiguation4/5

Most tools have distinct purposes with clear boundaries, such as get_album vs get_album_tracks or add_to_playlist vs add_to_queue. However, some overlap exists, like remove_from_playlist and remove_tracks, which could cause confusion about whether they affect playlists or the user's library. The descriptions help clarify, but the similar naming and overlapping concepts present minor ambiguity.

Naming Consistency5/5

All tools follow a consistent snake_case verb_noun pattern throughout, such as get_album, create_playlist, and search_tracks. The naming is highly predictable and readable, with no mixing of conventions or inconsistent verb styles. This uniformity makes it easy for agents to understand and predict tool functions.

Tool Count2/5

With 41 tools, the count is excessive for a single server, making it feel heavy and potentially overwhelming for agents. While Spotify's API is extensive, many tools could be consolidated (e.g., multiple search tools or overlapping get functions). A more focused set of 15-25 tools would be better scoped for coherence and usability.

Completeness5/5

The tool surface provides comprehensive coverage of Spotify's core functionalities, including CRUD operations for playlists and tracks, playback control, user profile management, and extensive search capabilities. There are no obvious gaps; agents can perform full lifecycle actions like creating, modifying, and deleting content, along with discovery and analytics, ensuring no dead ends in typical workflows.

Maintenance

ActivityInactive
ResponsivenessNo issues