Skip to content
Back to blog
  • MCP
  • YouTube
  • Codex

How to add a YouTube MCP server to Codex

Add a YouTube MCP server to Codex in two commands. Search videos, read transcripts and pull comments from inside your coding agent, with no YouTube API key.

A YouTube MCP server lets your coding agent search YouTube, read transcripts and pull comments as tool calls. To add one to Codex, run codex mcp add stophy --url https://mcp.stophy.dev/mcp and then codex mcp login stophy. You need no YouTube API key and no Google account.

Stophy is the web data API for AI agents. Its MCP server lets Codex search YouTube and read videos, transcripts, comments and channels. I ran four real tasks and pasted what came back. I did not want to change the Codex setup on this machine, so I ran each call with the Stophy CLI or through the MCP server from another client. The arguments are the ones an agent sends. Where output is long, I cut it and say so.

The short version

TaskEndpointCredits
Search videosyoutubeSearch1
Read a transcriptyoutubeTranscript1
Pull commentsyoutubeComments1
Check a video's statsyoutubeVideo1
Read a channelyoutubeChannel1
Playlists, hashtags, related videos, chartsMore endpoints1

What is a YouTube MCP server?

MCP is the Model Context Protocol, the standard way for a coding agent to call outside tools. An MCP server lists those tools, and the agent decides when to call them.

A YouTube MCP server is one that exposes YouTube as tools. Without it, Codex cannot see a video. It cannot read what a talk says, count the views on a launch or list what people ask in the comments. With it, you type a normal sentence and Codex makes the call.

The Stophy server also covers Reddit, Google and other sites, so you add it once. See the MCP page for other agents.

1. Add the server to Codex

Codex has a built in command for MCP servers. Run these two lines. The first registers the server. The second opens your browser so you can sign in.

terminal
codex mcp add stophy --url https://mcp.stophy.dev/mcp
codex mcp login stophy

Sign-in uses OAuth, so there is no key to copy and no file to edit. I checked both commands against codex mcp --help on Codex 0.160.0. I did not run them on my machine, because I already use Stophy through another client. To confirm the server is there, list your servers.

terminal
codex mcp list

You should see stophy in the list with the status enabled. The server gives the agent three tools. stophy_search_endpoints finds an endpoint from plain words. stophy_describe_endpoint shows its inputs and output fields. stophy_call runs it.

Honest take. Sign in once and you are done. There is no key to store and no config file to edit.

2. Search videos

This is the first thing I ask any new YouTube tool. In Codex you would type this.

prompt
Find the most watched tutorials about the Model Context Protocol from this year. I want videos between 3 and 20 minutes.

The agent finds the endpoint, youtubeSearch, and calls it with these arguments.

stophy_call
{
"id": "youtubeSearch",
"input": {
"query": "model context protocol tutorial",
"duration": "3to20Minutes",
"uploadDate": "thisYear",
"prioritize": "popularity"
}
}

I ran this one through the CLI so I could save the whole response. It is the same endpoint. The call returned 20 results and a cursor for the next page. Here are the first two, cut to four fields each.

response
[
{
"title": "MCP vs API: Why traditional APIs are failing AI agents",
"channelName": "Google Cloud Tech and Smitha Kolan - Machine Learning Engineer",
"durationSeconds": 745,
"views": 1141927
},
{
"title": "What AI Agent Skills Are and How They Work",
"channelName": "IBM Technology",
"durationSeconds": 745,
"views": 492557
}
]

The filters did what they said. Every result in the top three ran between 3 and 20 minutes. The third was a 217 second video from the Claude channel with 364,727 views, which I use below. The YouTube search API page lists every filter.

Honest take. Search matches words, not meaning, so read the titles before you trust the ranking. The publish date in a search result is also approximate. For this video, search said 2026-06-08 and a direct lookup said 2026-05-09. Use the lookup when the date matters.

3. Read a transcript

prompt
Get the transcript of https://www.youtube.com/watch?v=kkBFmwkDzdo with timestamps. Which part explains local servers?

The agent calls youtubeTranscript with the video id and includeTimestamps set to true. The response has the full text and a list of timed segments. This is the real response, with the text cut to its first sentence and the segments list cut to two entries out of 100.

response
{
"videoId": "kkBFmwkDzdo",
"language": "en",
"isAutoGenerated": true,
"durationSeconds": 217,
"text": "Model contact protocol is an open standard that lets Claude code connect to external tools and data sources. ...",
"segments": [
{ "startSeconds": 2.88, "endSeconds": 6.56, "text": "Model contact protocol is an open" },
{ "startSeconds": 87.56, "endSeconds": 92.4, "text": "STDIO servers are for local processes" }
]
}

The segment list answers the question. Local servers come up at 87.56 seconds, in the line that says STDIO servers are for local processes. That is the point of timestamps. The agent can send you to the second instead of summarizing a whole video.

Look at the first line. The captions read Model contact protocol, and the video says Model Context Protocol. isAutoGenerated is true, so a machine wrote them. The field is there so you know when to read with care. There is also a free transcript tool if you want one video without an agent.

