youtubemusic-mcp

codeRisshi25/youtubemusic-mcp

3.2

If you are the rightful owner of youtubemusic-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

The YouTube Music MCP Server connects YouTube Music to AI assistants like Claude, enabling music library access and management through natural language conversations.

Tools
7
Resources
0
Prompts
0

YouTube Music MCP Server

A powerful Model Context Protocol (MCP) server that connects YouTube Music to AI assistants like Claude. Access your music library, get recommendations, search for songs, create playlists, and discover new music through natural language conversations.

Python License MCP

FeaturesInstallationAuthenticationUsageTools


Features

7 powerful tools for music discovery and library management:

  • 🎵 get_liked_songs_count - Get total count of liked songs
  • 📊 get_library_stats - Comprehensive library statistics (songs, playlists, artists, albums)
  • 🔍 search_music - Search for songs, artists, albums, or playlists
  • 🎤 get_top_artists - Most played artists from listening history
  • 🎧 find_similar_songs - Discover similar tracks
  • get_recommendations - Personalized music recommendations
  • 📝 create_playlist_from_songs - Create playlists from song queries

Installation

Prerequisites

  • Python 3.10 or higher
  • A YouTube Music account
  • Browser developer tools access (for authentication)

Setup

  1. Clone the repository
git clone https://github.com/codeRisshi25/youtubemusic-mcp.git
cd youtubemusic-mcp
  1. Create virtual environment
python3 -m venv venv
source venv/bin/activate  # Linux/macOS
# OR
venv\Scripts\activate     # Windows
  1. Install dependencies
pip install -e .

Authentication

Choose one authentication method:

Option A: Browser Cookies (Recommended)

  1. Visit music.youtube.com and log in
  2. Open Developer Tools (F12)
  3. Go to Network tab and refresh the page
  4. Find any POST request to music.youtube.com
  5. Right-click → Copy → Copy as cURL
  6. Extract the cookie string
  7. Run setup:
python3 -c "
from ytmusicapi import setup
headers_raw = '''PASTE YOUR HEADERS HERE'''
setup(filepath='browser.json', headers_raw=headers_raw)
"

Note: Cookies may expire after 6-12 months. See for simple update instructions.

Option B: OAuth (Long-term)

See for complete OAuth setup instructions.


Usage

Test with MCP Inspector

npx @modelcontextprotocol/inspector venv/bin/python server.py

Opens web interface at http://localhost:6274 to test all tools.

Claude Desktop Integration

  1. Config file location:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • Linux: ~/.config/Claude/claude_desktop_config.json
  2. Add configuration:

{
  "mcpServers": {
    "youtube-music": {
      "command": "/path/to/venv/bin/python",
      "args": ["/path/to/server.py"]
    }
  }
}
  1. Restart Claude Desktop

See for detailed instructions.


Available Tools

ToolDescription
get_liked_songs_countGet total count of your liked songs
get_library_statsComprehensive library statistics (songs, playlists, artists, albums)
search_musicSearch for songs, artists, albums, or playlists
get_top_artistsGet your most played artists from listening history
find_similar_songsDiscover songs similar to any track
get_recommendationsGet personalized music recommendations
create_playlist_from_songsCreate playlists from song queries

Troubleshooting

Authentication Errors

If you get authentication errors after ~6 months:

  1. Your cookies have likely expired
  2. Follow the simple update process in
  3. You'll just need to paste fresh cookies from your browser

Server Not Detected in Claude

  • Use absolute paths in claude_desktop_config.json
  • Restart 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.json or oauth.json exists
  • Check file permissions
  • See for detailed troubleshooting

Contributing

See for contribution guidelines.


License

MIT License - see

Copyright (c) 2025 Risshi Raj Sen


Links


Built with ytmusicapiMCP

⭐ Star if useful!