ytm-mcp
Provides full control over YouTube Music, including playback, history, downloads, playlists, and search.
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., "@ytm-mcpWhat were my last 12 songs?"
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.
What is ytm-mcp?
ytm-mcp is a Model Context Protocol (MCP) server that gives AI assistants full control over YouTube Music. Connect it to Claude, Cursor, VS Code, or any MCP-compatible tool and control your music with natural language.
"What were my last 12 songs?"
"Download all my recent history as opus files"
"Play Stars Ultra Slowed and like it"
"Skip to the next track and turn the volume to 70"
"Create a playlist called Night Drive from my history"✨ Features
Category | What you get |
🎧 History | Scrape your full listening history with titles, artists, albums & URLs |
🔍 Search | Search YouTube Music for any song, artist, or album |
▶️ Playback | Play, pause, skip, seek, volume, like, shuffle, repeat |
📥 Downloads | Download songs as Opus or MP3 via yt-dlp with embedded metadata & thumbnails |
📋 Playlists | Create, edit, export local playlists as JSON or CSV |
💾 Database | SQLite persistence — history, downloads, playlists all cached locally |
🛠 Requirements
Node.js 18+
yt-dlp — for downloading songs
Python mutagen — for embedding metadata:
pip install mutagenChrome or Chromium — must be logged into YouTube Music
🚀 Installation
# 1. Clone the repo
git clone https://github.com/4shil/ytm-mcp.git
cd ytm-mcp
# 2. Install dependencies
npm install
# 3. Build
npm run build
# 4. Configure
cp .env.example .envFind your Chrome profile path
This is the folder where your browser stores your logged-in session.
Platform | Path |
Linux (Chrome) |
|
Linux (Chromium) |
|
macOS (Chrome) |
|
Windows (Chrome) |
|
⚠️ The profile must already be logged into YouTube Music. The server won't handle login — just reuse your existing session.
.env Configuration
# Your Chrome/Chromium profile path (see table above)
BROWSER_PROFILE=/path/to/your/chrome-profile
# Where downloaded songs are saved
DOWNLOAD_DIR=./downloads
# SQLite database location
DB_PATH=./db/ytm.db🔌 Connect to Your AI Tool
mcporter CLI
Install mcporter and register ytm-mcp:
npm install -g mcporter
mcporter config add ytm-mcp --stdio "node /path/to/ytm-mcp/dist/index.js"List all tools:
mcporter list ytm-mcpCall tools directly from your terminal:
mcporter call ytm-mcp.get_history limit=12
mcporter call ytm-mcp.search_song query="Stars Ultra Slowed"
mcporter call ytm-mcp.download_song url="https://music.youtube.com/watch?v=4Z8LwuQ3zao"
mcporter call ytm-mcp.playback_control action=like
mcporter call ytm-mcp.get_current_songClaude Desktop
Edit claude_desktop_config.json:
Linux:
~/.config/Claude/claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"ytm-mcp": {
"command": "node",
"args": ["/path/to/ytm-mcp/dist/index.js"],
"env": {
"BROWSER_PROFILE": "/path/to/your/chrome-profile"
}
}
}
}Restart Claude Desktop. You'll see ytm-mcp in the tools list. ✅
OpenClaw
Add to ~/.openclaw/config.json:
{
"mcp": {
"servers": [
{
"name": "ytm-mcp",
"command": "node",
"args": ["/path/to/ytm-mcp/dist/index.js"],
"env": {
"BROWSER_PROFILE": "/path/to/your/chrome-profile"
}
}
]
}
}Or with mcporter:
mcporter add ytm-mcp --command "node /path/to/ytm-mcp/dist/index.js"Cursor
Create or edit ~/.cursor/mcp.json:
{
"mcpServers": {
"ytm-mcp": {
"command": "node",
"args": ["/path/to/ytm-mcp/dist/index.js"],
"env": {
"BROWSER_PROFILE": "/path/to/your/chrome-profile"
}
}
}
}Antigravity
Create mcp.json in the Antigravity user config directory:
Linux:
~/.config/Antigravity/User/mcp.jsonmacOS:
~/Library/Application Support/Antigravity/User/mcp.jsonWindows:
%APPDATA%\Antigravity\User\mcp.json
{
"servers": {
"ytm-mcp": {
"type": "stdio",
"command": "node",
"args": ["/path/to/ytm-mcp/dist/index.js"],
"env": {
"BROWSER_PROFILE": "/path/to/your/chrome-profile"
}
}
}
}Reload Antigravity (Ctrl+Shift+P → Developer: Reload Window). ✅
VS Code (GitHub Copilot)
Create .vscode/mcp.json in your workspace:
{
"servers": {
"ytm-mcp": {
"type": "stdio",
"command": "node",
"args": ["/path/to/ytm-mcp/dist/index.js"],
"env": {
"BROWSER_PROFILE": "/path/to/your/chrome-profile"
}
}
}
}Zed
Add to ~/.config/zed/settings.json:
{
"context_servers": {
"ytm-mcp": {
"command": {
"path": "node",
"args": ["/path/to/ytm-mcp/dist/index.js"],
"env": {
"BROWSER_PROFILE": "/path/to/your/chrome-profile"
}
}
}
}
}Continue.dev
Add to ~/.continue/config.json:
{
"experimental": {
"modelContextProtocolServers": [
{
"transport": {
"type": "stdio",
"command": "node",
"args": ["/path/to/ytm-mcp/dist/index.js"],
"env": {
"BROWSER_PROFILE": "/path/to/your/chrome-profile"
}
}
}
]
}
}Any MCP Tool (Generic)
ytm-mcp uses standard stdio transport. Any MCP-compatible tool can connect:
Transport: stdio
Command: node
Args: ["/path/to/ytm-mcp/dist/index.js"]🧰 Tools Reference
🎧 History
get_history
Scrape your YouTube Music listening history.
Parameter | Type | Default | Description |
| number |
| Number of songs to fetch |
| boolean |
| Return cached DB results (no browser) |
get_history(limit: 12)
get_history(limit: 50, use_cache: true)🔍 Search & Download
search_song
Search YouTube Music for songs.
Parameter | Type | Default | Description |
| string | required | Song, artist, or album name |
| number |
| Max results to return |
download_song
Download a single song by URL.
Parameter | Type | Default | Description |
| string | required | YouTube Music URL |
| string |
|
|
| string | — | Optional title hint |
download_history
Batch download your recent listening history.
Parameter | Type | Default | Description |
| number |
| Songs to download |
| string |
|
|
list_downloads
List all downloaded files with sizes and timestamps.
▶️ Playback
play_song
Search and play a song, or play by direct URL.
Parameter | Type | Description |
| string | Search query (e.g. |
| string | Direct YouTube Music URL |
playback_control
Full playback control in one tool.
Action | Description |
| Resume playback |
| Pause playback |
| Toggle play/pause |
| Next track |
| Previous track |
| Toggle shuffle |
| Cycle repeat mode |
| Like current song ❤️ |
| Dislike current song |
| Set volume ( |
| Seek to seconds ( |
get_current_song
Get the current now-playing state.
▶️ Stars (Ultra Slowed) — SCXR SOUL ❤️
⏱ 0:42 / 1:46 | 🔊 80%📋 Playlists
create_playlist
Parameter | Type | Default | Description |
| string | required | Playlist name |
| string |
|
|
add_to_playlist
Parameter | Type | Description |
| string | Target playlist ID |
| array | Array of |
list_playlists
List all saved playlists.
export_playlist
Parameter | Type | Default | Description |
| string | required | Playlist to export |
| string |
|
|
🗺 Roadmap
These tools are planned for future releases. PRs welcome!
Tool | Description |
| View the current playback queue |
| Add a song to the queue without interrupting playback |
| Clear the current queue |
| Fetch lyrics for the current or any song |
| Get AI-recommended songs based on listening history |
| Get artist bio, top songs, and discography |
| Browse an album and list all tracks |
| Get trending songs and charts by region |
| Delete a specific song from your history |
| Download an entire playlist at once |
| Auto-pause playback after N minutes |
| Auto-generate a playlist based on mood, genre, or history |
📁 Project Structure
ytm-mcp/
├── src/
│ ├── index.ts # MCP server entry point & tool handlers
│ ├── db.ts # SQLite database setup & migrations
│ ├── browser/ # Playwright browser control
│ ├── history/ # YouTube Music history scraper
│ ├── downloader/ # yt-dlp search & download
│ ├── tools/ # Playback controls
│ ├── playlist/ # Playlist CRUD
│ └── api/ # YouTube Data API (optional)
├── downloads/ # Downloaded songs (gitignored)
├── db/ # SQLite database (gitignored)
├── dist/ # Compiled JS output
├── .env.example # Environment variable template
└── README.md❓ Troubleshooting
History returns empty
→ Make sure BROWSER_PROFILE points to a profile that's already logged into YouTube Music. Open it in Chrome/Chromium and sign in manually first.
Download fails with mutagen error
pip install mutagen --break-system-packagesPlayback controls don't work
→ YouTube Music must be open in the browser. Run play_song first to open it.
chromium not found
→ Install it: sudo apt install chromium or adjust BROWSER_PROFILE to point to Chrome.
Build errors
rm -rf dist node_modules
npm install
npm run build🤝 Contributing
Fork the repo
Create a feature branch:
git checkout -b feat/my-toolCommit your changes:
git commit -m 'feat: add get_queue tool'Push and open a PR
See the Roadmap for ideas on what to build next.
📄 License
MIT © 4shil
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
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/4shil/ytm-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server