YT-MCP
Uses the official YouTube Data API v3 to retrieve video details, rank similar videos and channels, generate personalized recommendations from likes/subscriptions/playlists, analyze engagement, and propose or create playlists.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@YT-MCP recommend some videos based on my likes and subscriptions"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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 |
| Public metadata for one video (summary basis) | API key or OAuth |
| FR-1: rank similar videos, with reasons | public data |
| FR-2: rank similar channels, with reasons | public data |
| FR-3: recommendations from your likes, subscriptions and playlists | OAuth (read) |
| FR-4: top channels/categories, duration preferences, trends | OAuth (read) |
| FR-5: build and preview a playlist under duration/language limits (writes nothing) | public data |
| FR-5: create the previewed playlist after explicit confirmation | OAuth (write) |
| Google sign-in (or sign-out with | user consent |
| 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 callRelated MCP server: YouTube MCP Server
2. Modes
| Data source | Network | Use for |
| synthetic fixtures in | none | development, tests, CI, rehearsal |
| 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)
Create a Google Cloud project and enable YouTube Data API v3.
API key (public reads): APIs & Services -> Credentials -> Create credentials -> API key. Restrict it to the YouTube Data API.
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.Testing-mode refresh tokens expire after 7 days. When a tool returns
AUTH_EXPIRED, runauth_startagain.
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 |
|
|
|
| - | API key for public reads (live) |
| - | path to the OAuth client JSON (live) |
|
| SQLite cache/ledger/proposals and the 0600 token file |
|
| daily unit budget |
|
| daily |
|
| units never planned away |
|
| units charged per |
| 24h / 7d / 6h / 12h | cache TTLs in seconds (max 30 days) |
|
| playlist proposal lifetime in seconds |
|
| playlists skip videos shorter than this (Shorts); |
|
| private file the server reads |
|
| 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_mcpMCP 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 fixtures7. 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 repo8. Team
Kabir Ahuja (BT2024004) · Aryan Malik (BT2024006) · Naman Jindal (BT2024203). See CONTRIBUTING.md for the branching strategy and review rules.
Available Tools
9 toolsanalyze_engagementARead-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_playlistAIdempotent
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_channelsARead-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_videosARead-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_statusARead-only
Report provider mode, sign-in state, quota estimate and cache status. Never shows credentials.
Inputs: no named parameters.
get_video_detailsARead-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_playlistARead-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_videosARead-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
Scored across 9 tools
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.
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.
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.
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
Related MCP Connectors
Unofficial YouTube MCP — wraps the YouTube Data API v3 (BYO API key)
YouTube transcripts, search, channel/playlist listings and upload tracking for AI agents.
YouTube for AI agents: transcripts, comments, video stats, channel monitor, Shorts captions.
Search YouTube videos, read transcripts and get public video information in your AI assistant.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables interaction with YouTube through the YouTube Data API, allowing users to search for videos, playlists, and channels, generate video titles using AI, and manage YouTube content through natural language commands.22ISC
- AlicenseAqualityDmaintenanceEnables YouTube content browsing, video searching, and metadata retrieval via the YouTube Data API v3. It also facilitates fetching video transcripts for summarization and analysis within MCP-compatible AI clients.71MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI models to interact with YouTube content through 18 MCP tools for videos, transcripts, channels, and playlists.-
- AlicenseNot gradedqualityCmaintenanceEnables interaction with YouTube via MCP, including search, transcript retrieval, trending videos, and AI community discovery.MIT