Skip to main content
Glama

YT-MCP: YouTube Video Intelligence MCP Server

A local Model Context Protocol server (stdio) that lets any MCP-compatible AI client (Claude, ChatGPT, Gemini) work with YouTube through the official YouTube Data API v3 only:

Tool

What it does

Auth

get_video_details

Public metadata for one video (summary basis)

API key or OAuth

find_similar_videos

FR-1: rank similar videos, with reasons

public data

find_similar_channels

FR-2: rank similar channels, with reasons

public data

recommend_videos

FR-3: recommendations from your likes, subscriptions and playlists

OAuth (read)

analyze_engagement

FR-4: top channels/categories, duration preferences, trends

OAuth (read)

propose_playlist

FR-5: build and preview a playlist under duration/language limits (writes nothing)

public data

create_playlist

FR-5: create the previewed playlist after explicit confirmation

OAuth (write)

auth_start

Google sign-in (or sign-out with revoke=true)

user consent

get_server_status

Mode, sign-in state, quota estimate, cache (no secrets)

none

MCP resources skill://video-to-playlist and skill://local-check serve the Agent Skill instructions. Course project for Software Engineering, IIIT Bangalore. The requirements baseline is SRS v1.4 (docs/).

Similarity scores are computed locally (TF-IDF + cosine + weighted category/duration/tags) because YouTube has no related-videos endpoint. They are not YouTube metrics. Personal analysis uses likes, subscriptions and playlists. The API exposes no watch history.


1. Install

Requires Python 3.11+.

git clone https://github.com/AryanOg0209/SELab_MCPServer.git
cd SELab_MCPServer
python -m venv .venv
# macOS/Linux: source .venv/bin/activate      Windows: .venv\Scripts\activate
pip install -e ".[dev]"
python skills/local-check/scripts/local_check.py      # build, tests, server, one tool call

Related MCP server: YouTube MCP Server

2. Modes

YT_MCP_MODE

Data source

Network

Use for

replay (default)

synthetic fixtures in fixtures/

none

development, tests, CI, rehearsal

live

YouTube Data API v3

HTTPS

the real demo

Replay mode simulates a signed-in demo account. Set YT_MCP_REPLAY_AUTH to granted, readonly, none, no_channel or expired to try the error paths.

3. Live-mode setup (Google Cloud)

  1. Create a Google Cloud project and enable YouTube Data API v3.

  2. API key (public reads): APIs & Services -> Credentials -> Create credentials -> API key. Restrict it to the YouTube Data API.

  3. OAuth client (personal data and playlist creation): configure the OAuth consent screen (External, Testing, add your Google account as a test user). Then Create credentials -> OAuth client ID -> Desktop app and download the JSON to a path outside the repository, e.g. ~/.yt-mcp/client_secret.json.

  4. Testing-mode refresh tokens expire after 7 days. When a tool returns AUTH_EXPIRED, run auth_start again.

Never commit keys or client secrets. .gitignore blocks client_secret*.json, oauth_token.json and .env, and CI runs secret scanning.

Environment variables

Variable

Default

Meaning

YT_MCP_MODE

replay

replay or live

YT_MCP_API_KEY

-

API key for public reads (live)

YT_MCP_CLIENT_SECRETS

-

path to the OAuth client JSON (live)

YT_MCP_DATA_DIR

~/.yt-mcp

SQLite cache/ledger/proposals and the 0600 token file

YT_MCP_DAILY_UNIT_LIMIT

10000

daily unit budget

YT_MCP_DAILY_SEARCH_LIMIT

100

daily search.list call budget

YT_MCP_QUOTA_RESERVE_UNITS

200

units never planned away

YT_MCP_COST_SEARCH_UNITS

0

units charged per search.list from the main pool (set 100 if your project uses the classic cost)

YT_MCP_CACHE_TTL_VIDEO / _CHANNEL / _SEARCH / _UPLOADS

24h / 7d / 6h / 12h

cache TTLs in seconds (max 30 days)

YT_MCP_PROPOSAL_TTL

1800

playlist proposal lifetime in seconds

