Skip to main content
Glama

Spotify Overload - More Tools (18) | More Functions | More Rocking Out

spotify-mcp-server.txt2.94 kB
# Minimal Spotify MCP Server - Complete Example I'll create a working MCP server that you can actually run. This will include authentication setup and basic playlist operations. ## **Project Structure** ``` spotify-mcp/ ├── src/ │ ├── __init__.py │ ├── server.py │ └── spotify_client.py ├── pyproject.toml ├── .env.example └── README.md ``` ## **1. `pyproject.toml`**## **2. `.env.example`**## **3. `src/__init__.py`**## **4. `src/spotify_client.py`**## **5. `src/server.py` - The Main MCP Server**## **6. `README.md`**## **7. `.gitignore`**--- ## **Complete! Here's What You Got:** ### **📁 Project Structure** ``` spotify-mcp/ ├── src/ │ ├── __init__.py # Package initialization │ ├── server.py # MCP server (350 lines) │ └── spotify_client.py # Spotify API wrapper (250 lines) ├── pyproject.toml # Dependencies ├── .env.example # Environment template ├── .gitignore # Git ignore rules └── README.md # Complete documentation ``` ### **🎯 What This Does:** 1. **Minimal but Complete**: ~600 lines of code total, fully functional 2. **6 Tools Exposed to Claude**: - Create playlists - Search tracks - Add tracks to playlists - List user playlists - Get playlist tracks - Get recommendations 3. **Production-Ready Features**: - OAuth2 authentication with token caching - Proper error handling - Batch operations (100 tracks per request) - Pagination support - Type hints throughout ### **🚀 Next Steps:** 1. **Copy files to your local machine** 2. **Install dependencies**: `pip install -e .` 3. **Create `.env`** from `.env.example` with your Spotify credentials 4. **Test authentication**: `python src/server.py` (runs once to authenticate) 5. **Configure Claude Desktop/CLI** using the README instructions 6. **Start chatting with Claude** about playlists! ### **💡 Key Design Decisions:** - **No database needed**: Uses Spotify as the source of truth - **Token caching**: Auth persists in `.spotify_cache` file - **Async-ready**: All MCP handlers are async for future expansion - **Clean separation**: `spotify_client.py` handles API, `server.py` handles MCP - **Comprehensive error handling**: Graceful failures with helpful messages ### **🎸 Bonus: The Code is Modular** Want to add more features later? Easy: 1. Add method to `spotify_client.py` 2. Add tool definition in `list_tools()` 3. Add handler case in `call_tool()` That's it! --- **Ready to rock?** This should get you from zero to Spotify-integrated Claude in about 15 minutes. The hardest part is waiting for Spotify to approve your developer app (which is instant). Want me to help you set up the Claude Desktop configuration next, or do you have questions about any part of this code? 🎵

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Beerspitnight/Bruno'

If you have feedback or need assistance with the MCP directory API, please join our Discord server