Spotify MCP Server

by hrishi0102
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Enables searching for tracks, viewing Spotify profiles, creating and managing playlists, adding tracks to playlists, and getting personalized music recommendations using a Spotify account.

Spotify MCP サーバー

Claude を介して Spotify とやり取りできるシンプルな Model Context Protocol (MCP) サーバーです。このサーバーにより、Claude は Spotify アカウントを使って曲を検索したり、プレイリストを作成したり、おすすめの表示などを行うことができます。

特徴

  • Spotifyでトラックを検索する
  • Spotifyプロフィールを表示する
  • プレイリストを作成する
  • プレイリストにトラックを追加する
  • パーソナライズされた音楽のおすすめを受け取る

利用可能なツール

ツール名説明
set-spotify-credentialsSpotifyの認証情報を設定する
check-credentials-status資格情報が有効かどうか、誰がログインしているかを確認します
search-tracks名前、アーティスト、キーワードでトラックを検索
get-current-userSpotifyプロフィール情報を取得する
create-playlistアカウントに新しいプレイリストを作成する
add-tracks-to-playlist既存のプレイリストにトラックを追加する
get-recommendationsシードトラックに基づいて推奨事項を取得する

セットアップ手順

1. 前提条件

  • Node.js v16以上
  • npm
  • Spotifyアカウント
  • 登録済みのSpotify開発者アプリケーション

2. Spotify開発者アプリを作成する

  1. Spotify開発者ダッシュボード
  2. Spotifyアカウントでログイン
  3. 「アプリを作成」をクリックします
  4. アプリ名と説明を入力してください
  5. リダイレクトURIとしてhttp://localhost:8888/callbackを追加します。
  6. クライアントIDとクライアントシークレットをメモしてください

3. プロジェクトをインストールする

# Clone or download the project first cd spotify-mcp-server # Install dependencies npm install

4. Spotifyトークンを入手する

spotify-auth.jsファイルを編集して、クライアント ID とクライアント シークレットを追加します。

// Replace these with your Spotify app credentials const CLIENT_ID = "your_client_id_here"; const CLIENT_SECRET = "your_client_secret_here";

次に、認証スクリプトを実行します。

node spotify-auth.js

これにより、次のようになります。

  1. ブラウザでURLを開く
  2. Spotifyにログインするように促す
  3. アカウントにアクセスする許可を求める
  4. トークンをsecrets.jsonに保存する

5. MCPサーバーを構築する

npm run build

6. Claudeデスクトップを設定する

Claude Desktop 構成ファイルを編集します。

  • macOSの場合: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows の場合: %APPDATA%\Claude\claude_desktop_config.json

次の構成を追加します。

{ "mcpServers": { "spotify": { "command": "node", "args": ["/full/path/to/spotify-mcp-server/build/spotify-mcp-server.js"] } } }

/full/path/to/spotify-mcp-serverプロジェクト ディレクトリへの実際のパスに置き換えます。

7. Claude Desktopを再起動します

新しい構成をロードするには、Claude Desktop を閉じて再度開きます。

使用法

クロードとの会話を始めるときは、まず Spotify の資格情報を設定する必要があります。

  1. secrets.jsonファイルを参照して資格情報を取得します
  2. set-spotify-credentialsツールを使用して認証する
  3. その後、他のSpotifyツールを使用します

プロンプトの例

資格情報の設定

I want to connect to my Spotify account. Here are my credentials from secrets.json: Tool: set-spotify-credentials Parameters: { "clientId": "your_client_id", "clientSecret": "your_client_secret", "accessToken": "your_access_token", "refreshToken": "your_refresh_token" }

基本コマンド

アカウントを確認してください:

Can you check who I'm logged in as on Spotify? Tool: get-current-user Parameters: {}

トラックを検索:

Search for songs by Weekend Tool: search-tracks Parameters: { "query": "Taylor Swift", "limit": 5 }

プレイリストを作成します:

Create a new playlist called "My Pretty pretty girlfriend" Tool: create-playlist Parameters: { "name": "My Pretty pretty girlfriend", "description": "For my girlfriend. Created with Claude and the Spotify MCP server" }

複数ステップのタスク

曲のプレイリストを作成する:

I want to create a workout playlist with energetic songs. First, search for some high-energy songs. Then create a playlist called "Workout Mix" and add those songs to it.

お気に入りに基づいて推奨事項を取得する:

I like the song "Blinding Lights" by The Weeknd. Can you search for it, then find similar songs, and create a playlist with those recommendations?

トラブルシューティング

  • エラー: アクセストークンが利用できません: まずset-spotify-credentialsツールを使用して資格情報を設定する必要があります
  • 認証失敗: トークンの有効期限が切れている可能性があります。認証スクリプトを再度実行して、新しいトークンを取得してください。
  • 無効な認証情報: 正しいクライアントIDとクライアントシークレットを使用していることを確認してください

注記

  • サーバーは資格情報をメモリにのみ保存します
  • 新しい会話を始めるたびに認証情報を設定する必要があります
  • Claude Desktopが再起動した場合は、資格情報を再度設定する必要があります。

You must be authenticated.

A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

Claude が Spotify アカウントを通じて曲を検索したり、プレイリストを作成したり、おすすめの取得や音楽の管理を行ったりして、Spotify を操作できるようになります。

  1. Features
    1. Tools Available
      1. Setup Instructions
        1. 1. Prerequisites
        2. 2. Create a Spotify Developer App
        3. 3. Install the Project
        4. 4. Get Your Spotify Tokens
        5. 5. Build the MCP Server
        6. 6. Configure Claude Desktop
        7. 7. Restart Claude Desktop
      2. Usage
        1. Example Prompts
          1. Setting Up Credentials
          2. Basic Commands
          3. Multi-Step Tasks
        2. Troubleshooting
          1. Notes
            ID: ho9epeqejw