YT_MCP_MIN_VIDEO_SECONDS

60

playlists skip videos shorter than this (Shorts); 0 disables

YT_MCP_ENV_FILE

~/.yt-mcp/env

private file the server reads YT_MCP_* settings from, so MCP client configs need no secrets

YT_MCP_HTTP_TIMEOUT / YT_MCP_HTTP_RETRIES

10 / 2

per-request timeout and max retries

4. Connect an MCP client

Claude Desktop: claude_desktop_config.json (Settings -> Developer -> Edit config):

{
  "mcpServers": {
    "yt-mcp": {
      "command": "/absolute/path/to/SELab_MCPServer/.venv/bin/python",
      "args": ["-m", "yt_mcp"],
      "env": {
        "YT_MCP_MODE": "live",
        "YT_MCP_API_KEY": "<your API key>",
        "YT_MCP_CLIENT_SECRETS": "/Users/<you>/.yt-mcp/client_secret.json"
      }
    }
  }
}

On Windows use C:\\path\\to\\SELab_MCPServer\\.venv\\Scripts\\python.exe.

Claude Code:

claude mcp add yt-mcp --env YT_MCP_MODE=replay -- /abs/path/.venv/bin/python -m yt_mcp

MCP Inspector (no LLM, raw calls): npx @modelcontextprotocol/inspector .venv/bin/python -m yt_mcp

5. Tool examples

Arguments are JSON. Every response has "ok": true|false.

// get_video_details
{"video": "https://www.youtube.com/watch?v=pyBasics001"}

// find_similar_videos  (FR-1)
{"video": "pyDecorat01", "max_results": 5}
// -> results[].similarity, results[].why_similar ["shares key terms: functions, python", ...]

// find_similar_channels  (FR-2)
{"channel": "@pythontutorhub", "max_results": 5}

// recommend_videos  (FR-3, OAuth read)
{"max_results": 10}

// analyze_engagement  (FR-4, OAuth read)
{"period_days": 90}

// propose_playlist  (FR-5) - "two hours on python, nothing over 20 minutes"
{"topic": "python beginners", "total_minutes": 120, "max_video_minutes": 20, "language": "en"}
// -> proposal_id, proposal_hash, videos[], total_minutes, privacy: "private", unmet_constraints[]

// create_playlist  (FR-5, OAuth write) - ONLY after the user says yes
{"proposal_id": "<from propose>", "proposal_hash": "<from propose>", "confirmed": true}

// auth_start
{"scopes": "read"}          // or "read_write" before creating playlists; {"revoke": true} signs out

// get_server_status
{}

Error format

{
  "ok": false,
  "error": {
    "code": "QUOTA_BUDGET_EXCEEDED",
    "message": "This request would exceed the remaining YouTube quota budget, so it was rejected before any API call.",
    "next_action": "Try a smaller request ... or wait for the daily quota reset (midnight Pacific Time).",
    "details": {"estimated_cost": {"units": 2, "search": 1}, "remaining": {"units": 0, "search": 93}}
  }
}

The MCP isError flag is set on failures. All codes are listed in docs/tool-reference.md.

6. Development

pytest                                    # 200+ tests, fixtures only (TQ-1..TQ-6, TQ-8, security)
pytest -m live tests/live                 # real API, fixed budget; needs YT_MCP_API_KEY (TQ-5)
ruff check src tests scripts skills && ruff format --check src tests scripts skills
python scripts/validate_skills.py         # SKILL.md frontmatter/naming/brain links
python scripts/validate_brain.py          # vault schema, broken links, ADR citations
python scripts/run_skill_evals.py         # skill evaluations (TQ-7) -> docs/testing/
python scripts/scan_secrets.py            # secret scan
python scripts/make_fixtures.py           # regenerate synthetic fixtures

7. Repository map

src/yt_mcp/            server.py (MCP adapter), services/ (FR-1..FR-5), provider/ (live, replay, cache),
                       auth/ (OAuth, tokens), quota.py, storage.py, validation.py, config.py
