{
  "markdown": "# ytdl-rmcp\n\n[![npm version](https://img.shields.io/npm/v/ytdl-rmcp.svg)](https://www.npmjs.com/package/ytdl-rmcp)\n[![release](https://github.com/dinglebear-ai/rytdl/actions/workflows/release.yml/badge.svg)](https://github.com/dinglebear-ai/rytdl/actions/workflows/release.yml)\n[![CI](https://github.com/dinglebear-ai/rytdl/actions/workflows/ci.yml/badge.svg)](https://github.com/dinglebear-ai/rytdl/actions/workflows/ci.yml)\n\nyt-dlp search, download, metadata, delivery, and Plex workflows over MCP and CLI.\n\nWritten in Rust on the [`rmcp`](https://crates.io/crates/rmcp) crate. **yt-dlp\nand ffmpeg are auto-downloaded** into a per-user cache on first run, so the host\nneeds neither pre-installed — the one binary is the whole install.\n\n**30-second path:** `npx -y @dinglebear/rytdl setup` -> configure a target path ->\ncall `youtube_search` or `youtube_probe`; use `youtube_download` only after the\ndestination and trust boundary are clear.\n\n**Status:** production personal-media MCP server. Read-only search/probe/stats\npaths are safe; download, playlist, queue-drain, and tag-writing paths create or\nmove state and are intended for trusted callers.\n\n**Not for:** a generic web-downloader SaaS, a multi-tenant media ingestion\nboundary, a replacement for yt-dlp's upstream site handling, or an arbitrary\nfilesystem writer for untrusted MCP callers.\n\n## Contents\n\n- [Naming](#naming)\n- [Capabilities And Boundaries](#capabilities-and-boundaries)\n- [Install](#install)\n- [Quickstart](#quickstart)\n- [Client Configuration](#client-configuration)\n- [Runtime Surfaces](#runtime-surfaces)\n- [MCP Tool Reference](#mcp-tool-reference)\n- [CLI Reference](#cli-reference)\n- [Configuration](#configuration)\n- [Authentication](#authentication)\n- [Safety And Trust Model](#safety-and-trust-model)\n- [Architecture](#architecture)\n- [Distribution Contract](#distribution-contract)\n- [Development](#development)\n- [Verification](#verification)\n- [Deployment](#deployment)\n- [Troubleshooting](#troubleshooting)\n- [Related Servers](#related-servers)\n- [Documentation](#documentation)\n- [License](#license)\n\n## Naming\n\n| Surface | This repo |\n| --- | --- |\n| Repository | [`dinglebear-ai/rytdl`](https://github.com/dinglebear-ai/rytdl) |\n| Cargo crate | `ytdl-rmcp` |\n| npm package | `@dinglebear/rytdl` |\n| CLI / binary | `rytdl` |\n| MCP tools | `youtube_search`, `youtube_search_ui`, `youtube_download`, `youtube_probe`, `youtube_identify`, `youtube_stats`, `youtube_plex_playlist`, `youtube_transfer_queue` |\n| Env prefix | `YTDLP_*`, plus `FFMPEG_*`, `FPCALC_PATH`, and `YTDLP_LOG` |\n| Transport | stdio only — no HTTP listener, no service port |\n\nThe crate and npm package use the `*-rmcp` family naming pattern, while the\nrepository and runtime binary are `rytdl` so local shells get a short\nRust-native command.\n\n## Capabilities And Boundaries\n\n- Searches YouTube through yt-dlp without downloading media.\n- Downloads audio, video, or both into a staging tree, tags audio metadata, and\n  transfers the result to local, SSH, or rclone destinations.\n- Optionally fingerprints audio through AcoustID/MusicBrainz and syncs completed\n  audio downloads into a Plex playlist.\n- Builds Plex playlists from successful transfer history and drains server-made\n  retained-staging transfer manifests.\n- Exposes an MCP App search UI for hosts that can render embedded widgets.\n- Keeps a JSONL ledger for repeat-safe downloads and stats.\n\n| This repo owns | Upstream owns | Explicitly out of scope |\n| --- | --- | --- |\n| MCP tools, CLI setup, media staging, tagging, transfer policy, queue manifests, config validation, response shaping, plugin/package metadata. | yt-dlp extraction behavior, source-site availability, ffmpeg media conversion, Plex library indexing, SSH/rclone authentication. | Multi-tenant isolation, arbitrary local writes for untrusted callers, credential brokering, site-specific scraping guarantees, media-server replacement. |\n\n---\n\n## Features\n\n- **Audio, video, or both** — audio-first by default, with separate targets for\n  audio and video.\n- **Proper tagging** — embeds title / artist / album / date and cover art, and\n  organizes output as `Artist/Title [id].ext` so media servers (Plex, etc.)\n  index it cleanly. A non-greedy `Artist - Title` parse recovers the artist from\n  free-form video titles. Source `.info.json`, thumbnail, and description\n  sidecars are preserved next to the media for future retagging/indexing.\n  Common YouTube title noise like `(Official Video)`, `[Official Audio]`, and\n  trailing channel handles is stripped from embedded title metadata by default.\n- **Self-contained paths** — the binary downloads/caches yt-dlp + ffmpeg when\n  run directly; the container image bakes in ffmpeg, fpcalc, SSH, and rsync for\n  media-host batch jobs.\n- **Self-installing** — `ytdl-rmcp setup` registers the server into Claude Code,\n  Codex, and/or Gemini CLI via each tool's own `mcp add`.\n- **Robust transfers** — local paths (`/path`) are copied in-process by the\n  binary itself, SSH targets (`host:/path`) use `rsync -a --partial\n  --protect-args` with an `scp` fallback when `rsync` is missing, and rclone\n  targets (`remote:path` or `rclone:remote:/path`) use `rclone copy`. On\n  transfer failure the local staging copy is kept for retry and recorded as a\n  drainable manifest for `youtube_transfer_queue`.\n- **Repeat-safe** — `use_archive` records downloaded IDs (per mode) and skips\n  them on later runs; YouTube mix/radio URLs are auto-cleaned to the seed video.\n- **Stats-ready ledger** — every completed download call appends a JSONL entry\n  with timestamp, destinations, files, bytes, uploader, and transfer status.\n- **Plex playlist sync** — when Plex credentials are configured, downloaded\n  audio is added to `yt-dlp Downloads` by default.\n\n## MCP Tool Reference\n\n| Tool | Purpose |\n| --- | --- |\n| `youtube_search` | Search YouTube with yt-dlp and return result URLs without downloading. |\n| `youtube_search_ui` | Open an interactive YouTube search UI in MCP App-capable hosts. |\n| `youtube_download` | Download one or more URLs (audio/video/both) and transfer them to a target path. |\n| `youtube_probe` | Read-only: resolve title/duration/uploader/format counts without downloading. |\n| `youtube_identify` | Fingerprint local audio with `fpcalc`, return AcoustID/MusicBrainz candidates, preview canonical tags, and optionally write high-confidence tags. |\n| `youtube_stats` | Summarize the download ledger: totals, file kinds, uploaders, and recent entries. |\n| `youtube_plex_playlist` | Build or preview Plex audio playlists from successful transferred audio history. |\n| `youtube_transfer_queue` | List and drain retained-staging transfer failure manifests. |\n\n### `youtube_download` parameters\n\n| Param | Default | Meaning |\n| --- | --- | --- |\n| `urls` | — (required) | One URL string or an array of URLs. |\n| `mode` | `audio` | `audio`, `video`, or `both`. |\n| `audio_format` | env `YTDLP_AUDIO_FORMAT` → `mp3` | `mp3`/`m4a`/`opus`/`flac`/`wav`/`best`. |\n| `audio_quality` | `0` | yt-dlp quality for lossy codecs: `0`–`9` or a bitrate like `192K`. |\n| `max_height` | best | Cap video resolution (e.g. `1080`). |\n| `container` | `mp4` | `mp4` or `mkv` for video. |\n| `target_path` | env `YTDLP_TARGET_PATH` | Destination for audio. Use `/path` for local, `host:/path` for SSH, or `remote:path` or `rclone:remote:/path` for rclone. |\n| `video_target_path` | env `YTDLP_VIDEO_TARGET_PATH` → `target_path` | Destination for video when it should land somewhere different from audio. Same target forms. |\n| `keep_local` | `false` | Keep the local staging copy after transfer. |\n| `use_archive` | `false` | Record + skip already-downloaded IDs (per mode). |\n| `plex_playlist` | env `YTDLP_PLEX_PLAYLIST` → `yt-dlp Downloads` when Plex is configured | Plex playlist title or ID to add downloaded audio tracks to. Requires `YTDLP_PLEX_URL` and `YTDLP_PLEX_TOKEN`. |\n| `response_format` | `markdown` | `markdown` or `json`. |\n\nWhen Plex credentials are configured, successful downloads that produced audio\nfiles search Plex for each downloaded track, create the target playlist if\nneeded, and add missing tracks while skipping entries already present. The\ndefault playlist is `yt-dlp Downloads`; set `YTDLP_PLEX_PLAYLIST` or pass\n`plex_playlist` to override it. Plex errors are reported as\n`plex_playlist_error` and do not make the completed download fail. JSON\nresponses include a `plex_playlist` summary with `matched`, `added`,\n`already_present`, and `missing` counts.\n\nCanonical metadata matching through MusicBrainz/AcoustID is documented in\n`docs/musicbrainz-acoustid.md`. `youtube_download` automatically runs\nhigh-confidence MusicBrainz retagging for downloaded audio when\n`YTDLP_ACOUSTID_CLIENT_KEY` is configured; `youtube_identify` remains available\nfor previewing or repairing existing library files, with manual tag writes\nenabled by `write_tags=true`.\n\n#### `youtube_download` JSON response\n\nWith `response_format=json`, the call returns a single object describing the\nbatch:\n\n| Field | Meaning |\n| --- | --- |\n| `transferred` | `true` if every produced subtree reached its target. |\n| `transfer_error` | `null` on success, else the failure/timeout message (string). |\n| `target_path` / `destination` / `destinations` | The per-kind target destination(s) actually used. |\n| `staging_kept_at` | Local staging path retained for retry (set when the transfer failed or `keep_local` was requested). |\n| `total_files` / `total_bytes` / `total_size` | Aggregate counts across all items. |\n| `partial_items` | Count of items that errored **but** still produced files. |\n| `failed_items` | Count of items that errored **and** produced no files. |\n| `items[]` | Per-URL results, each with a `status`, `title`, `video_id`, `error`, and a `files[]` list. |\n\nEach `items[].status` is one of:\n\n- `ok` — succeeded with files.\n- `partial` — an error occurred but some files were still produced.\n- `failed` — errored with no files.\n- `skipped` — nothing new (already in the archive).\n\nOptional keys are attached only when the relevant stage ran:\n\n- `metadata_retag` — MusicBrainz/AcoustID auto-retag summary (`attempted`,\n  `matched`, `written`, `skipped`, `errors`, or an `error` string); present when\n  `YTDLP_ACOUSTID_CLIENT_KEY` is configured.\n- `plex_playlist` — Plex playlist summary (`playlist`, `matched`, `added`,\n  `already_present`, `missing`); `plex_playlist_error` is set instead if the\n  Plex update failed (a Plex failure does not fail the download).\n- `history_error` — set when the download succeeded but the JSONL ledger append\n  failed.\n\n`youtube_probe` takes `urls` and `response_format`.\n\n### `youtube_plex_playlist`\n\nBuild or preview Plex audio playlists from successful ytdl-rmcp download history.\n\nActions:\n\n| Action | Meaning |\n| --- | --- |\n| `list_candidates` | Return audio candidates from history entries where `transferred` is `true`. |\n| `preview` | Resolve selected candidates against Plex without mutating Plex. |\n| `apply` | Add selected candidates to a Plex audio playlist idempotently. |\n\nCandidates are history-derived and audio-only. Failed or retained-staging\ntransfers are intentionally excluded.\n\n`apply` can return `plexamp_url`, `plex_web_url`, and\n`playback_link_status`. `plexamp_url` is a best-effort generated\n`listen.plex.tv` playback link, not an official Plexamp API guarantee. The\nregular Plex playlist API calls use the official Plex Media Server API.\n\n### `youtube_transfer_queue`\n\nList and drain server-created transfer failure manifests.\n\nActions:\n\n| Action | Meaning |\n| --- | --- |\n| `list` | Show pending retained-staging transfer manifests. |\n| `retry` | Retry one manifest by opaque `manifest_id`. |\n| `retry_all` | Retry all pending manifests. |\n| `prune` | Remove manifests whose staging directory is gone. |\n\nThe queue never accepts arbitrary filesystem paths. Retry uses the original\ntarget paths recorded at failure time and re-checks local target policy before\ntransfer. Manifests are created by the local server when a transfer fails while\nthe staging directory, manifest ID, file list, and original targets still match.\n\n### `youtube_identify` parameters\n\n| Param | Default | Meaning |\n| --- | --- | --- |\n| `paths` | — (required) | One local audio file path string or an array of paths. |\n| `write_tags` | `false` | Write high-confidence MusicBrainz tag previews back to the audio files. |\n| `response_format` | `markdown` | `markdown` or `json`. |\n\n`youtube_identify` runs Chromaprint `fpcalc`, sends the fingerprint to AcoustID,\nand returns MusicBrainz recording candidates. When the best candidate is\nhigh-confidence, it also fetches the MusicBrainz recording/release data and\nincludes a `retag_preview` showing the canonical artist, title, release, release\ndate, release type, track number, and MusicBrainz IDs. By default it is\npreview-only. With `write_tags=true`, it writes the preview to the file with\nLofty, including common title/artist/album/date/track fields plus MusicBrainz\nrecording, release, release-group, and release-type tags. It requires\n`YTDLP_ACOUSTID_CLIENT_KEY`; set `FPCALC_PATH` if `fpcalc` is not on `PATH`.\n\n### `youtube_search` parameters\n\n| Param | Default | Meaning |\n| --- | --- | --- |\n| `query` | - (required) | YouTube search text. The server passes this to yt-dlp as `ytsearchN:<query>`. |\n| `limit` | `10` | Number of results, clamped to `1..=25`. |\n| `response_format` | `markdown` | `markdown` or `json`. |\n\n`youtube_search_ui` accepts the same input and returns the same search payload,\nplus MCP App metadata for hosts that can render the embedded UI. Hosts without\napp rendering still receive the normal search result text and structured data.\n\n### MCP App pattern\n\n`youtube_search_ui` is the widget-backed entry point for this repo:\n\n- The tool descriptor advertises `_meta.ui.resourceUri`.\n- The server exposes `ui://ytdl-rmcp/youtube-search.html` through\n  `resources/list` and `resources/read`.\n- The resource uses `text/html;profile=mcp-app` and an explicit CSP metadata\n  block.\n- `.mcpb` / `.dxt` packaging installs the local server; UI resources are still\n  advertised through the MCP tools/resources protocol and are host-rendered.\n\n### `youtube_stats` parameters\n\n| Param | Default | Meaning |\n| --- | --- | --- |\n| `limit` | `10` | Number of recent ledger entries to include, clamped to `0..=100`. |\n| `response_format` | `markdown` | `markdown` or `json`. |\n\nJSON stats include `total_downloads`, `total_files`, `total_bytes`,\n`skipped_entries`, `by_kind`, `by_uploader`, and `recent`. Bucket fields include\n`downloads` (compatibility alias for call count), `calls`, `items`, `files`,\n`bytes`, and human-readable `size`. Malformed ledger lines are skipped and\ncounted instead of failing the whole stats call. If a download succeeds but the\nledger append fails, the download response still succeeds and includes\n`history_error` in JSON output.\n\n## CLI Reference\n\nThe CLI owns process setup and diagnostics; media operations are exposed as MCP\ntools.\n\n| Command | Purpose |\n| --- | --- |\n| `rytdl` or `rytdl serve` | Serve MCP over stdio. This is the default runtime used by clients. |\n| `rytdl setup` | Fetch tool dependencies when needed and register local MCP clients. |\n| `rytdl doctor` | Print version, platform, tool-resolution, and config-presence diagnostics. |\n\nThe npm launcher exposes the same binary:\n\n```bash\nnpx -y @dinglebear/rytdl doctor\nnpx -y @dinglebear/rytdl serve\n```\n\n## Install\n\nRun the guided installer through npm:\n\n```bash\nnpx -y @dinglebear/rytdl setup\n```\n\nOr install the command globally:\n\n```bash\nnpm i -g @dinglebear/rytdl\nytdl-rmcp setup\n```\n\nThe npm package downloads the matching GitHub Release binary during\n`postinstall`; the installed command is the Rust binary served through a tiny\nNode launcher. You can also use the one-line installer:\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/dinglebear-ai/rytdl/main/scripts/install.sh | bash\n```\n\nOr download the binary tarball for your platform from\n[Releases](https://github.com/dinglebear-ai/rytdl/releases), or build it (see below).\nThe guided setup fetches yt-dlp + ffmpeg, prompts for your audio/video target\npaths, detects which agent CLIs are present, and registers the server into the\nones you pick.\n\n## Quickstart\n\nAfter setup, prove the read-only path first:\n\n```bash\nnpx -y @dinglebear/rytdl doctor\n```\n\nFor raw MCP clients, call a read-only tool with JSON-RPC `tools/call`:\n\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"tools/call\",\n  \"params\": {\n    \"name\": \"youtube_search\",\n    \"arguments\": {\n      \"query\": \"lcd soundsystem live\",\n      \"limit\": 3,\n      \"response_format\": \"json\"\n    }\n  }\n}\n```\n\nThen probe a known URL before downloading:\n\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 2,\n  \"method\": \"tools/call\",\n  \"params\": {\n    \"name\": \"youtube_probe\",\n    \"arguments\": {\n      \"urls\": \"https://www.youtube.com/watch?v=dQw4w9WgXcQ\"\n    }\n  }\n}\n```\n\nUse `youtube_download` only after `YTDLP_TARGET_PATH` or\n`YTDLP_VIDEO_TARGET_PATH` points at a destination you are comfortable letting\ntrusted MCP callers write into.\n\n## Client Configuration\n\nRun without subcommands, `npx -y @dinglebear/rytdl` serves MCP over stdio. Register it\nyourself:\n\n```bash\n# Claude Code\nclaude mcp add -s user @dinglebear/rytdl -e YTDLP_TARGET_PATH=nashost:/media/music -e YTDLP_EXTRACTOR_ARGS=youtube:player_client=android -- npx -y @dinglebear/rytdl\n# Codex\ncodex  mcp add --env YTDLP_TARGET_PATH=nashost:/media/music --env YTDLP_EXTRACTOR_ARGS=youtube:player_client=android @dinglebear/rytdl -- npx -y @dinglebear/rytdl\n# Gemini CLI (command is positional, env last)\ngemini mcp add -s user @dinglebear/rytdl npx -y @dinglebear/rytdl -e YTDLP_TARGET_PATH=nashost:/media/music -e YTDLP_EXTRACTOR_ARGS=youtube:player_client=android\n```\n\nIf you already installed a standalone binary with `npm i -g @dinglebear/rytdl`,\n`scripts/install.sh`, or a release tarball, you can use that binary path in\nplace of `npx -y @dinglebear/rytdl`.\n\nFor raw MCP JSON configs, include the required target path env var and the\nYouTube extractor override:\n\n```json\n{\n  \"mcpServers\": {\n    \"ytdl-rmcp\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@dinglebear/rytdl\"],\n      \"env\": {\n        \"YTDLP_TARGET_PATH\": \"nashost:/mnt/user/data/media/music/yt-dlp\",\n        \"YTDLP_VIDEO_TARGET_PATH\": \"nashost:/mnt/user/data/media/movies/yt-dlp\",\n        \"YTDLP_AUTO_UPDATE\": \"1\",\n        \"YTDLP_MAX_AGE_DAYS\": \"1\",\n        \"YTDLP_EXTRACTOR_ARGS\": \"youtube:player_client=android\"\n      }\n    }\n  }\n}\n```\n\nThe checked-in `.mcp.json` is also a complete raw MCP profile: it declares the\nsame `user_config` keys used by the plugin/bundle manifests, supplies defaults\nfor local gateway imports, and maps every setting into the server environment.\nFor reliable YouTube search/probe behavior it defaults\n`YTDLP_EXTRACTOR_ARGS` to `youtube:player_client=android`; official music-video\nresults frequently reject yt-dlp's default YouTube clients during metadata\nextraction.\n\n## Runtime Surfaces\n\n| Surface | Command or file | Notes |\n| --- | --- | --- |\n| stdio MCP server | `npx -y @dinglebear/rytdl` or `rytdl` | Default runtime for local MCP clients. |\n| CLI | `rytdl --help` | Same binary; exposes setup and diagnostics. |\n| Guided setup | `npx -y @dinglebear/rytdl setup` | Registers Claude Code, Codex, and Gemini CLI configs where available. |\n| MCP App | `youtube_search_ui` | Embedded search widget plus normal fallback tool output. |\n| Bundle | `mcpb/manifest.json` | Binary MCPB/DXT package for desktop hosts that support bundles. |\n| Container | `ghcr.io/dinglebear-ai/rytdl:main` | Includes ffmpeg, fpcalc, SSH, rclone, and rsync for shared deployments. |\n| TOOTIE persistent runtime | `ops/compose/tootie/` | Product-owned Compose declaration; sessions enter the long-lived container over stdio with `mcp-stdio.sh`. |\n\n## Distribution Contract\n\n- **npm launcher** — `npx -y @dinglebear/rytdl` downloads and runs the matching\n  GitHub Release binary. Run without subcommands, it serves MCP over stdio;\n  `npx -y @dinglebear/rytdl setup` runs the guided installer. Stable releases publish\n  the package from GitHub Actions with npm provenance.\n- **Claude Code plugin** — `.claude-plugin/plugin.json` prompts for config via\n  `userConfig`; `.mcp.json` launches `npx -y @dinglebear/rytdl`, which downloads the\n  matching GitHub Release binary through npm.\n- **Gemini CLI extension** — `gemini-extension.json`; install with\n  `gemini extensions install https://github.com/dinglebear-ai/rytdl`. MCP clients\n  should prefer the npm launcher command, `npx -y @dinglebear/rytdl`.\n- **Container image** — `ghcr.io/dinglebear-ai/rytdl:main` is published on every\n  push to `main`, or build locally with `docker build -t ytdl-rmcp:local .`. It\n  includes `ffmpeg`, `fpcalc`, `openssh-client`, `rclone`, and `rsync`. See\n  [`docs/container.md`](docs/container.md) for MCP and mounted-library examples.\n- **MCP bundle (`.mcpb` / `.dxt`)** — `mcpb/manifest.json` defines a\n  `binary`-type bundle for one-click install in MCPB-capable desktop hosts.\n  Every main release publishes `ytdl-rmcp.mcpb` plus a legacy `ytdl-rmcp.dxt`\n  alias; both contain the same linux + windows binaries. The bundle defaults\n  optional config values to empty strings so Claude Desktop can install it\n  before you fill in the destination settings. Configure at least the target\n  path in the extension settings before downloading.\n  Build one locally from prebuilt binaries with `scripts/build-mcpb.sh` (needs\n  Node for the `@anthropic-ai/mcpb` CLI).\n\n## Configuration\n\nOnly one value is required for downloads: `YTDLP_TARGET_PATH`.\n`YTDLP_VIDEO_TARGET_PATH` is required only when video files should land\nsomewhere different from audio. `youtube_search`, `youtube_probe`, and\n`youtube_identify` do not need a destination. The install manifests default\n`YTDLP_EXTRACTOR_ARGS` to `youtube:player_client=android` because that client\nsurvives common YouTube metadata blocks that make official music-video search\nresults look unavailable.\n\nTarget path forms:\n\n- `/path/to/library` — local directory. Copied by the binary's own filesystem\n  copy (no external tool); a destination nested inside the staging source is\n  rejected. Requires `YTDLP_ALLOW_LOCAL_TARGETS=true` because local paths let MCP callers choose write locations.\n- `host:/path/to/library` — SSH target. Uses the existing rsync/scp flow and\n  honors `YTDLP_SSH_OPTS`.\n- `remote:path/to/library` — rclone target with a relative remote path. Uses `rclone copy`; `rclone` must be\n  configured on `PATH` for the server process.\n- `rclone:remote:/path/to/library` — explicit rclone target for an absolute remote path; without the `rclone:` prefix, `host:/path` remains SSH by design.\n\n| Var | Required? | Default | Used by | Meaning |\n| --- | --- | --- | --- | --- |\n| `YTDLP_TARGET_PATH` | Required for downloads | — | download | Destination for **audio**. Use `/path` for local, `host:/path` for SSH, or `remote:path` or `rclone:remote:/path` for rclone. |\n| `YTDLP_VIDEO_TARGET_PATH` | Optional | falls back to `YTDLP_TARGET_PATH` | download | Destination for **video** when video files should land somewhere different from audio. Same target forms. |\n| `YTDLP_REMOTE` | Deprecated | — | download | Legacy SSH remote alias or `user@host`. During migration, combines with `YTDLP_REMOTE_PATH` / `YTDLP_VIDEO_REMOTE_PATH` as explicit SSH targets. Prefer `YTDLP_TARGET_PATH`. |\n| `YTDLP_REMOTE_PATH` | Deprecated | — | download | Legacy absolute SSH path for audio. Requires `YTDLP_REMOTE`; relative paths are rejected. Prefer `YTDLP_TARGET_PATH`. |\n| `YTDLP_VIDEO_REMOTE_PATH` | Deprecated | — | download | Legacy absolute SSH path for video. Requires `YTDLP_REMOTE`; falls back to the audio target when unset. Prefer `YTDLP_VIDEO_TARGET_PATH`. |\n| `YTDLP_ALLOW_LOCAL_TARGETS` | Optional | `0` | download | Permit local filesystem targets such as `/path`. Keep disabled unless you trust MCP callers to choose local write locations. |\n| `YTDLP_AUDIO_FORMAT` | Optional | `mp3` | download | Default audio codec: `mp3`, `m4a`, `opus`, `flac`, `wav`, or `best`. |\n| `YTDLP_STAGING_DIR` | Optional | system temp | download | Local directory where media is staged before transfer. On transfer failure this staging copy is kept for retry. |\n| `YTDLP_SSH_OPTS` | Optional | — | download | Extra ssh options parsed with shell-word syntax and appended after forced non-interactive defaults. Example: `-i \"~/.ssh/ytdl key\" -o ProxyJump=media-bastion`. Malformed quoting is rejected, and command-execution footguns such as `ProxyCommand` are stripped. |\n| `YTDLP_ARCHIVE_DIR` | Optional | per-user state dir | download | Directory that stores `use_archive` download archives. Separate per-mode archive files are created inside it. |\n| `YTDLP_HISTORY_PATH` | Optional | per-user state dir `downloads.jsonl` | download, stats | JSONL download ledger used by `youtube_stats`. |\n| `YTDLP_PLEX_URL` | Required for Plex sync | — | download | Plex server URL, e.g. `http://plex.local:32400`, used when adding audio downloads to a Plex playlist. Must be paired with `YTDLP_PLEX_TOKEN`. |\n| `YTDLP_PLEX_TOKEN` | Required for Plex sync | — | download | Plex auth token for playlist/search API calls. Must be paired with `YTDLP_PLEX_URL`. |\n| `YTDLP_PLEX_PLAYLIST` | Optional | `yt-dlp Downloads` when Plex URL/token are set | download | Default Plex playlist title or ID; can be overridden per call with `plex_playlist`. |\n| `YTDLP_CLEAN_METADATA` | Optional | `1` | download | Strip common YouTube title noise before embedding metadata. Set to `0` to preserve source titles exactly. |\n| `YTDLP_ACOUSTID_CLIENT_KEY` | Required for identify/auto-retagging | — | identify, download | AcoustID application API key. Required by `youtube_identify`; when set, `youtube_download` also writes high-confidence MusicBrainz tags to downloaded audio before transfer. |\n| `FPCALC_PATH` | Optional | `fpcalc` on `PATH` | identify, download retagging | Optional explicit path to the Chromaprint `fpcalc` executable. |\n| `YTDLP_MUSICBRAINZ_CONTACT` | Optional | GitHub repo URL | identify, download retagging | Contact URL/email included in MusicBrainz lookup User-Agent strings. |\n| `YTDLP_AUTO_UPDATE` | Optional | `1` | tool bootstrap | Re-download yt-dlp when stale. Disable only when `YTDLP_PATH`/hash pins are managing the executable externally. |\n| `YTDLP_MAX_AGE_DAYS` | Optional | `14` | tool bootstrap | Staleness threshold in days for yt-dlp auto-update. |\n| `YTDLP_UPDATE_PRE` | Optional | `0` | tool bootstrap | Track yt-dlp's nightly pre-release channel instead of stable. |\n| `YTDLP_EXTRACTOR_ARGS` | Required for reliable YouTube search/probe | `youtube:player_client=android` in install manifests; unset in bare process env | search, probe, download | Passed to yt-dlp `--extractor-args`. The Android YouTube client fixes common `This video is not available` metadata failures for official music videos. |\n| `YTDLP_TIMEOUT_SECS` | Optional | `1800` | search, probe, download | Timeout for each yt-dlp search/probe/download command. |\n| `YTDLP_TRANSFER_TIMEOUT_SECS` | Optional | `600` | download | Timeout for each transfer phase. |\n| `YTDLP_PATH` | Optional | — | tool bootstrap | Use a specific yt-dlp executable instead of auto-resolution/auto-download. |\n| `FFMPEG_PATH` | Optional | — | tool bootstrap, download | Use a specific ffmpeg executable instead of auto-resolution/auto-download. Probe/search do not need ffmpeg. |\n| `YTDLP_SHA256` | Optional | — | tool bootstrap | Optional SHA-256 digest required for the resolved yt-dlp executable. |\n| `FFMPEG_SHA256` | Optional | — | tool bootstrap | Optional SHA-256 digest required for the resolved ffmpeg executable. |\n| `YTDLP_LOG` | Optional | `info` | server process | `tracing` filter written to stderr only. Never send logs to stdout because stdout is the MCP JSON-RPC channel. |\n\n> **Maintainers:** this table is maintained **by hand**. `scripts/check-packaging.sh`\n> cross-checks the machine-readable config surfaces (the Claude plugin,\n> `.mcp.json` `user_config`, `gemini-extension.json`, and `mcpb/manifest.json`) and verifies this README mentions every mapped env var name.\n> It does not compare README descriptions or defaults. When you add, rename, or remove a\n> `YTDLP_*`, `FFMPEG_*`, `FPCALC_PATH`, or `YTDLP_LOG` env var, update this\n> table manually.\n\n## Authentication\n\nThis server speaks **stdio only** — it opens no network listener, binds no\nport, and has no HTTP auth layer. Access is whatever the local MCP client\ngrants to the process it launches. External\ncredentials live in operator-controlled environment variables, local config, SSH\nagents, rclone config, or Plex/AcoustID variables.\n\nMCP callers never provide Plex tokens, SSH keys, rclone credentials, hash pins,\nor downloader binary paths in tool arguments. Tool arguments carry media URLs,\nsearch/probe inputs, output mode choices, and destination selectors that are\nvalidated against the process configuration.\n\n## Safety And Trust Model\n\n### Bootstrap trust model\n\nBy default, first run resolves tools in this order: explicit env override,\n`PATH`, cache, then HTTPS download from the upstream release source. Set\n`YTDLP_SHA256` and/or `FFMPEG_SHA256` to require an exact executable digest\nafter resolution or download. These pins verify bytes on disk, but they do not\nfetch upstream signatures or automatically discover trusted digests; operators\nwho need a fully pinned supply chain should provide known-good binaries through\n`YTDLP_PATH` / `FFMPEG_PATH` plus matching SHA-256 pins, or disable yt-dlp\nauto-update.\n\nFor stricter bootstrap control, combine `YTDLP_PATH` / `FFMPEG_PATH` with\nmatching `YTDLP_SHA256` / `FFMPEG_SHA256` pins. Hash pins verify the resolved\nexecutable bytes; they are not upstream signature verification.\n\n### Security posture\n\nThis server is designed to run with **trusted callers and operator-supplied\nconfig** — it is not a hardened multi-tenant boundary.\n\n- **Tool-call URLs reach yt-dlp.** Whatever `urls` an MCP caller passes are\n  handed to yt-dlp, a powerful extraction tool. Only point callers at it that\n  you trust. Tool-call URLs are validated as `http`/`https` before they reach\n  yt-dlp, and every positional is passed after a `--` end-of-options separator so\n  a `-`-prefixed value can't be parsed as a flag; the trust assumption above\n  still holds regardless.\n- **SSH is key-only and non-interactive.** SSH targets force `BatchMode=yes` and\n  `StrictHostKeyChecking=accept-new`, so a TTY-less server fails fast instead of\n  prompting; there is no password auth. Auth comes from your SSH key/agent and\n  any options you add via `YTDLP_SSH_OPTS`.\n- **Target paths are validated.** Local and SSH paths must be absolute and may\n  not contain traversal or control characters. SSH remotes also reject\n  option-like and whitespace/control-bearing values before anything reaches\n  `ssh`/`rsync`/`scp`; remote paths are single-quote-escaped for the remote\n  shell. Rclone targets must be `remote:path` or explicit `rclone:remote:/path` and reject control characters.\n\n## Requirements\n\n- **rsync** is recommended for SSH transfers and falls back to **scp** when\n  absent. Local transfers need no external tool — the binary copies the tree\n  itself.\n- **ssh** plus passwordless key-based auth when using `host:/path` targets.\n- **rclone** plus a configured rclone remote when using `remote:path` or `rclone:remote:/path` targets.\n- yt-dlp and ffmpeg are fetched automatically (override with `YTDLP_PATH` /\n  `FFMPEG_PATH`, or just have them on `PATH`).\n- `youtube_identify` additionally needs `fpcalc`; the container image includes\n  it via `libchromaprint-tools`.\n\n## Development\n\nBuild and test from source:\n\n```bash\ncargo build --release                                          # Linux/macOS\ncargo test && cargo clippy --all-targets -- -D warnings        # checks\n\n# Cross-compile to Windows from Linux (needs nasm + the LLVM toolchain):\nsudo apt-get install -y nasm llvm clang lld\ncargo install cargo-xwin\ncargo xwin build --release --target x86_64-pc-windows-msvc\n```\n\nOn devhost/local shells, `~/.local/bin/cargo` is a wrapper that can break\n`cargo xwin`; use the real rustup cargo for local Windows rehearsals:\n\n```bash\n~/.cargo/bin/cargo xwin build --release --target x86_64-pc-windows-msvc\n```\n\nCI (`.github/workflows/`) runs fmt + clippy + tests and a Windows cross-build on\nevery push/PR, and publishes both binaries to a GitHub Release on `v*` tags.\n\nThis single-crate workspace uses Rust edition 2024 with MSRV 1.97.1.\n\n## Verification\n\nUse these checks before releasing README, package, or runtime changes:\n\n```bash\npython3 /home/jmagar/workspace/soma/scripts/check-readme-guide.py README.md packages/ytdl-rmcp/README.md\nnpm --prefix packages/ytdl-rmcp run check\ncargo fmt --check\ncargo check\ncargo test\nscripts/check-packaging.sh\ngit diff --check\n```\n\nFor a live MCP smoke, register with a temporary config and call\n`youtube_search` or `youtube_probe` before running `youtube_download`.\n\n## Architecture\n\nBare invocation serves MCP over stdio; `setup` runs the installer. A\n`youtube_download` call:\n\n1. Resolves yt-dlp + ffmpeg (env override → PATH → cache → download) and\n   verifies SHA-256 pins when configured.\n2. Cleans mix/radio URLs, then runs yt-dlp per mode into a staging tree\n   (`staging/audio`, `staging/video`) with metadata/thumbnail/archive flags,\n   source metadata sidecars, and the `Artist/Title [id]` output template.\n3. *(optional)* When `YTDLP_ACOUSTID_CLIENT_KEY` is set, fingerprints the\n   downloaded audio and writes high-confidence MusicBrainz/AcoustID tags\n   in-place — before transfer, so the target copy carries the canonical tags.\n4. Transfers each kind's subtree to its target: local in-process copy, SSH\n   rsync/scp, or `rclone copy`.\n5. *(optional)* When Plex credentials are configured and the transfer\n   succeeded, adds the downloaded audio tracks to the target Plex playlist.\n6. Appends the completed call to the JSONL download ledger.\n7. Returns a markdown or JSON summary listing files, sizes, and the actual\n   destination(s).\n\nSee `CLAUDE.md` for architecture, conventions, and gotchas.\n\n## Deployment\n\n- Local clients should use `npx -y @dinglebear/rytdl` or the installed `rytdl` binary\n  over stdio.\n- Shared runtime jobs can use the container image when ffmpeg, fpcalc, SSH,\n  rclone, and rsync should be present without host-level installs.\n- Host deployments should set destination, Plex, AcoustID, SSH, and rclone\n  credentials in process env or host config before exposing the MCP server to\n  callers.\n- Keep `YTDLP_ALLOW_LOCAL_TARGETS=0` unless trusted callers are allowed to write\n  to local filesystem paths selected through tool arguments.\n\n## Troubleshooting\n\n- YouTube metadata looks unavailable: set\n  `YTDLP_EXTRACTOR_ARGS=youtube:player_client=android` or use the checked-in\n  client/plugin configs, which already default it.\n- Downloads succeed but transfers fail: inspect `staging_kept_at` or the\n  `youtube_transfer_queue` list, then retry after fixing SSH, rclone, or local\n  target permissions.\n- Plex playlist updates are missing: confirm `YTDLP_PLEX_URL`,\n  `YTDLP_PLEX_TOKEN`, and that Plex can see the transferred files.\n- Tool bootstrap is too loose for your environment: pin `YTDLP_PATH` and\n  `FFMPEG_PATH` with matching SHA-256 variables, or disable yt-dlp auto-update.\n\n## Related Servers\n\n- [soma](https://github.com/dinglebear-ai/soma) - RMCP runtime for provider-backed MCP servers.\n- [unifi-rmcp](https://github.com/dinglebear-ai/runifi) - UniFi controller REST API bridge.\n- [tailscale-rmcp](https://github.com/dinglebear-ai/rtailscale) - Tailscale API bridge for devices, users, and tailnet operations.\n- [unraid](https://github.com/dinglebear-ai/unraid) - Unraid GraphQL bridge for NAS and server management.\n- [apprise-rmcp](https://github.com/dinglebear-ai/rapprise) - Apprise notification fan-out bridge for many delivery backends.\n- [gotify-rmcp](https://github.com/dinglebear-ai/rgotify) - Gotify push notification bridge for sends, messages, apps, and clients.\n- [arcane-rmcp](https://github.com/dinglebear-ai/rarcane) - Arcane Docker management bridge for containers and related resources.\n- [yarr](https://github.com/dinglebear-ai/yarr) - Media-stack bridge for Sonarr, Radarr, Prowlarr, Plex, and related services.\n- [synapse-rmcp](https://github.com/dinglebear-ai/synapse) - Local Synapse workflow server for scout and flux actions.\n- [cortex](https://github.com/dinglebear-ai/cortex) - Syslog and homelab log aggregation MCP server.\n- [axon](https://github.com/dinglebear-ai/axon) - RAG, crawl, scrape, extract, and semantic search project.\n- [labby](https://github.com/dinglebear-ai/labby) - Homelab control plane and MCP gateway project.\n- [lumen](https://github.com/dinglebear-ai/lumen) - Local semantic code search MCP server.\n\n## Documentation\n\nThis README is the curated operator entry point. The generated or\nmachine-readable source of truth lives in the package, plugin, and bundle\nmanifests that `scripts/check-packaging.sh` cross-checks.\n\n| Doc | Purpose |\n| --- | --- |\n| `CLAUDE.md` | Architecture, conventions, and local agent notes. |\n| `docs/container.md` | Container runtime examples and mounted-library patterns. |\n| `docs/musicbrainz-acoustid.md` | Canonical metadata matching and retagging behavior. |\n| `.mcp.json` | Raw MCP profile and machine-readable user config defaults. |\n| `.claude-plugin/plugin.json`, `gemini-extension.json`, `mcpb/manifest.json` | Client-specific packaging metadata. |\n\n## License\n\nOriginal Dinglebear-authored portions of this project are licensed under [AGPL-3.0-only](LICENSE). Separate commercial licensing is available for organizations that need terms outside the AGPL. Third-party material remains under its original license. See [LICENSING.md](https://github.com/dinglebear-ai/rytdl/blob/main/LICENSING.md).\n\n## Rust MCP naming pattern\n\nThis repo follows the Rust MCP server naming convention:\n\n- Repo: `dinglebear-ai/rytdl`\n- Cargo crate: `ytdl-rmcp`\n- CLI alias: `rytdl`\n- npm package: `@dinglebear/rytdl`\n",
  "bytes": 38056,
  "sha": "27f28484bcc001500bbf316e8ca8dd3655959e3bda2175af20ecdc907baf5947",
  "repo_slug": "jmagar/ytdl-rmcp",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_ai_dinglebear_ytdl_rmcp_50d1adb1/readme"
}