ytmusic-mcp
This MCP server lets you search YouTube Music and manage playlists, history, and related listening data through natural-language tools.
Search music by query, with optional filters for songs, videos, albums, artists, playlists, community/featured playlists, profiles, podcasts, and episodes.
List your library playlists and fetch the tracks in any playlist.
Create private playlists, add tracks by video ID, remove tracks from playlists, and delete playlists you own (except the auto playlists LM/SE).
Read your recent YouTube Music play history.
Get a song's radio/autoplay queue and related-content sections for similarity signals.
Fetch lyrics and artist pages (top songs, albums, related artists).
Log out and revoke stored YouTube Music auth.
Allows searching YouTube Music, managing playlists, and reading listening history.
Click on "Deploy 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 'Bohemian Rhapsody' on YouTube Music"
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.
ytmusic-mcp
An MCP server that wraps ytmusicapi so Claude (or any MCP client) can search YouTube Music, manage your playlists, and read your listening history.
Tools
Tool | Description |
| Search YouTube Music. |
| List your library playlists. Omit |
| Get the tracks in a playlist. Omit |
| Create a new private playlist, returns its ID. |
| Add a track to a playlist. |
| Remove every occurrence of a track from a playlist by video ID. |
| Permanently delete a playlist you own. Refuses to touch the auto playlists |
| Get your recent play history. |
| Get the radio/autoplay queue for a song — one of two independent similarity signals. |
| Get "related content" sections for a song (the |
| Get a song's lyrics (the |
| Get an artist's page: top songs, albums, related artists. |
| Delete the local auth file, revoking this server's stored YouTube Music authorization. |
Other Claude Code projects on this machine (e.g. re-com) call these tools by spawning this server over MCP rather than talking to ytmusicapi/YouTube Music themselves — this is the only place YouTube Music credentials live.
Not included (v1): BPM-based recommendations. YouTube Music doesn't expose tempo data, so this would need a second data source (e.g. an audio analysis API) — a stretch goal for a future version, not part of this build.
Related MCP server: mcp-server-youtube
Setup
1. Install dependencies
python3 -m venv .venv
source .venv/bin/activate
pip install -e .2. Authenticate
There's no official YouTube Music API, so ytmusicapi authenticates by reusing headers from your logged-in browser session. Both methods below write the same headers_auth.json file, so you can switch between them freely.
Option A: Auto-extract from your browser (recommended)
Reads your existing YouTube Music session cookies straight from your browser's local storage — no DevTools, no copy-pasting.
pip install -e ".[browser-auth]"
python scripts/setup_auth_from_browser.py --browser firefox # or chrome, safari, edge, brave, opera, vivaldi, arcRequires being logged into music.youtube.com in that browser. Omit --browser to try every installed browser and use the first one with a valid session.
Notes:
Chrome/Edge/Brave/Opera/Vivaldi/Arc encrypt their cookie store; on macOS this may trigger a one-time Keychain permission prompt.
Some browsers lock their cookie database while running — close the browser first if extraction fails.
Option B: Manual header paste (fallback)
Use this if browser auto-extraction doesn't work for your setup.
Open music.youtube.com in Firefox (recommended — its raw-header copy is more reliable than Chrome's) while logged in.
Open DevTools (
Cmd+Option+I/F12) → Network tab → filter bybrowse.Click into a playlist, or reload the page, to trigger a
browsePOST request.Click that request → Headers tab → toggle Raw headers → select and copy the whole block.
Paste it into a new file named
raw_headers.txtin the project root and save.Run:
python scripts/setup_auth_from_file.pyThis writes
headers_auth.jsonand deletesraw_headers.txt.
Alternatively, python scripts/setup_auth.py does the same thing via an interactive terminal prompt instead of a file, if you prefer to paste directly.
headers_auth.json is equivalent to your logged-in session — never commit it or share it. It's already gitignored.
Verify auth works before going further:
python scripts/test_search.pyThese headers expire/rotate periodically. If tools start failing with an auth error, redo whichever setup option you used.
3. Add to 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 makes it available in any Claude Code session, not just this directory. Use absolute paths for the python interpreter, server.py, and YTMUSIC_AUTH_PATH since the server can be launched from any working directory.
For other MCP clients (Claude Desktop, etc.), point them at the same command and env var using their respective config format.
Testing
The unit test suite (tests/) runs against a hand-rolled fake YTMusic client — no network access or headers_auth.json needed:
pip install -e ".[dev]"
pytestscripts/test_search.py is a separate real-account smoke test, not part of the unit suite.
Error handling
Tool calls translate common failure modes into clear messages instead of raw tracebacks:
Missing/expired/malformed auth → tells you to redo the authenticate step (
scripts/setup_auth_from_browser.pyorscripts/setup_auth_from_file.py).Rate limiting (HTTP 429) → tells you to wait and retry.
Gated/restricted content → reported as unavailable rather than crashing.
Network errors → reported directly.
License
MIT — see LICENSE.
Available Tools
6 toolsadd_to_playlistC
Add a track to a playlist by video ID.
| Name | Required | Description | Default |
|---|---|---|---|
| video_id | Yes | ||
| playlist_id | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description must disclose behavioral traits. It indicates a mutation (add) but omits critical details: idempotency, duplicate handling, error conditions (e.g., playlist not found), access requirements, or side effects. This is insufficient for safe agent invocation.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence, which is concise. However, conciseness comes at the cost of completeness; a slightly longer description including a prerequisite or behavioral note would improve utility without being verbose.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (mutation, two required params, no annotations, sibling tools), the description is insufficiently complete. It fails to cover execution context (e.g., playlist existence, authentication) and does not leverage the presence of an output schema to reduce burden. Significant gaps remain.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It adds minimal meaning by stating 'by video ID' (hinting that video_id is the identifier) but does not explain the format, constraints, or how to obtain valid values. No additional context for playlist_id.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action (add a track to a playlist) and the key identifier (by video ID). It distinguishes the tool from siblings like create_playlist (creation) and get_playlists (listing). However, it does not specify prerequisites such as playlist ownership or authentication, which slightly weakens clarity.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives. The sibling tools are listed but not referenced, and there is no mention of cases where another tool (e.g., search_music to find a video_id first) might be needed beforehand.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
create_playlistC
Create a new private playlist and return its playlist ID.
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| description | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description must fully disclose behavioral traits. It states the tool creates a playlist and returns an ID, but omits important details: whether overwriting occurs for duplicate names, what happens on failure, authorization requirements, or if the playlist is truly private by default. The description leaves significant gaps for a mutation tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence of 9 words, front-loading the key action and output. It is concise and to the point, though it sacrifices some necessary detail. No filler or redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given 0% schema description coverage and no annotations, the description is far from complete. It does not explain return value contents beyond 'playlist ID' (output schema exists but description doesn't reference it), error cases, or side effects. For a tool creating a resource, this is insufficient.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, meaning the description adds no meaning to the two parameters—'name' and 'description' are listed but not explained. The description does not mention that 'name' is required or provide any guidance on format, length, or uniqueness. The baseline would be higher with good schema docs, but here description totally fails to compensate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('Create'), the resource ('a new private playlist'), and the result ('return its playlist ID'). It distinguishes itself from siblings like add_to_playlist or search_music, but does not specify the playlist is private by default or that the name is required—though that is implied by the schema.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit guidance is given on when to use this tool versus alternatives like get_playlists or add_to_playlist. It does not state prerequisites (e.g., must have account, must not exceed playlist limit) or when not to use it. The context of 'private' is a hint but insufficient for decision-making around usage.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_historyB
Get recent play history.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It only implies a read operation with a temporal filter ('recent'), but does not disclose side effects, authentication needs, rate limits, or pagination behavior. The single sentence leaves many important behavioral gaps.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, front-loaded imperative sentence: 'Get recent play history.' It is concise with no wasted words. While it could benefit from slightly more detail, it is not overly sparse to the point of being cryptic. It earns its place by clearly stating the tool's primary action.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given that there are no parameters and an output schema exists to describe return values, the description is minimally acceptable. However, it lacks completeness regarding the definition of 'recent', any implicit limits, and how the results are ordered. The agent may still need to infer these details from the output schema, leaving some uncertainty.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 0 parameters and schema_description_coverage is 100% (trivially). According to the rubric, 0 parameters sets a baseline of 4. The description cannot add parameter meaning beyond the schema, but it does not need to because there are none. This score is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'Get' and the resource 'recent play history'. It distinguishes the tool from siblings like search_music and get_playlists, as none of them deal with history. However, the description could be more specific about the type of history (e.g., playback, search) and the scope of 'recent'.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool vs its siblings. There is no mention of use cases, exclusions, or alternatives. The agent receives no contextual hints about selecting this tool over other retrieval or search tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_playlistsA
List your YouTube Music library playlists.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It only states 'List your YouTube Music library playlists', which is a minimal read operation. It does not mention authentication requirements, whether the list is paginated, or what happens if the library is empty. More transparency is needed for a tool with zero annotation coverage.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, front-loaded sentence of four words: 'List your YouTube Music library playlists.' Every word is meaningful, and there is no redundancy or wasted space. It is optimally concise.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's simplicity (zero parameters) and the presence of an output schema, the description is largely complete. It conveys the core action and scope. However, it could slightly improve by explicitly stating that it returns all playlists for the authenticated user, but this is not a critical gap.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has zero parameters, so schema coverage is effectively 100%. The description adds no parameter semantics (none needed). Baseline 3 applies as the description does not require additional parameter information, but it also does not add value beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb ('List') and resource ('your YouTube Music library playlists'), clearly distinguishing from siblings like 'create_playlist' or 'search_music'. It is unambiguous and directly states the tool's function.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies the tool is for retrieving all playlists, but it offers no explicit guidance on when to use this versus alternatives like 'get_playlist_tracks' (for a specific playlist's tracks) or 'search_music' (for searching beyond playlists). The purpose is clear, but the usage context is left inferred.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_playlist_tracksC
Get the tracks in a playlist.
| Name | Required | Description | Default |
|---|---|---|---|
| playlist_id | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description must disclose behavioral traits. It fails to mention whether the operation is read-only (likely), if authentication is required, or how it behaves with empty/paginated playlists. The one-line description does not add behavioral depth.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is very concise at one sentence. However, it could be slightly expanded to be more informative without losing brevity. As is, it is not verbose, but 'earns its place' only minimally.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given there is an output schema (providing some structure for results) and a single required parameter, the description still lacks completeness. It does not mention that the result likely includes track details, any sorting, or limits. For such a simple tool, the info gap is moderate.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description needs to compensate. However, it adds no meaning to the playlist_id parameter—no format, ownership context, or example. Given the small parameter count and that the schema provides a title, the description does not significantly enhance understanding.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('get') and the resource ('tracks in a playlist'). Although the name is somewhat self-explanatory, the description provides clarity without being vague. It distinguishes this tool from siblings like search_music or create_playlist, but does not explicitly highlight the distinction.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no guidance on when to use this tool versus alternatives like search_music (which might return tracks based on criteria) or get_playlists. No context is given about prerequisites (e.g., does the playlist need to exist?) or limitations.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_musicB
Search YouTube Music.
filter: one of songs, videos, albums, artists, playlists, community_playlists, featured_playlists, profiles, podcasts, episodes. Omit for a mixed search. Returns an empty list if there are no matches.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| query | Yes | ||
| filter | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'Returns an empty list if there are no matches,' which is useful. However, it does not mention whether the operation is read-only, any rate limits, or side effects. For a search tool, read-only is implied but not confirmed.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise at two sentences plus a list of filter values. It front-loads the main action. However, the filter options are presented as a run-on sentence, which could be clearer with better formatting (e.g., bullet points). Still, it is efficient and avoids unnecessary words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool has 3 parameters, no schema descriptions, no annotations, and an output schema (not shown), the description covers the filter parameter and the empty return case. It does not explain the 'limit' parameter or pagination behavior. The query parameter is obvious. The description is adequate but not complete for a new user.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must add meaning. It explains the 'filter' parameter in detail, listing valid values and the default behavior. It does not explain 'query' (self-explanatory) or 'limit' (not explained). This partially compensates for the schema gap, but one parameter is left undocumented.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states 'Search YouTube Music' which is a clear verb+resource combination. It lists filter options, adding specificity. However, it does not explicitly distinguish from sibling tools, though the sibling tools are all about playlists and history, making the distinction implicit. The purpose is clear but not fully elaborated.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides guidance on the filter parameter ('Omit for a mixed search') but does not explain when to use this tool versus alternatives like get_playlists or get_history. The intended use case is implied by the name, but no explicit when-to-use or when-not-to-use guidance is given.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
6 tool updates
v0.1.0- First observed
add_to_playlist - First observed
create_playlist - First observed
get_history - First observed
get_playlist_tracks - First observed
get_playlists - First observed
search_music
TDQS
Scored across 6 tools
Each tool targets a distinct action or resource: search, library playlists, playlist tracks, playlist creation, playlist modification, and history. No two tools have overlapping purposes, making selection unambiguous.
Tool names follow a consistent verb_noun pattern (search_music, get_playlists, get_playlist_tracks, create_playlist, add_to_playlist, get_history). The only minor deviation is 'add_to_playlist' instead of 'add_track_to_playlist', but the pattern is still clear.
With 6 tools, the number is well-scoped for a YouTube Music server that focuses on search, playlist management, and history. Each tool earns its place without being overwhelming or too sparse.
The set covers search, playlist CRUD (create, read tracks, add to), and history, but lacks tools for removing tracks from playlists, updating playlist metadata, or managing likes/ratings. This leaves some common music management workflows incomplete.
Maintenance
Related MCP Connectors
YouTube transcripts, search, channel browsing, and playlists for AI agents via MCP.
Search YouTube, read video metadata, and fetch transcripts with language preferences
YouTube discovery, transcripts, library search, and monitors with API keys or OAuth.
1YouTube transcripts, search, channel/playlist listings and upload tracking for AI agents. No signup.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables 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.-
- AlicenseNot gradedqualityCmaintenanceEnables 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
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to search videos, channels, and playlists, retrieve video metadata, transcripts, and comments via the YouTube Data API v3.71MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to search YouTube Music, manage playlists, and create smart recommendations using natural language.13-