Sponsored by Deepsite.site

Spotify MCP Server

Created By
254binaryninja8 months ago
A simple python spotify mcp server
Content

Spotify MCP Server

The Spotify MCP Server is a Model Context Protocol (MCP) server designed to interact with the Spotify API. It provides tools to control Spotify playback, such as playing, pausing, skipping tracks, shuffling playlists, and more. This server is built using the mcp framework and spotipy library.

Features

  • Play, pause, and skip tracks.
  • Shuffle and repeat playlists.
  • Play specific albums or tracks by name.
  • Built-in tools for seamless Spotify playback control.

Prerequisites

Before setting up the server, ensure you have the following:

  1. Python 3.12 or higher.
  2. A Spotify Developer account with a registered application. You will need:
    • SPOTIFY_CLIENT_ID
    • SPOTIFY_CLIENT_SECRET
  3. A .env file containing your Spotify credentials.
  4. A premium spotify account

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd spotify-mcp-server
    
  2. Create a virtual environment and activate it:

    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    
  3. Install uv for dependency management:

    pip install uv
    

    Windows

    powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
    
  4. Install dependencies using uv from the pyproject.toml file:

    uv sync
    
  5. Create a .env file in the project root and add your Spotify credentials:

    SPOTIFY_CLIENT_ID=your_client_id
    SPOTIFY_CLIENT_SECRET=your_client_secret
    

Usage

  1. Start the MCP server:

    python server.py
    
  2. Use the provided tools to control Spotify playback. For example:

    • play(): Start playing the current track.
    • pause(): Pause the current track.
    • next_track(): Skip to the next track.
    • play_album("album_name"): Play a specific album by name.
    • play_track("track_name"): Play a specific track by name.
  3. Add MCP tools to your MCP client. For example, if you're using Claude: Add this at the root of your project

    uv mcp install server.py
    

Example Using Calude Desktop

Here is the JSON file

{
"mcpServers": {
  "spotify-mcp-server": {
    "command": "~path-to-project\\spotify-mcp-server\\.venv\\Scripts\\python.exe",
    "args": [
      "~path-to-project\\spotify-mcp-server\\server.py"
    ],
    "transport": "stdio",
    "env":{
      "SPOTIFY_CLIENT_ID": "############",
      "SPOTIFY_CLIENT_SECRET": "############",
      "TRANSPORT": "stdio"
    }
  }
}
}

Troubleshooting

  • Spotify Authentication Failed: Ensure your SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET are correctly set in the .env file.

  • Server Not Starting: Verify that the __name__ check in server.py is correctly set to __server__:

     if __name__ == "__server__":
      mcp.run()
    

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
ChatWiseThe second fastest AI chatbot™
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Tavily Mcp
Serper MCP ServerA Serper MCP Server
WindsurfThe new purpose-built IDE to harness magic
Amap Maps高德地图官方 MCP Server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
DeepChatYour AI Partner on Desktop
CursorThe AI Code Editor
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Playwright McpPlaywright MCP server
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors