ytmusic-mcp
ytmusic-mcp
ytmusicapi를 감싸는 MCP 서버입니다. Claude(또는 모든 MCP 클라이언트)가 YouTube Music을 검색하고, 플레이리스트를 관리하며, 청취 기록을 읽을 수 있습니다.
도구
도구 | 설명 |
| YouTube Music을 검색합니다. |
| 내 라이브러리 플레이리스트를 나열합니다. |
| 플레이리스트의 트랙을 가져옵니다. |
| 새로운 비공개 플레이리스트를 만들고 ID를 반환합니다. |
| 플레이리스트에 트랙을 추가합니다. |
| 최근 재생 기록을 가져옵니다. |
포함되지 않음(v1): BPM 기반 추천. YouTube Music은 템포 데이터를 노출하지 않으므로 두 번째 데이터 소스(예: 오디오 분석 API)가 필요합니다. 이는 향후 버전의 목표이며, 현재 빌드에는 포함되지 않습니다.
Related MCP server: mcp-server-youtube
설정
1. 의존성 설치
python3 -m venv .venv
source .venv/bin/activate
pip install -e .2. 인증
공식 YouTube Music API가 없으므로 ytmusicapi는 로그인된 브라우저 세션의 헤더를 재사용하여 인증합니다.
music.youtube.com을 Firefox(권장 — Chrome보다 원시 헤더 복사가 더 안정적임)에서 로그인 상태로 엽니다.
개발자 도구 열기 (
Cmd+Option+I/F12) → 네트워크 탭 →browse로 필터링.플레이리스트를 클릭하거나 페이지를 새로고침하여
browsePOST 요청을 트리거합니다.해당 요청을 클릭 → 헤더 탭 → 원시 헤더 전환 → 전체 블록을 선택하여 복사합니다.
프로젝트 루트에
raw_headers.txt라는 새 파일에 붙여넣고 저장합니다.다음을 실행합니다:
python scripts/setup_auth_from_file.py이렇게 하면
headers_auth.json이 작성되고raw_headers.txt가 삭제됩니다.
또는 python scripts/setup_auth.py를 실행하면 파일 대신 대화형 터미널 프롬프트를 통해 동일한 작업을 수행하므로 직접 붙여넣을 수 있습니다.
headers_auth.json은 로그인된 세션과 동일하므로 절대 커밋하거나 공유하지 마세요. 이미 gitignore에 포함되어 있습니다.
계속 진행하기 전에 인증이 작동하는지 확인합니다:
python scripts/test_search.py이 헤더는 주기적으로 만료/교체됩니다. 도구가 인증 오류와 함께 실패하기 시작하면 이 단계를 다시 수행하세요.
3. 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를 사용하면 이 디렉토리뿐만 아니라 모든 Claude Code 세션에서 사용할 수 있습니다. python 인터프리터, server.py, YTMUSIC_AUTH_PATH에는 절대 경로를 사용하세요. 서버가 어떤 작업 디렉토리에서도 실행될 수 있기 때문입니다.
다른 MCP 클라이언트(Claude Desktop 등)의 경우, 각각의 구성 형식을 사용하여 동일한 명령어와 환경 변수를 가리키도록 설정하세요.
오류 처리
도구 호출은 일반적인 실패 모드를 원시 추적 대신 명확한 메시지로 변환합니다:
인증 누락/만료/손상 →
scripts/setup_auth_from_file.py를 다시 실행하라고 안내합니다.속도 제한(HTTP 429) → 기다렸다가 다시 시도하라고 안내합니다.
차단/제한된 콘텐츠 → 충돌 대신 사용할 수 없다고 보고합니다.
네트워크 오류 → 직접 보고합니다.
라이선스
MIT — 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-