ytmusic-mcp
Provides tools for searching YouTube Music and managing playlists, including creating, deleting, renaming, adding/removing tracks, and reordering tracks.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ytmusic-mcpSearch for 'chill piano' and add the top 5 results to a new playlist called 'Relax'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
YouTube Music MCP Server (personal, single-user)
An MCP server wrapping ytmusicapi so Claude (and optionally ChatGPT) can
search YouTube Music and manage playlists: create/delete, add/remove tracks,
reorder tracks (top/bottom/before another track).
Scope of this setup: built for exactly one user (you), hosted on your own Ubuntu box, reachable only with a secret bearer token. Recommended to run against a secondary Google account, not your main one, since a leaked token means full playlist read/write access to whatever account is authenticated.
1. Install
pip install -r requirements.txtRelated MCP server: mcp-ytmusic
2. Auth against YouTube Music (secondary account)
Log into your secondary Gmail/YouTube account in the browser you use for this, then run:
python3 setup_auth.pyFollow the printed steps (DevTools → Network tab → copy request headers
from a music.youtube.com request). This writes browser.json, which
server.py reads automatically. Cookie-based auth can go stale — re-run
this if tools start failing.
Paste the headers, then press Enter on one additional empty line. Firefox's structured request-header JSON export is also accepted. This project uses browser-cookie authentication only; OAuth credentials are rejected.
3. Local test (optional, before deploying)
python3 -c "from server import get_client; print(get_client().get_library_playlists(limit=5))"4. Deploy on your Ubuntu server
4.1 Copy the project over
sudo mkdir -p /opt/ytmusic-mcp
sudo cp server.py requirements.txt /opt/ytmusic-mcp/
sudo cp browser.json /opt/ytmusic-mcp/ # the file setup_auth.py made
cd /opt/ytmusic-mcp
sudo pip install -r requirements.txt --break-system-packages4.2 Configure
sudo cp .env.example /opt/ytmusic-mcp/.env
openssl rand -hex 32 # generate your token
sudo nano /opt/ytmusic-mcp/.env # paste it into MCP_BEARER_TOKENLeave MCP_HOST=127.0.0.1 — the app must never bind directly to the public
interface. nginx is the only thing facing the internet.
4.3 Run as a systemd service
sudo cp ytmusic-mcp.service /etc/systemd/system/
sudo nano /etc/systemd/system/ytmusic-mcp.service # set User= to your linux user
sudo systemctl daemon-reload
sudo systemctl enable --now ytmusic-mcp
sudo systemctl status ytmusic-mcp
journalctl -u ytmusic-mcp -f # tail logs4.4 nginx — only port 443, only path /mcp
sudo apt install nginx certbot python3-certbot-nginx
sudo cp nginx-ytmusic-mcp.conf /etc/nginx/sites-available/ytmusic-mcp
sudo nano /etc/nginx/sites-available/ytmusic-mcp # replace mcp.yourdomain.com
sudo ln -s /etc/nginx/sites-available/ytmusic-mcp /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d mcp.yourdomain.com # gets the TLS cert, edits the configYou need a domain/subdomain pointed at your server's public IP (any DNS A record works), and ports 80+443 open in your firewall. Port 80 exists only to redirect to HTTPS and serve certbot's renewal challenge — nothing else is served there.
This config makes only /mcp reachable; every other path (/,
/admin, /.env, etc.) returns a bare 404 before hitting your app at all.
It also rate-limits requests (30/min, burst 10) to blunt brute-force/scan
traffic.
4.5 fail2ban — auto-ban repeat offenders
sudo apt install fail2ban
sudo cp fail2ban-filter-ytmusic-mcp.conf /etc/fail2ban/filter.d/ytmusic-mcp.conf
sudo cp fail2ban-jail-ytmusic-mcp.conf /etc/fail2ban/jail.d/ytmusic-mcp.conf
sudo systemctl restart fail2ban
sudo fail2ban-client status ytmusic-mcp # confirm the jail is activeAny IP racking up 5 unauthorized/probing requests in 10 minutes gets banned for 24h.
4.6 Verify from outside
curl -i https://mcp.yourdomain.com/mcp # expect 401 (reachable, but locked)
curl -i https://mcp.yourdomain.com/anything # expect 404 (nothing else exposed)Your MCP endpoint: https://mcp.yourdomain.com/mcp
5. Connect from Claude.ai
Settings → Connectors → Add custom connector.
URL:
https://mcp.yourdomain.com/mcpAdvanced settings → add header:
Authorization: Bearer <your MCP_BEARER_TOKEN>Save, then enable it in a conversation via + → Connectors.
6. Connect from ChatGPT
ChatGPT's remote-connector/custom-header support has been shifting between
plan tiers and connector types — worth checking OpenAI's current docs for
the exact click path when you get there. The server side doesn't change:
it's a standard endpoint at https://mcp.yourdomain.com/mcp expecting
Authorization: Bearer <token>. If their UI doesn't support custom headers
for a given connector type, that combination just won't work until it does
— nothing to fix on your end in that case.
Security summary
Token is the only thing standing between the internet and your YouTube account (via
browser.json) — treat it like a root password.App binds
127.0.0.1only; nginx is the sole public-facing surface, and only exposes/mcpon:443.Rate limiting + fail2ban blunt scanning/brute-force attempts.
Using a secondary Google account caps the blast radius of a leak to that account's playlists, not your main one.
Rotate the token any time you suspect exposure: regenerate, update
.env,sudo systemctl restart ytmusic-mcp.browser.jsoncan expire — re-runsetup_auth.py(on your dev machine, then re-copy to the server) if calls start failing with auth errors.
Tools exposed
Tool | What it does |
| Search songs/videos/albums/artists/playlists |
| List your playlists |
| Get a playlist's tracks (includes |
| Create a new playlist |
| Delete a playlist |
| Edit title/description/privacy |
| Add tracks by videoId, optionally to the top |
| Remove tracks by setVideoId |
| Move a track before another track, or to the end |
| Move a track to position 1 |
| Move a track to the last position |
ID note: videoId identifies a song (used to add); setVideoId
identifies one occurrence of a track inside a playlist (used to remove
or reorder, since the same song can appear twice with different
setVideoIds). You never need to look these up manually — ask by song name
and the assistant calls get_playlist first to resolve the right ID.
This server cannot be installed
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
- Alicense-qualityDmaintenanceEnables interaction with Spotify through natural language for music discovery, playback control, library management, and playlist creation. Supports searching for music, controlling playback, managing saved tracks, and getting personalized recommendations based on mood and preferences.1165MIT
- 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.
- Flicense-qualityFmaintenanceEnables AI assistants to search YouTube Music, manage playlists, and create smart recommendations using natural language.10
- Alicense-qualityDmaintenanceEnables AI assistants to search for music and create/manage playlists on YouTube Music via OAuth 2.0 authentication.1MIT
Related MCP Connectors
YouTube MCP — wraps the YouTube Data API v3 (BYO API key)
YouTube transcripts, subtitles, and video metadata as structured JSON via an Apify Actor.
Provide token-optimized, structured YouTube data to enhance your LLM applications. Access efficien…
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/imesh-madushan/ytmusic-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server