tests/                 unit/ integration/ e2e/ security/ live/
fixtures/              synthetic YouTube API-shaped data (no real user data)
skills/                video-to-playlist, local-check, brain-ingest, brain-refine, brain-query
brain/                 Obsidian second brain (PARA, index.md, log.md)
docs/                  design/ adr/ testing/ reviews/ development-plan, traceability, tool-reference
.github/workflows/     ci.yml (every PR), live-tests.yml (scheduled)
AGENTS.md              rules for AI coding agents working in this repo

8. Team

Kabir Ahuja (BT2024004) · Aryan Malik (BT2024006) · Naman Jindal (BT2024203). See CONTRIBUTING.md for the branching strategy and review rules.

Available Tools

9 tools
analyze_engagementA
Read-only

FR-4 (OAuth): analyse the user's liked videos, subscriptions and playlists - top channels/categories, duration preferences, trends and period comparison. This is not watch history; app-computed values are labelled.

Inputs: period_days.

auth_startA

FR-6: start Google OAuth sign-in (returns a consent link), or sign out with revoke=true. Requests only the scopes needed. Use again when a sign-in expires (Testing mode refresh tokens expire after 7 days).

Inputs: revoke, scopes.

create_playlistA
Idempotent

FR-5 step 2 (OAuth write scope): create the displayed proposal in the user's account. Requires the user's explicit approval (confirmed=true), an unchanged and unexpired proposal, a YouTube channel and enough quota. Private by default. Retrying the same proposal never creates a duplicate playlist.

Inputs: proposal_id (required), proposal_hash (required), confirmed.

find_similar_channelsA
Read-only

FR-2: find and rank channels similar to a given channel using channel descriptions and recent-upload metadata, with brief reasons. Works when statistics are hidden.

Inputs: channel (required), max_results, candidate_pool.

find_similar_videosA
Read-only

FR-1: find and rank videos similar to a given video, with reasons. Ranking is local (TF-IDF + cosine + category/duration/tag scoring) because YouTube has no related-videos endpoint.

Inputs: video (required), max_results, candidate_pool.

get_server_statusA
Read-only

Report provider mode, sign-in state, quota estimate and cache status. Never shows credentials.

Inputs: no named parameters.

get_video_detailsA
Read-only

Fetch public metadata for one video (title, description, tags, category, duration, channel, language). Use it to summarise a video from official metadata only.

Inputs: video (required).

propose_playlistA
Read-only

FR-5 step 1: build and preview a playlist that never exceeds the total duration or per-video limit. Writes nothing. Show the preview to the user and get explicit approval before calling create_playlist. Example: 'two hours on X, no video over 20 minutes' -> total_minutes=120, max_video_minutes=20.

Inputs: topic (required), total_minutes (required), title, privacy, +2 more.

recommend_videosA
Read-only

FR-3 (OAuth): recommend videos from the signed-in user's liked videos, subscriptions and playlists, with short explanations. Watch history is not available from the API.

Inputs: max_results.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 9 tools

    Disambiguation4/5

    Each tool targets a distinct action+object, and the propose_playlist/create_playlist pair is explicitly documented as a preview-then-commit workflow with a required approval gate. The only mild overlap is find_similar_videos versus recommend_videos, but seed-video-based vs user-history-based inputs and OAuth requirements make the boundary clear enough.

    Naming Consistency4/5

    Nearly all tools follow a verb_noun pattern (get_video_details, find_similar_channels, create_playlist, analyze_engagement, get_server_status). The one outlier is auth_start, which uses noun_verb ordering, but it remains readable and otherwise fits the lowercase snake_case convention.

    Tool Count5/5

    Nine tools is well within the ideal range and each one maps to a distinct requirement (auth, metadata, similarity, recommendation, analytics, playlist proposal/creation, status). Nothing looks redundant or bolted on.

    Completeness4/5

    The surface covers the full lifecycle it advertises: sign-in/out, video metadata, similarity discovery, personalization, engagement analysis, and playlist preview plus creation. Gaps remain in keyword/channel search (agents must obtain seed IDs elsewhere) and playlist management beyond creation (no list/update/delete).

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers