MCPInstall
spotify_mcp logo

spotify_mcp

by pradeepjung45 1 stars pradeepjung45/spotify_mcp

A tool integrating Spotify API and Gemini AI for music insights and recommendations.

READMEmain

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

More AI Chatbot MCP servers

Similar servers from the same category.

Jentic

jentic

Enables AI assistants to discover and execute external APIs and workflows through a Python SDK that leverages the Open Agentic Knowledge repository for standardized API access and execution.

AI Chatbot

Provides a bridge to the Flyworks AI lipsync service, enabling creation of digital avatar videos synchronized with audio inputs through a simple API.

git

Official JavaScript implementation that integrates with MiniMax's multimodal capabilities for image generation, video creation, text-to-speech, and voice cloning across multiple transport modes.

APIVideo+7

Provides a bridge to Mureka.ai's music generation capabilities, enabling on-demand creation of lyrics, complete songs, and instrumental tracks without requiring specialized music production knowledge.

AI Chatbot