ytmusic-mcp
ytmusic-mcp
MCP サーバーであり、ytmusicapi をラップして、Claude(または任意の MCP クライアント)が YouTube Music の検索、プレイリストの管理、リスニング履歴の読み取りを行えるようにします。
ツール
ツール | 説明 |
| YouTube Music を検索します。 |
| ライブラリのプレイリストを一覧表示します。 |
| プレイリスト内のトラックを取得します。 |
| 新しいプライベートプレイリストを作成し、その ID を返します。 |
| トラックをプレイリストに追加します。 |
| 最近の再生履歴を取得します。 |
含まれていません(v1): BPM ベースのレコメンデーション。YouTube Music はテンポデータを公開していないため、これには別のデータソース(例:オーディオ分析 API)が必要になります。これは将来のバージョンでのストレッチゴールであり、今回のビルドには含まれていません。
Related MCP server: mcp-server-youtube
セットアップ
1. 依存関係のインストール
python3 -m venv .venv
source .venv/bin/activate
pip install -e .2. 認証
公式の YouTube Music API は存在しないため、ytmusicapi はログイン済みのブラウザセッションのヘッダーを再利用して認証を行います。
ログインした状態で Firefox(推奨 – 生ヘッダーのコピーが Chrome よりも信頼性が高い)で music.youtube.com を開きます。
DevTools(
Cmd+Option+I/F12)→ Network タブ →browseでフィルタリングします。プレイリストをクリックするか、ページをリロードして、
browsePOST リクエストをトリガーします。そのリクエストをクリック → Headers タブ → Raw headers に切り替え → ブロック全体を選択してコピーします。
それをプロジェクトルートに
raw_headers.txtという名前の新しいファイルに貼り付けて保存します。以下を実行します:
python scripts/setup_auth_from_file.pyこれにより、
headers_auth.jsonが書き込まれ、raw_headers.txtが削除されます。
または、python scripts/setup_auth.py は、ファイルの代わりにインタラクティブなターミナルプロンプトを介して同じことを行います(直接貼り付けたい場合に便利です)。
headers_auth.json はログイン済みセッションと同等です – これをコミットしたり共有したりしないでください。 すでに gitignore されています。
先に進む前に認証が機能することを確認してください:
python scripts/test_search.pyこれらのヘッダーは定期的に期限切れ/ローテーションします。認証エラーでツールが失敗し始めた場合は、この手順をやり直してください。
3. Claude Code に追加
claude mcp add ytmusic -s user \
-e YTMUSIC_AUTH_PATH="$(pwd)/headers_auth.json" \
-- "$(pwd)/.venv/bin/python" "$(pwd)/server.py"-s user を指定すると、このディレクトリだけでなく、任意の Claude Code セッションで使用できるようになります。サーバーは任意の作業ディレクトリから起動できるため、python インタプリタ、server.py、YTMUSIC_AUTH_PATH には絶対パスを使用してください。
他の MCP クライアント(Claude Desktop など)の場合は、それぞれの設定形式を使用して、同じコマンドと環境変数を指定します。
エラーハンドリング
ツールコールは、一般的な障害モードを生のトレースバックではなく、明確なメッセージに変換します:
認証情報の欠落/期限切れ/不正 →
scripts/setup_auth_from_file.pyを再実行するように指示します。レート制限(HTTP 429) → 待ってから再試行するように指示します。
ゲート/制限付きコンテンツ → クラッシュする代わりに利用不可として報告します。
ネットワークエラー → 直接報告します。
ライセンス
MIT – LICENSE を参照してください。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Flicense-qualityDmaintenanceEnables users to search the YouTube Music catalog and manage playlists using natural language. It provides tools for searching songs, albums, and artists, as well as performing playlist operations like creating, adding, and deleting tracks.
- Alicense-qualityCmaintenanceEnables AI assistants to search videos, read channels, browse playlists, fetch comments, and get transcripts from YouTube using the YouTube Data API v3 and InnerTube API for captions.2GPL 3.0
- Flicense-qualityCmaintenanceEnables AI assistants to search videos, channels, and playlists, retrieve video metadata, transcripts, and comments via the YouTube Data API v3.73
- Flicense-qualityFmaintenanceEnables AI assistants to search YouTube Music, manage playlists, and create smart recommendations using natural language.10
Related MCP Connectors
YouTube MCP — wraps the YouTube Data API v3 (BYO API key)
Provide token-optimized, structured YouTube data to enhance your LLM applications. Access efficien…
YouTube transcripts, subtitles, and video metadata as structured JSON via an Apify Actor.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/umsachde/ytmusic-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server