YouTube MCP Server & CLI

A free, open source YouTube MCP server and CLI that lets Claude Code, Codex, Cursor and other AI agents read any public video's transcript, research channels and manage your own.

Navid Moazzezby Navid Moazzez·Updated 30 sept 2026·10 min read
~/youtube-mcp-cli
$ claude
Claude Code v2.1.220
>
Rate this tool

This free YouTube MCP server and CLI gives your AI real access to YouTube: the transcript of any public video, search and channel research, and your own channels' videos, comments and analytics. It reads what was said in any public video, compares channels, and manages your own videos and comments.

It's one install with 2 ways in. Claude, Codex, Cursor or any other MCP app calls its 16 tools for you, and the same tools work as a CLI that agents like Claude Code, Codex and OpenCode run, or that you type yourself.

Here's what the YouTube MCP server and CLI is, how to set it up in each app, and every tool it has.

What is the YouTube MCP server & CLI?

The YouTube MCP server & CLI is a free, open source program that lets AI agents read transcripts, research channels and manage your own YouTube channels for you, in 2 ways. The MCP server is what an AI app like Claude, Codex or Cursor connects to, through MCP (Model Context Protocol), the open standard AI apps use to call outside tools.

You ask in plain language. Your AI picks the right tool, and the server makes the call to YouTube, and to Google's API with your own key.

The CLI is the same program as commands. youtube-cli get-transcript --video <url> runs the same code your AI runs when you ask what a video says, whether an agent like Claude Code runs it or you do.

What can you ask it?

Once it's set up, you ask the way you'd ask an assistant. These are real prompts it handles:

Try asking
Summarize this video in five bullets.
Find where she talks about retention in this talk.
Pull the transcripts of these six videos and tell me what the openings have in common.
Which of this channel's last 30 videos actually overperformed?
Read the comments on this video and group them by what people are asking for.
What did my last video do on watch time versus the one before?

The first one shows why this is useful. YouTube's own caption API only serves videos you own, and this reads the public captions of any video, with no key at all.

How to install the YouTube MCP server

Pick your app in the box at the top of this page. Each one is a single command or a pasted block, and transcripts work with nothing else set up.

Before you start0/3

Pro tip: Start with transcripts. They need no key and no account, so you can try the server before any Google setup.

⚠️

Watch out: Publish the OAuth app under Audience. An app left in testing gets refresh tokens that expire after 7 days, and the login stops working every week.

Set up YouTube

There are 3 levels, and most people never need the third.

Transcripts need nothing. Search, research and comments need an API key, which takes about 10 minutes. Your own channels need OAuth, which takes about half an hour, most of it forms.

Get an API key0/3
Connect your own channels0/3

The saved channels live in ~/.youtube-mcp-cli/channels.json, encrypted, and every app on this computer uses them. The full walkthrough is in the repo's INSTALL.md.

Check that it works

Run the doctor. It checks yt-dlp, the API key and each connected channel separately.

npx -y @thenavidm/youtube-mcp-cli doctor

Exit code 10 means nothing is configured for that level yet. unauthorized_client means the token came from a different OAuth client than the one set now.

Use the YouTube CLI

The CLI is the same 16 tools as commands. AI agents that run commands, like Claude Code, Codex and OpenCode, use it on their own, and you can type the same commands in a terminal or a script.

Every tool name becomes a command with dashes, so get_transcript runs as youtube-cli get-transcript.

npm install -g @thenavidm/youtube-mcp-cli
youtube-cli
youtube-cli get-transcript --video https://youtu.be/jNQXAC9IVRw
youtube-cli search-videos --query "claude code" --max-results 5
youtube-cli list-my-videos --limit 10

The bare youtube-cli lists every command, and youtube-cli <command> --help shows what a command takes. Deleting a video and replying to a comment ask for --confirm first, like they do for your AI.

These flags work on every command:

FlagWhat it does
--jsonPrints JSON
--compactPrints the JSON on one line
--agentMachine mode: JSON, compact, no prompts and no color
--select a,b.cKeeps only those fields, and a dotted path goes deeper
--confirmLets a write that asks first go ahead

A script can branch on the exit code:

Exit codeWhat it means
0It worked
2The command was typed wrong, or a write needed --confirm
3It wasn't found
4YouTube rejected the credentials
5YouTube's API failed
7You hit a rate limit, so wait and try again
10Nothing is set up yet

MCP server or CLI: which one?

Both are the same program with the same 16 tools. The difference is when your AI pays for them, in the tokens it reads.

Every message, in an app that loads every tool
MCP server
5,000 tokens
CLI
Nothing
Every message, in Claude Code
MCP server
490 tokens
CLI
Nothing
When YouTube comes up
MCP server
Nothing more, or in Claude Code the tools it picks
CLI
2,300 tokens, once
20 messages with YouTube in 1, every tool loaded
MCP server
100,000 tokens
CLI
2,300 tokens
Works in Claude Desktop's chat
MCP server
Yes
CLI
No, there's no terminal there
Works in a script, a cron job or CI
MCP server
No
CLI
Yes

