YouTube Music MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
YouTube Music MCP Server
A production-grade Model Context Protocol (MCP) server that connects YouTube Music to AI assistants like Claude.
Implements the full MCP primitive set — Tools, Resources, and Prompts — for genuine agentic music experiences.
Architecture • Features • Installation • Authentication • Usage • Tools • Resources • Prompts
Architecture
┌────────────────────────────────────────────────────────────┐
│ Claude / AI Assistant │
└──────────────────────┬─────────────────────────────────────┘
│ Model Context Protocol (stdio)
┌──────────────────────▼─────────────────────────────────────┐
│ YouTube Music MCP Server v2 │
│ │
│ ┌─────────────┐ ┌───────────────┐ ┌──────────────────┐ │
│ │ 15 Tools │ │ 3 Resources │ │ 3 Prompts │ │
│ │ │ │ │ │ │ │
│ │ search │ │library:// │ │weekly-discovery │ │
│ │ stats │ │ songs │ │mood-based- │ │
│ │ similar ★ │ │ artists │ │ playlist │ │
│ │ recommend ★ │ │ playlists │ │artist-deep-dive │ │
│ │ smart pl ★ │ └───────────────┘ └──────────────────┘ │
│ │ charts │ │
│ │ insights │ ┌───────────────────────────────────┐ │
│ │ moods │ │ TTL Cache (5 min) • Async ★ │ │
│ │ ... │ │ Custom Exceptions • Logging │ │
│ └─────────────┘ └───────────────────────────────────┘ │
└──────────────────────┬─────────────────────────────────────┘
│ ytmusicapi
┌──────────────────────▼─────────────────────────────────────┐
│ YouTube Music API │
└────────────────────────────────────────────────────────────┘
★ = Agentic / async featureRelated MCP server: ytm-mcp
Features
15 Tools · 3 Resources · 3 Prompts — full MCP primitive coverage:
🛠️ Tools
Tool | Description |
| Total song count (bypasses YT display limit) |
| Songs, artists, playlists + detailed breakdown |
| Search with type filter (songs/albums/artists/playlists/videos) |
| Ranked artists with visual progress bars |
| Real YTMusic radio engine — not a fake artist search |
| Async-parallel fetch across top 5 artists |
| Create & populate playlist from search queries |
| All your playlists with IDs and song counts |
| Browse songs in any playlist |
| Add songs to existing playlist |
| Agentic 6-step pipeline: mood→category→tracks→filter→save |
| Discover all YTMusic Moods & Genres categories |
| Global or country-specific trending charts |
| History analysis: patterns, diversity score, insights |
| Auth method, cache state, version, capabilities |
📦 Resources (passively readable by Claude)
Resource URI | Description |
| Full library as structured JSON |
| Artist rankings with percentages |
| All playlists as structured JSON |
💬 Prompts (guided conversation starters)
Prompt | Description |
| Guided weekly music discovery workflow |
| Collaborative mood → playlist session |
| Full artist exploration + listening plan |
Installation
Prerequisites
Python 3.10 or higher
A YouTube Music account
Browser developer tools access (for authentication)
Setup
Clone the repository
git clone https://github.com/codeRisshi25/youtubemusic-mcp.git
cd youtubemusic-mcpCreate virtual environment
python3 -m venv venv
source venv/bin/activate # Linux/macOS
# OR
venv\Scripts\activate # WindowsInstall dependencies
pip install -e .Authentication
Choose one authentication method:
Option A: Cookie File (Simplest — recommended)
Visit music.youtube.com and log in
Open Developer Tools (
F12)Go to Network tab and refresh the page
Click any request → Headers → copy the full
cookie:valuePaste it into a file named
cookie.txtin the project directoryDone! The server auto-generates
browser.jsonon first startup
# Optional: validate cookies before starting the server
python update_auth.pyNote: Cookies typically last 6–24 months. When they expire, just paste fresh cookies into cookie.txt and restart.
Option B: OAuth (Long-term)
See docs/OAUTH_SETUP.md for complete OAuth setup instructions.
Usage
Test with MCP Inspector
npx @modelcontextprotocol/inspector venv/bin/python server.pyOpens web interface at http://localhost:6274 to test all 15 tools, 3 resources, and 3 prompts.
Claude Desktop Integration
Config file location:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
Add configuration:
{
"mcpServers": {
"youtube-music": {
"command": "/path/to/venv/bin/python",
"args": ["/path/to/server.py"]
}
}
}Restart Claude Desktop
See docs/CLAUDE_SETUP.md for detailed instructions.
Available Tools
See the Features section above for a full table of all 15 tools.
Agentic Highlights
build_smart_playlist — the centrepiece agentic tool. Runs a 6-step pipeline inside a single tool call:
Step 1: Fetch all Moods & Genres from YouTube Music
Step 2: Match your mood keyword to a real category
Step 3: Pull mood playlist pool from that category
Step 4: Sample tracks across multiple playlists
Step 5: Apply energy-level filter (high/medium/low)
Step 6: Optionally create & save to YouTube Musicfind_similar_songs — uses get_watch_playlist(radio=True), the actual YTMusic similarity engine, not a fake artist search.
get_recommendations — fetches from 5 artists using asyncio.gather() for true parallel execution.
Running Tests
pip install -e ".[dev]"
pytest tests/ -v51 tests covering auth, caching, all tools, resources, prompts, and routing — no network required (fully mocked).
Troubleshooting
Authentication Errors
If you get authentication errors after ~6 months:
Your cookies have likely expired
Follow the simple update process in docs/AUTH_UPDATE.md
You'll just need to paste fresh cookies from your browser
Server Not Detected in Claude
Use absolute paths in
claude_desktop_config.jsonRestart Claude Desktop after config changes
Check logs in Claude → Help → View Logs
Import Errors
Ensure virtual environment is activated
Run
pip install -e .in the project directory
Server Crashes on Startup
Verify
browser.jsonoroauth.jsonexistsCheck file permissions
See docs/CLAUDE_SETUP.md for detailed troubleshooting
Contributing
See docs/CONTRIBUTING.md for contribution guidelines.
License
MIT License - see LICENSE
Copyright (c) 2025 Risshi Raj Sen
Links
Built with ytmusicapi • MCP
⭐ Star if useful!
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
YouTube transcripts, search, channel browsing, and playlists for AI agents via MCP.
MCP server for Producer/Riffusion AI music generation
MCP server connecting AI agents to 100+ apps (Gmail, Slack, Notion, GitHub) via one-click OAuth.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Related MCP Servers
- AlicenseBqualityDmaintenanceA simple MCP server that allows AI assistants like Cursor or Claude Desktop to search for and play tracks on YouTube Music through natural language commands.219 npm13MIT
- AlicenseNot gradedqualityDmaintenanceA full-featured YouTube Music MCP server that lets AI assistants control playback, browse history, download songs, and manage playlists via natural language.1ISC
- AlicenseAqualityDmaintenanceA production-ready MCP server for YouTube integration with intelligent caching. Enables searching videos, retrieving transcripts, analyzing channels, and monitoring live streams via natural language.311MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables AI applications to search YouTube music videos and manage playlists via the YouTube Data API v3, with OAuth support for playlist and subscription management.3MIT