Skip to main content
Glama

yt

Agent-first YouTube CLI — search, transcripts, metadata, and a local FTS5 cache for AI context retrieval. Wraps yt-dlp with JSON envelopes, NDJSON streaming, and an MCP co-binary.

No YouTube Data API key. No quotas. No rate-limit ceiling on the default path.

██╗   ██╗████████╗
╚██╗ ██╔╝╚══██╔══╝
 ╚████╔╝    ██║
  ╚██╔╝     ██║
   ██║      ██║
   ╚═╝      ╚═╝

Why

Existing YouTube tooling is either:

  • Built for humans (interactive TUIs like ytfzf),

  • Built for content creators (niche analysis, competitor audits),

  • Or locked inside MCP-only servers.

yt is built for agents — Claude Code, Cursor, Codex, Gemini CLI, and your bash scripts. One call (yt context <url>) hands an LLM everything it needs to reason about a video.

Install

# Requires yt-dlp on PATH
brew install yt-dlp

# From source
git clone https://github.com/progrmoiz/yt-cli
cd yt-cli
npm install && npm run build && npm link

Sanity check:

yt doctor

Quick start

# Search
yt search "rust async" --limit 5

# Grok a single video (the 80% agent use case)
yt context https://www.youtube.com/watch?v=dQw4w9WgXcQ

# Fetch transcript
yt transcript https://www.youtube.com/watch?v=dQw4w9WgXcQ --text

# Query everything you've cached
yt find "borrow checker"

# List a channel's recent videos
yt channel @ThePrimeTimeagen --limit 20

Piping switches output to JSON automatically (redis-cli pattern):

yt search "typescript" | jq '.data[0].url'
yt context <url> | jq '.data.transcript.full_text'

Commands

Command

Description

yt search <query>

YouTube search, no API key. --limit, --since 7d.

yt transcript <url>

Timestamped transcript JSON. Cached. --lang en, --text.

yt info <url>

Metadata: title, channel, chapters, duration. Cached.

yt context <url>

Headline. One-shot info + transcript + chapters for agents.

yt find <query>

FTS5 search over cached transcripts. Line-level hits with timestamps.

yt channel <handle|id|url>

Recent videos from a channel.

yt doctor [--deep]

Diagnostics: yt-dlp, cache, agent detection.

yt self-test

Regression suite — catches YouTube endpoint rot.

yt schema <cmd>

JSON schema for that command's output.

yt mcp serve

Stdio MCP server. Co-binary.

Agent integration

Claude Code / Cursor / etc — MCP

// .mcp.json
{
  "mcpServers": {
    "yt": { "command": "yt", "args": ["mcp", "serve"] }
  }
}

Tools exposed 1:1 with CLI commands: search, info, transcript, context, find, channel, whoami.

Scripts / shell

# Ingest the top 10 search hits into the local cache
yt search "machine learning ops" --limit 10 --json \
  | jq -r '.data[].url' \
  | xargs -I{} yt transcript {} --json >/dev/null

# Then query across all of them
yt find "feature store" --limit 5

Cache

SQLite database at ~/.cache/yt/yt.db. Contents:

  • videos — one row per video (metadata).

  • transcripts — one row per (video, language) pair.

  • transcript_segments_fts — FTS5 virtual table over every transcript segment.

Override with YT_CACHE_DIR=/path/to/dir.

Every transcript / info / context call cache-checks first. Pass --refresh to force a fresh fetch.

Output shape

Default envelope (v2):

{
  "version": "2",
  "status": "success",
  "command": "context",
  "cli": { "name": "yt", "version": "0.1.0" },
  "data": { /* command payload */ },
  "metadata": {
    "elapsed_ms": 1200,
    "cached": true,
    "has_transcript": true,
    "agent": "CLAUDECODE"
  }
}

Use --raw for bare data. Full JSON schema via yt schema <command>.

Exit codes

0 ok · 1 generic · 2 usage · 3 validation · 4 auth · 5 rate_limit · 6 network · 7 not_found · 75 temp_fail

Environment

Var

Purpose

YT_CACHE_DIR

Cache directory (default: ~/.cache/yt)

YT_DLP_BIN

Override path to the yt-dlp binary

YT_NO_RETRY

Set to 1 to disable the single auto-retry on RATE_LIMIT/NETWORK/TIMEOUT

YT_JSON=1

Force JSON output

YT_API_KEY

Reserved for future Data API extras

NO_COLOR

Disable ANSI

CI

Force non-interactive mode

License

MIT.

Related MCP Connectors

  • YouTube transcripts, search, channel browsing, and playlists for AI agents via MCP.

  • An MCP server that gives any LLM or agent clean YouTube transcripts on demand: a single video, a whole channel, or a playlist, plus AI cleanup of auto-generated captions. API-key auth, credit-based, same backend as the public v1 API. Get a free API key with 25 free credits at youtubetranscriptdownload.com/account.

  • YouTube transcripts, search, channel/playlist listings and upload tracking for AI agents.

  • Your agent needs to find video — which channels own a topic, which videos rank for a phrase, what exists in a given country and language. **What you can ask for** • "Which videos rank for 'rag pipeline tutorial' in the US this month?" • "Find channels publishing about MCP, sorted by relevance." • "What playlists cover this subject in Japanese?" • "Search videos uploaded this week only." **How to use it** Point any MCP client at https://mcp.aisa.one/youtube-search/mcp and sign in with OAuth — there is no key to create or paste. One search tool covering videos, channels and playlists, narrowed by country, language, upload date, duration and sort order. **It is also a door to the rest** The same login reaches 26 sources and 580+ operations. Find the video here, then ask the same agent what the channel's site traffic is or what the same phrase does in Google — without adding a second server. **What it costs** Finding and inspecting an operation is free. Running one is billed per call at API prices, with no seat and no monthly minimum, and every call takes max_price_usd so an agent cannot overspend by accident. **Where else it reaches** https://mcp.aisa.one/social/mcp for X plus Instagram, Reddit, Pinterest and YouTube; https://mcp.aisa.one/gtm/mcp for those plus Similarweb and Apollo.