An app that loads every tool up front sends the full list with every message, whether you mention YouTube or not. Claude Code doesn't by default: its tool search sends only the tool names and the server's instructions, and loads a tool's full definition when your AI reaches for it.

The CLI costs nothing until YouTube comes up. Then your agent reads its skill file once and runs the commands it needs. With the skill added, Claude Code also lists its one-line description with every message, about 160 tokens.

When the whole conversation is about YouTube, the gap closes. Then the MCP server is the better experience, because you ask in plain language and your AI never has to look up a command.

How to spend less

In Claude Code, leave tool search on, which it is unless you've set ENABLE_TOOL_SEARCH=false.

Turn the server off when you aren't using YouTube, with your AI app's own switch. YOUTUBE_READ_ONLY=1 cuts it to the 13 reading tools.

Or install the CLI and connect the server later, on the days it earns its place. Every tool stays in reach, and the standing cost drops to nothing.

Every number here was measured on September 27, 2026 in Claude Code 2.1.257 with Claude Opus 5. It's the same one-line prompt with and without the server connected, once with tool search off so every tool loads, and once with Claude Code's default. The skill was measured the same way, and other apps and models count tokens a little differently.

What YouTube actually does

A few things on YouTube's side explain most surprises.

Search has its own small allowance

A search draws from its own bucket of 100 calls a day, separate from the 10,000 units the rest of the API shares. It's almost always search that runs out first.

Analytics is only for your own channels

Watch time, retention and traffic sources aren't public for anyone else's channel, at any price, and they lag about 2 days.

Public subscriber counts are rounded

YouTube rounds counts above 1,000 in its public API, so your channel's public count and its own count differ. The one from your own channel is exact.

Shorts skew the averages

Shorts views aren't comparable to long videos on the same channel, so analyze_channel flags them rather than averaging them in.

Every YouTube tool

All 16 tools, grouped the way the repo groups them. 13 only read, and 3 change something on your channel.

Transcripts

get_transcript
What it does
Read the transcript of ANY public YouTube video, not just your own.
Kind
Reads
list_transcript_languages
What it does
List every caption language on a video and whether each was written by a human or auto-generated.
Kind
Reads
search_transcript
What it does
Find every place a phrase is said in a video and get the timestamps, each as a link that jumps to that second.
Kind
Reads
get_transcripts
What it does
Fetch transcripts for up to 20 videos in one call.
Kind
Reads

Research

search_videos
What it does
Search YouTube and get results WITH view counts, likes and duration attached.
Kind
Reads
get_channel
What it does
Look up any channel by @handle, id or URL.
Kind
Reads
analyze_channel
What it does
Score a channel's recent videos against its OWN median views, so you can see which ones genuinely outperformed rather than which are simply oldest.
Kind
Reads
get_video
What it does
Full detail for one video: title, description, channel, views, likes, comments, duration and tags.
Kind
Reads

Your channels

list_accounts
What it does
List every YouTube channel connected to this server.
Kind
Reads
get_my_channel
What it does
Details for a connected channel: subscribers, total views, video count and the uploads playlist id.
Kind
Reads
get_channel_analytics
What it does
Watch time, average view duration, retention percentage, traffic sources and subscriber change for a connected channel.
Kind
Reads
list_my_videos
What it does
List videos on a connected channel, newest first, with views and likes.
Kind
Reads
list_comments
What it does
Read comment threads on a video, newest or most relevant first.
Kind
Reads
update_video
What it does
Change a video's title, description, tags or privacy.
Kind
Writes
reply_to_comment
What it does
Post a public reply to a comment thread as the connected channel.
Kind
Asks first
delete_video
What it does
Permanently delete a video from a connected channel.
Kind
Asks first

Is the YouTube MCP server safe?

Writes work from the start, because managing a channel is the point. The two that can't be undone ask first.

delete_video and reply_to_comment ask for a confirm check first, marked Asks first in the tool tables above. YouTube deletes a video at once, with no trash, and a reply is public and notifies someone.

Make it read-only

Set YOUTUBE_READ_ONLY=1 and every write disappears from the tool list, leaving 13. YOUTUBE_ALLOW_DESTRUCTIVE=0 keeps editing titles and blocks the two irreversible tools.

Keep a log of every write

Set YOUTUBE_AUDIT_LOG to a file path. The server writes one line per attempted write, allowed or blocked.

⚠️

Watch out: Comments, titles, descriptions and transcripts are written by other people, and some are written to steer whatever reads them. The server tells your AI to treat them as data, but for an agent working on its own, YOUTUBE_READ_ONLY=1 is the real defense.

Your data

There's no server of ours in between. Every request goes from your computer to YouTube and Google directly.

