๐ต Workshop Music MCP Server
AI @Princeton x CBC Workshop - October 30, 2025
Build a real MCP server that connects Claude to Spotify! Search songs, analyze music collections, and create playlists using natural language.
๐ฏ What You'll Learn
- MCP Fundamentals: Build servers that give Claude new capabilities
- API Integration: Connect to real services (Spotify)
- Tool Design: Create intuitive interfaces for AI
- Real-world Skills: Handle API changes and deprecations (like we did with Spotify's 2025 update!)
โก Quick Start
Prerequisites
- Python 3.10 or higher
- A Spotify account (free is fine!)
- Claude Desktop app installed
- Basic familiarity with terminal/command line
Installation
Clone this repository
git clone <your-repo-url> cd workshop-music-mcpInstall dependencies
pip install -r requirements.txtSet up Spotify credentials
- Follow SPOTIFY_SETUP.md to get your API keys
- Copy
.env.exampleto.envand fill in your credentials
Configure Claude Desktop
- See SETUP.md for detailed instructions
- Add the MCP server to your Claude Desktop config
Start the server and try it!
python music_server_updated_2025.pyThen restart Claude Desktop and start chatting!
๐ต What Can It Do?
Once connected, you can ask Claude things like:
Basic Discovery:
- "Find me some upbeat indie songs" - Search tracks
- "Tell me about Taylor Swift's most popular songs" - Artist information
- "Give me recommendations based on Blinding Lights" - Get song recommendations
Collection Analysis:
- "Is this playlist family-friendly?" - Check explicit content
- "How diverse is my music taste?" - Artist, genre, and era diversity
- "Which artists do I listen to most?" - Artist frequency analysis
- "What genres dominate my collection?" - Genre breakdown and distribution
- "Analyze this playlist" - Get popularity stats and explicit content overview
Playlist Creation: ๐ฏ
- "Create a playlist from these 20 songs" - Make actual Spotify playlists
- "Balance this collection by genre and create a playlist" - Smart playlist generation
๐ง Available Tools (10 Total)
Discovery & Search
search_tracks
Search for songs on Spotify by name, artist, or keywords. Returns track details, popularity, and Spotify links.
get_recommendations
Get song recommendations based on seed tracks, artists, or genres. Great for discovering new music similar to what you already love.
get_artist_info
Get detailed information about artists including their top tracks, genres, popularity, and follower count.
Playlist Tools โญ NEW!
create_playlist
Create a real Spotify playlist from a collection of songs! Provide song names and artists, and it'll search for them and create the playlist on your account.
generate_balanced_playlist
Create a balanced playlist from a larger collection. Balance by:
- Genre - Equal representation across genres
- Artist - Max 2 songs per artist for diversity
- Era - Even distribution across decades
analyze_playlist
Analyze any Spotify playlist to get popularity stats, explicit content percentage, and track details.
Collection Analysis Tools ๐ฏ
analyze_explicitness
Check explicit content in your song collection - find out what percentage has explicit lyrics and get a family-friendly rating.
analyze_collection_diversity
Analyze how diverse your music collection is:
- Artist variety and diversity score
- Genre spread and unique genres
- Popularity distribution (mainstream vs underground)
- Era range and distribution across decades
get_top_artists_from_collection
Find which artists appear most frequently in your collection and see their contribution percentages. Perfect for understanding your listening habits.
analyze_genres_in_collection
Get a complete genre breakdown - dominant styles, genre diversity score, and detailed distribution percentages with genre tags for each song.
๐จ What Changed in 2025?
Important API Update: Spotify deprecated their audio-features endpoint in November 2024. This MCP server has been updated to work without it!
What's different:
- โ Removed: Audio features like danceability, energy, valence, tempo are no longer accessible
- โ Still Available: Track info (name, artist, album, popularity, explicit flag), artist genres, release dates
- ๐ฏ New Focus: Playlist creation, genre analysis, explicitness checking, and collection diversity
What this means for you:
- You won't see "mood" analysis or "energy levels" anymore
- Focus shifted to practical tools: creating playlists and analyzing your collection's diversity
- The tools now use what's reliably available: popularity scores, genres, explicit flags, and release years
๐๏ธ Architecture
โโโโโโโโโโโโโโโ
โ Claude โ Asks: "Find upbeat songs"
โ Desktop โ
โโโโโโโโฌโโโโโโโ
โ MCP Protocol
โ
โโโโโโโโผโโโโโโโโโโโ
โ MCP Server โ Converts to: search_tracks("upbeat")
โ (This Code!) โ
โโโโโโโโฌโโโโโโโโโโโ
โ Spotify API
โ
โโโโโโโโผโโโโโโโโโโโ
โ Spotify Web โ Returns: Song data
โ API โ
โโโโโโโโโโโโโโโโโโโ
How it works:
- You ask Claude a music question in natural language
- Claude decides which MCP tool to use
- Your MCP server calls Spotify's API
- Results come back to Claude
- Claude presents them in a friendly way
๐ Documentation
- QUICKSTART.md - Get running in 10 minutes
- SETUP.md - Detailed installation guide
- SPOTIFY_SETUP.md - How to get API credentials
- TOOLS_REFERENCE.md - ๐ Quick reference for all tools (print this!)
- EXAMPLES.md - โญ Example queries for bulk analysis tools!
- ADVANCED_ANALYSIS.md - ๐ฏ Advanced analysis: explicitness, diversity, artists, genres!
- WORKSHOP_GUIDE.md - Full workshop walkthrough
- TROUBLESHOOTING.md - Common issues and fixes
- CONTRIBUTING.md - Build your own tools!
๐ Learning Resources
New to MCP?
Want to Learn More?
๐ 48-Hour Challenge
After the workshop, try building your own MCP server! Some ideas:
- ๐ Book Recommendations - Connect to Goodreads or Open Library
- ๐ฌ Movie Analysis - Use TMDB API for film data
- ๐ Recipe Finder - Integrate with Spoonacular
- โก Smart Home - Control your lights or thermostat
- ๐ Data Viz - Generate charts from your data
Join the AI@Princeton Discord for support during the challenge!
๐ Troubleshooting
"ModuleNotFoundError: No module named 'spotipy'"
- Run:
pip install -r requirements.txt
"Can't connect to Spotify"
- Check your
.envfile has the correct credentials - Make sure you've created a Spotify app on their dashboard
"Claude can't see the tools"
- Restart Claude Desktop after adding the server to config
- Check that the server path in config is absolute (full path)
More issues? See TROUBLESHOOTING.md
๐ค Contributing
Want to add more features? Check out CONTRIBUTING.md for:
- How to add new tools
- Code style guidelines
- Testing your changes
- Submitting improvements
๐ License
MIT License - see LICENSE file for details.
๐ Acknowledgments
Built for AI@Princeton's MCP Workshop Series. Special thanks to:
- Anthropic for creating MCP
- Spotify for their excellent API
- The Princeton AI community
๐ง Questions?
- Workshop Questions: Ask during the session or on Discord
- Technical Issues: Open an issue on GitHub
- General MCP Help: Check docs.anthropic.com/mcp
Ready to build? Start with QUICKSTART.md or jump into SETUP.md!
โญ If this helped you, give it a star on GitHub!