Spotify MCP Server

by obre10off
Verified

Spotify MCP サーバー

このプロジェクトは、 CursorClaude for Desktop (macOS および Windows のみ) などの MCP クライアントを通じて自然言語を使用して Spotify の再生を制御できるModel Context Protocol (MCP)サーバーを実装します。

特徴

このサーバーは次のツールを公開します。

  • play : トラック、アルバム、またはプレイリストを再生するか、再生を再開します。
  • pause : 再生を一時停止します。
  • next : 次のトラックにスキップします。
  • previous : 前のトラックにスキップします。
  • get_current_track : 現在再生中のトラックに関する情報を取得します。
  • search : トラック、アルバム、アーティスト、またはプレイリストを検索します。

前提条件

  • Bun (バージョン1.0.0以降)
  • Spotify Premium アカウント。
  • Spotify 開発者アプリケーション:
    • Spotify 開発者ダッシュボードで作成します。
    • クライアント ID とクライアント シークレットを取得します。
    • アプリの設定のリダイレクト URI にhttp://localhost:8888/callbackを追加します。
  • MCP クライアント (例: Cursor または Claude for Desktop)。

インストールとセットアップ

  1. リポジトリをクローンします。
    git clone https://github.com/obre10off/spotify-mcp.git cd spotify-mcp
  2. 依存関係をインストールします:
    bun install
  3. .envファイルを作成します。プロジェクトディレクトリのルートに.envというファイルを作成します。以下のコードを追加し、プレースホルダーを実際のSpotifyの認証情報に置き換えます。
    SPOTIFY_CLIENT_ID=your_spotify_client_id SPOTIFY_CLIENT_SECRET=your_spotify_client_secret SPOTIFY_REDIRECT_URI=http://localhost:8888/callback # These will be filled in after running the auth script: SPOTIFY_ACCESS_TOKEN= SPOTIFY_REFRESH_TOKEN=
  4. 認証スクリプトを実行します。このスクリプトはブラウザを開き、Spotify にログインして権限を付与するように要求し、最初のアクセス トークンと更新トークンを取得します。
    bun run auth
    スクリプトはコンソールにSPOTIFY_ACCESS_TOKENSPOTIFY_REFRESH_TOKENを出力します。これらの値を.envファイルにコピーしてください。
  5. MCP クライアントを構成します。
    • カーソル:
      • カーソルの設定を開きます (Cmd+, または Ctrl+,)。
      • 「モデルコンテキストプロトコル」を検索します。
      • 「settings.json で編集」をクリックします。
      • mcp.servers配列に以下を追加します ( /absolute/path/to/your/spotify-mcp``spotify-mcpディレクトリへの絶対パスに置き換えます)。
        { "mcp.servers": [ { "spotify": { "command": "bun", "args": ["/absolute/path/to/your/spotify-mcp/src/index.ts"], "env": { "SPOTIFY_CLIENT_ID": "your_spotify_client_id", "SPOTIFY_CLIENT_SECRET": "your_spotify_client_secret", "SPOTIFY_REDIRECT_URI": "http://localhost:8888/callback", "SPOTIFY_ACCESS_TOKEN": "your_spotify_access_token", "SPOTIFY_REFRESH_TOKEN": "your_spotify_refresh_token" } } } ] }
        値をsettings.jsonファイルに追加するのではなく、 .envファイルを使用して、Spotifyに関連する環境変数のみをそこに置くことをお勧めします。
    • デスクトップ版Claude(macOS/Windows):
      • Claude for Desktop 構成ファイルを開きます。
        • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
        • Windows: %APPDATA%\Claude\claude_desktop_config.json
      • mcpServersオブジェクトに以下を追加します ( /absolute/path/to/your/spotify-mcp``spotify-mcpディレクトリへの絶対パスに置き換えます): GXP6
    • **重要:**クライアント構成では常に絶対パスを使用してください。
  6. MCPクライアントを再起動します設定を適用するには、必ず MCP クライアント (Cursor/Claude) を再起動してください。

サーバーの実行

bun run start This command starts the server with automatic reloading on file changes (thanks to Bun's --watch flag). Keep this terminal window open while you're using the server. ## Usage Once the server is running and your MCP client is configured, you can start using natural language commands to control Spotify. Examples: "Play Bohemian Rhapsody" "Pause the music" "What song is playing?" "Search for Taylor Swift albums" "Next track" "Play spotify:track:4uLU6hMCjMI75M1A2tKUQC"
-
security - not tested
-
license - not tested
-
quality - not tested

Cursor や Claude for Desktop などの MCP クライアントで自然言語コマンドを使用して Spotify の再生を制御できるようにするモデル コンテキスト プロトコル サーバー。

  1. Features
    1. Prerequisites
      1. Installation and Setup
        1. Running the Server
          ID: 4xocsor6an