Honest take. A transcript is the cheapest way to let an agent read a video, at one credit. The weak spot is names, which auto captions get wrong.

4. Pull comments

prompt
Read the top comments on that video. What are people complaining about?

The agent calls youtubeComments. This one I ran through the MCP server itself, with fields so only four keys come back and maxTextLength to shorten each comment. The arguments were these.

stophy_call
{
"id": "youtubeComments",
"input": { "videoId": "kkBFmwkDzdo", "sort": "top" },
"fields": ["text", "authorName", "likes", "replies"],
"maxTextLength": 80
}

The call returned 20 comments and a cursor, and it cost 1 credit. Three of them.

response
[
{ "text": "\"How to consume more tokens and become an addict.\"", "authorName": "trappedcat3615", "likes": 105, "replies": 0 },
{ "text": "Tokens limit reached", "authorName": "knowledgeguru9175", "likes": 46, "replies": 2 },
{ "text": "MCP server scope for local and user, same path?!", "authorName": "mutlulukumut9665", "likes": 0, "replies": 0 }
]

Several of the 20 comments were about usage limits and billing, and one asked a real question about server scope. An agent can group them for you. The comment downloader does the same call from a web page and gives you a .csv file.

Honest take. Top is YouTube's own ranking, not a strict sort by likes. The first comment had 105 likes and the next had 0. Sort by newest when you want the latest, and read the like counts yourself before you quote a number.

5. Check a video and its channel

prompt
How big is the Claude channel, and how is that MCP video doing?

The agent makes two calls, youtubeVideo for the video and youtubeChannel for the channel. Both responses are long, so these are the fields that matter.

youtubeVideo
{
"title": "MCP in Claude Code",
"channelName": "Claude",
"channelSubscribers": 621000,
"durationSeconds": 217,
"views": 364727,
"likes": 1888,
"comments": 61,
"mostReplayedAtSeconds": [104]
}
youtubeChannel
{
"channelName": "Claude",
"subscribers": 621000,
"videos": 220,
"totalViews": 315421031
}

The channel call also returns a page of the latest videos. The newest was What's new in Claude, September recap, at 148,000 views. Add a tab such as shorts or playlists, or sort by popular, to read other parts of the channel.

Honest take. I run this before I trust a creator's reach. It costs two credits.

What it costs

Every YouTube endpoint costs 1 credit per call. A call that returns an error or an empty list costs 0. A new account starts with 1,000 credits, so the six calls I made for this post cost 6 credits. After that, 1,000 credits cost between $0.80 and $1.50 depending on the size of the top-up.

To see the price before you call, ask Codex to describe the endpoint. stophy_describe_endpoint returns the cost with the inputs. The CLI does the same with stophy describe youtube.transcript.

What does not work

  • Private, removed or age restricted videos. The call returns an error that tells you to check the id, and it costs nothing. I tried a made up id to check.
  • Videos with no captions. A transcript reads captions, so it returns an error when there are none.
  • What is on screen. The transcript is what the video says, not what it shows. The video endpoint returns the title, description, stats and chapters, but nothing about the picture.
  • Writing to YouTube. The tools read. They cannot post a comment, like a video or upload one.
  • The video file. You get text and numbers, not an mp4 or the audio.
  • Exact dates from a search. Treat them as approximate and use the video endpoint.

Which way to pick

Use MCP when you work in Codex and want the agent to choose the call. Use the CLI in a script or a cron job. Use the TypeScript SDK or the Python SDK inside your own product. Use a free tool page when you need one transcript or one set of comments and nothing else.

All of them use the same credits and the same account.

Frequently asked questions

Does Codex support MCP servers?

Yes. Codex has a codex mcp command with add, list, get, remove, login and logout. It can connect to a server by address or start a local one with a command.

How do I add an MCP server to Codex?

Run codex mcp add with a name and the server address, such as codex mcp add stophy --url https://mcp.stophy.dev/mcp. If the server uses OAuth, run codex mcp login with the same name. Run codex mcp list to confirm it is there.

Do I need a YouTube API key?

No. Your agent calls Stophy, so you need no YouTube Data API key and no Google login.

Is the YouTube MCP server free?

A new account starts with 1,000 credits and every YouTube call costs 1 credit. A call that returns an error or an empty list costs nothing.

Can Codex watch a YouTube video?

It can read one. It gets the captions as text, plus the title, description, views and chapters. It cannot see the picture.

Can Codex get a YouTube transcript?

Yes. Paste the video link and ask. The transcript endpoint returns the text, the language and whether a machine wrote the captions. Ask for timestamps to jump to a moment. The YouTube transcript API page shows the fields.

Can Codex read YouTube comments?

Yes, 20 comments per call. Choose top or newest. A reply thread is a second call with the comment's repliesCursor.

What can I do with a YouTube MCP server?

Research a topic from the top videos, summarize a talk, check a creator before you sponsor them, or turn a webinar into notes with timestamps.

Does the same server work in Claude Code or Cursor?

Yes. The address is the same. Only the setup command changes. The MCP page has the steps for each agent.

How do I remove the server from Codex?

Run codex mcp remove stophy. That deletes the entry. Your Stophy account and credits stay as they are.