youtube-cli login saves your channels and API key to ~/.youtube-mcp-cli/channels.json, encrypted with a key derived from your computer and never stored, so a copied file is useless elsewhere. The audit log is written only when you set YOUTUBE_AUDIT_LOG.

Several channels

Run youtube-cli login once per channel, picking a different one in Google's chooser each time. Brand channels on the same Google account show up there too, and youtube-cli list-accounts shows them all.

Pass --account on the command line, or account through your AI, to pick one. With a single channel connected, you never need it.

YouTube MCP server settings

Every setting is an environment variable in your app's config. None are needed for transcripts, or on a computer where you ran youtube-cli login.

YOUTUBE_API_KEY
Default
the saved key
What it does
Unlocks search, channel lookup and comments
YOUTUBE_CLIENT_ID
Default
none
What it does
Names your OAuth client, for login and your own channels
YOUTUBE_CLIENT_SECRET
Default
none
What it does
Holds that client's secret
YOUTUBE_ACCOUNTS
Default
none
What it does
Lists several channels at once, as the JSON youtube-cli login --print prints
YOUTUBE_READ_ONLY
Default
0
What it does
1 hides every write
YOUTUBE_ALLOW_DESTRUCTIVE
Default
1
What it does
0 blocks deleting videos and replying to comments
YOUTUBE_TRANSCRIPT_LANG
Default
en
What it does
Sets the default transcript language
YOUTUBE_YTDLP_PATH
Default
yt-dlp on your PATH
What it does
Points at yt-dlp, when your app can't find it

Troubleshooting

Run the doctor first. It names the step that failed and the fix.

What you seeWhat to do
"yt-dlp is not installed"Transcripts need it: brew install yt-dlp
"Access blocked" at the consent screenThe channel's Google address isn't a test user in your Cloud project
The login stops working after a weekThe OAuth app is still in testing. Publish it under Audience and log in again
quotaExceededThe daily quota resets at midnight Pacific
Search stops working before anything elseSearch has its own 100-call daily allowance
A command lists your channels and stopsTwo or more are connected. Pass --account

If the server doesn't show up in your app at all, run the command your app runs, in a terminal, and read the error.

More free tools for YouTube

Find videos that beat their channel's average, write chapter timestamps, or check a title before you publish.

YouTube MCP Server FAQs

Here are the questions people ask most about the YouTube MCP server and CLI.

The YouTube MCP server & CLI is a free, open source program that lets an AI app like Claude, Codex or Cursor read transcripts, research channels and manage your own YouTube channels.

It has 16 tools for transcripts, research, and your own channels' videos, comments and analytics, and the same tools run as a CLI that agents like Claude Code and Codex use, or that you type yourself.

An MCP server is a standard way to give an AI app real access to a tool, so it can act instead of guessing.

MCP stands for Model Context Protocol, and Claude, Codex, Cursor and many other AI apps speak it.

The YouTube CLI is the same program as the YouTube MCP server, run as commands.

AI agents like Claude Code, Codex and OpenCode run them for you, and you can type them in a terminal or a script.

Use the YouTube MCP server in an AI app with no terminal, like Claude Desktop's chat, and the CLI in a terminal, a script or a cron job.

In an AI app that can run commands, like Claude Code, Codex or Cursor, the CLI is the lighter choice, because it costs nothing until it runs.

Yes, the YouTube MCP server is free and open source under the MIT license, and Google's API costs nothing within its daily quota.

Transcripts need no key at all.

Yes, any public video with captions, including other people's, with no key and no account.

It reads the public caption tracks through yt-dlp, which needs to be installed.

Only for search, channel research and comments.

Transcripts need nothing, and your own channels need an OAuth login instead.

Yes, run youtube-cli login once per channel, brand channels included.

Each tool then takes an account to pick one.

Only when you ask, and only after a confirm check, because YouTube deletes a video at once with no trash.

YOUTUBE_READ_ONLY=1 removes every write.

The YouTube MCP server works with any app that speaks MCP.

That includes Claude Code, Claude Desktop, Codex, Cursor, VS Code, GitHub Copilot CLI, Gemini CLI, OpenCode, OpenClaw, Antigravity and Hermes.

Navid Moazzez built the YouTube MCP server and maintains it.

The code is on GitHub under the MIT license, and the package is on npm.

Navid Moazzez

AI business strategist & AI OS builder

Navid Moazzez helps creators and founders master AI and build their own AI Operating System (AI OS) to automate their business and life.

Navid.me is reader-supported. When you buy through links on this site, I may earn an affiliate commission. Learn more.

More MCP servers & CLIs

Free AI newsletter

The most actionable AI newsletter for founders

Every week, get proven AI strategies, curated tools, and step-by-step systems to grow your audience, create better content, and build a profitable creator business.

No fluff, no filler, no BS. Just five minutes each week that might level up your online business and life.

P.S. Sign up now to get free access to my ultimate AI tools guide for creators.

Loved by 10,000+ readers