MCP ExplorerExplorer

Spotify Mcp

@pradeepjung45on a year ago
1 MIT
FreeCommunity
AI Systems
A tool integrating Spotify API and Gemini AI for music insights and recommendations.

Overview

What is Spotify Mcp

spotify_mcp is a powerful tool that integrates the Spotify API with Google’s Gemini AI to provide music insights, recommendations, and analysis.

Use cases

Use cases include generating personalized playlists, analyzing listening habits for better recommendations, and discovering new music based on user preferences.

How to use

To use spotify_mcp, clone the repository, set up a virtual environment, install dependencies, and configure environment variables. Then, use the command-line interface to authenticate with Spotify and access various features.

Key features

Key features include access to Spotify data (user profiles, playlists, top tracks), AI-powered insights (listening habit analysis, personalized recommendations, playlist insights), and mood-based playlist generation.

Where to use

spotify_mcp can be used in music analysis, personalized music recommendation systems, and applications that require insights into user listening habits.

Content

Spotify MCP Tool

A powerful tool that combines Spotify API with Google’s Gemini AI to provide music insights, recommendations, and analysis.

Features

Spotify Data Access

  • User profile information
  • Playlists and tracks
  • Top tracks and artists
  • Recently played tracks
  • New releases

AI-Powered Insights (Gemini)

  • Comprehensive listening habit analysis
  • Personalized track recommendations
  • Playlist insights and analysis
  • Question answering about playlists
  • Music discovery suggestions
  • Mood-based playlist generation

Installation

  1. Clone the repository:
git clone https://github.com/pradeepjung45/spotify_mcp.git
cd spotify_mcp
  1. Create a virtual environment and install dependencies:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
  1. Set up environment variables:
    Create a .env file in the root directory with the following:
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
SPOTIFY_REDIRECT_URI=http://127.0.0.1:8000/callback
GEMINI_API_KEY=your_gemini_api_key

Usage

CLI Tool

The project includes a command-line interface for interacting with Spotify and Gemini AI:

  1. Authenticate with Spotify:
python mcp_tools.py auth_url

This will provide a URL to open in your browser. After authorizing, you’ll be redirected to a callback URL with a code parameter.

  1. Complete authentication with the code:
python mcp_tools.py auth_url --code YOUR_CODE_HERE
  1. Get your user profile:
python mcp_tools.py user_profile
  1. Get your playlists:
python mcp_tools.py playlists
  1. Get AI analysis of your listening habits:
python mcp_tools.py listening_analysis
  1. Get AI-powered track recommendations:
python mcp_tools.py track_recommendations
  1. Get insights about a specific playlist:
python mcp_tools.py playlist_insights --playlist-id YOUR_PLAYLIST_ID
  1. Ask a question about a playlist:
python mcp_tools.py playlist_question --playlist-id YOUR_PLAYLIST_ID --question "What is the overall mood of this playlist?"
  1. Get music discovery suggestions:
python mcp_tools.py music_discovery
  1. Get a mood-based playlist suggestion:
python mcp_tools.py mood_playlist --mood happy

FastAPI Server

The project also includes a FastAPI server for accessing the same functionality through a web interface:

  1. Start the server:
python -m uvicorn app.main:app --host 0.0.0.0 --port 8000
  1. Open your browser and navigate to http://localhost:8000

  2. Click “Login with Spotify” to authenticate

  3. Access various endpoints for Spotify data and AI insights

MCP Integration

This tool is designed to be used as an MCP (Model Context Protocol) tool with Claude Desktop. Once Claude Desktop is available, you can install the tool using:

mcp install mcp_tools.py

Project Structure

  • app/ - FastAPI application
    • routers/ - API route handlers
    • services/ - Service classes for Spotify and Gemini
    • config.py - Configuration settings
    • main.py - FastAPI application entry point
  • mcp_tools.py - MCP tool and CLI interface

Requirements

  • Python 3.8+
  • Spotify Developer Account
  • Google Gemini API Key

License

MIT

Acknowledgements

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers