ytmusic-mcp
ytmusic-mcp
Un servidor MCP que envuelve ytmusicapi para que Claude (o cualquier cliente MCP) pueda buscar en YouTube Music, gestionar tus listas de reproducción y leer tu historial de escucha.
Herramientas
Herramienta | Descripción |
| Buscar en YouTube Music. |
| Listar tus listas de reproducción de la biblioteca. |
| Obtener las pistas de una lista de reproducción. |
| Crear una nueva lista de reproducción privada, devuelve su ID. |
| Añadir una pista a una lista de reproducción. |
| Obtener tu historial de reproducción reciente. |
No incluido (v1): Recomendaciones basadas en BPM. YouTube Music no expone datos de tempo, por lo que se necesitaría una segunda fuente de datos (por ejemplo, una API de análisis de audio) — un objetivo a largo plazo para una versión futura, no parte de esta versión.
Related MCP server: mcp-server-youtube
Configuración
1. Instalar dependencias
python3 -m venv .venv
source .venv/bin/activate
pip install -e .2. Autenticación
No existe una API oficial de YouTube Music, por lo que ytmusicapi se autentica reutilizando las cabeceras de tu sesión de navegador iniciada.
Abre music.youtube.com en Firefox (recomendado — su copia de cabeceras sin procesar es más fiable que la de Chrome) mientras estás conectado.
Abre DevTools (
Cmd+Option+I/F12) → pestaña Red → filtra porbrowse.Haz clic en una lista de reproducción, o recarga la página, para activar una solicitud POST de
browse.Haz clic en esa solicitud → pestaña Encabezados → activa Encabezados sin procesar → selecciona y copia todo el bloque.
Pégalo en un nuevo archivo llamado
raw_headers.txten la raíz del proyecto y guárdalo.Ejecuta:
python scripts/setup_auth_from_file.pyEsto escribe
headers_auth.jsony eliminaraw_headers.txt.
Alternativamente, python scripts/setup_auth.py hace lo mismo mediante un prompt interactivo en la terminal en lugar de un archivo, si prefieres pegar directamente.
headers_auth.json equivale a tu sesión iniciada — nunca lo subas al control de versiones ni lo compartas. Ya está en .gitignore.
Verifica que la autenticación funciona antes de continuar:
python scripts/test_search.pyEstas cabeceras caducan/rotan periódicamente. Si las herramientas empiezan a fallar con un error de autenticación, repite este paso.
3. Añadir a 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 lo hace disponible en cualquier sesión de Claude Code, no solo en este directorio. Usa rutas absolutas para el intérprete de Python, server.py y YTMUSIC_AUTH_PATH, ya que el servidor puede lanzarse desde cualquier directorio de trabajo.
Para otros clientes MCP (Claude Desktop, etc.), apúntalos al mismo comando y variable de entorno usando su formato de configuración respectivo.
Manejo de errores
Las llamadas a herramientas traducen modos de fallo comunes en mensajes claros en lugar de trazas de error sin procesar:
Autenticación faltante/caducada/incorrecta → te indica que vuelvas a ejecutar
scripts/setup_auth_from_file.py.Límite de velocidad (HTTP 429) → te indica que esperes y lo intentes de nuevo.
Contenido restringido/bloqueado → se informa como no disponible en lugar de fallar.
Errores de red → se informan directamente.
Licencia
MIT — ver 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.
YouTube transcripts, search, channel/playlist listings and upload tracking for AI agents.
Search YouTube, read video metadata, and fetch transcripts with language preferences
YouTube discovery, transcripts, library search, and monitors with API keys or OAuth.
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.31 PyPI71MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to search YouTube Music, manage playlists, and create smart recommendations using natural language.14-