YouTube MCP Server
YouTube MCP Server
基于 MCP 的服务器,将 YouTube 带到 Claude Code — 视频转录、搜索、元数据、频道信息、播放列表、评论、热门视频、互动分析、章节提取、SponsorBlock 集成以及最多重播热图。使用 YouTube Data API v3、youtube-transcript 和 SponsorBlock。
快速开始
第 1 步:获取你的 API 密钥
创建一个项目(或选择现有项目)
启用 YouTube Data API v3:
前往 API Library
点击 Enable
创建 API 密钥:
前往 Credentials
点击 Create Credentials > API key
复制该密钥(在第 3 步中你会用到它)
第 2 步:安装先决条件
第 3 步:安装 MCP 服务器
3.1 克隆仓库
git clone https://github.com/wynandw87/claude-code-youtube-mcp.git
cd claude-code-youtube-mcp3.2 安装依赖
macOS / Linux / Windows:
npm install注意: 依赖安装和服务器构建会在一步内自动完成。
3.3 注册到 Claude Code
选择你的安装范围:
范围 | 标志 | 谁可以使用 |
用户(推荐) |
| 你,在任何项目中 |
项目 |
| 任何克隆此仓库的人 |
本地 |
| 仅限当前目录 |
将 YOUR_API_KEY 替换为你的实际 YouTube Data API 密钥,并使用 dist/index.js 的完整路径。
提示: 要获取完整路径,请在克隆的目录中运行:
macOS/Linux:
echo "$(pwd)/dist/index.js"Windows:
echo %cd%\dist\index.js
macOS / Linux:
claude mcp add -s user youtube -e YOUTUBE_API_KEY=YOUR_API_KEY -- node /full/path/to/dist/index.jsWindows(CMD):
claude mcp add -s user youtube -e "YOUTUBE_API_KEY=YOUR_API_KEY" -- node "C:\full\path\to\dist\index.js"Windows(PowerShell):
claude mcp add -s user youtube -e "YOUTUBE_API_KEY=YOUR_API_KEY" '--' node "C:\full\path\to\dist\index.js"备选方案:使用 npm 辅助工具(如果已在环境中设置 API 密钥)
export YOUTUBE_API_KEY=YOUR_API_KEY
npm run install:claude第 4 步:重启 Claude Code
关闭并重新打开 Claude Code,使更改生效。
第 5 步:验证安装
claude mcp list你应该会看到 youtube 以 Connected 状态列出。
Related MCP server: youtube-research
功能
转录与字幕
获取转录(
get_transcript)- 获取带时间戳的完整视频转录,支持多种语言搜索转录(
search_transcript)- 在视频中查找关键词或短语出现的位置及时间戳干净转录(
get_clean_transcript)- 通过 SponsorBlock 移除赞助、片头、片尾和填充内容的转录提取章节(
extract_chapters)- 从视频描述中解析章节时间戳
搜索与发现
搜索视频(
search_videos)- 完整的 YouTube 搜索,支持日期、时长、类型和排序筛选在频道内搜索(
search_within_channel)- 搜索特定创作者的视频获取热门视频(
get_trending_videos)- 按地区和类别查看当前热门视频获取频道视频(
get_channel_videos)- 频道的最近上传内容,按日期或观看次数排序
视频与频道信息
视频元数据(
get_video_metadata)- 标题、描述、时长、观看次数、点赞数、标签等频道信息(
get_channel_info)- 订阅者数量、视频数量、描述、国家/地区播放列表项(
get_playlist_items)- 播放列表中的所有视频,包含位置和元数据
分析与互动
计算互动率(
calculate_engagement)- 根据公开统计数据计算点赞率、评论率和互动率最多重播(
get_most_replayed)- 显示观众最常重看的段落的热图数据视频评论(
get_video_comments)- 带点赞数和回复数的热门评论
实用工具
解析 YouTube URL(
parse_youtube_url)- 从任何 YouTube URL 格式中提取视频/频道/播放列表 ID
使用
安装后,使用触发短语来调用 YouTube 工具:
触发 | 工具 | 示例 |
| 获取转录 | "get the youtube transcript for this video" |
| 搜索视频 | "youtube search for React tutorials" |
| 视频元数据 | "get youtube metadata for this video" |
| 频道信息 | "get youtube channel info for @ThePrimeagen" |
| 播放列表项 | "list the videos in this youtube playlist" |
| 视频评论 | "get youtube comments for this video" |
| 热门视频 | "what's trending on youtube in the US?" |
| 提取章节 | "extract chapters from this youtube video" |
| 计算互动率 | "calculate youtube engagement for this video" |
| 最多重播 | "show the most replayed parts of this youtube video" |
| 干净转录 | "get a clean youtube transcript without sponsors" |
| 搜索转录 | "search the youtube transcript for 'authentication'" |
或者自然地问:
"获取这个 YouTube 视频的转录并总结一下"
"这个视频最常被重看的段落是哪些?"
"在这个频道上查找关于 TypeScript 的近期视频"
"这个视频有多少观看次数和点赞数?"
"获取这个视频的评论并总结情感倾向"
"给我看看这个教程的章节"
"获取没有赞助商朗读内容的干净转录"
"现在 YouTube 上游戏类有哪些热门内容?"
工具参考
parse_youtube_url
解析任何 YouTube URL 格式并提取标识符。无需 API 密钥。
参数:
url(字符串,必填)- 任何 YouTube URL 或视频 ID
支持的格式: youtube.com/watch?v=、youtu.be/、/shorts/、/embed/、/playlist?list=、/channel/、/@handle、/c/、/user/、裸视频 ID
get_transcript
获取 YouTube 视频的完整转录/字幕。无需 API 密钥。
参数:
url(字符串,必填)- YouTube 视频 URL 或视频 IDlang(字符串,可选)- 字幕语言代码(默认:"en")
search_transcript
在视频的转录中搜索关键词或短语。
参数:
url(字符串,必填)- YouTube 视频 URL 或视频 IDquery(字符串,必填)- 要搜索的关键词或短语lang(字符串,可选)- 字幕语言代码(默认:"en")
extract_chapters
从视频描述中提取章节时间戳。
参数:
url(字符串,必填)- YouTube 视频 URL 或视频 ID
get_clean_transcript
获取通过 SponsorBlock 移除赞助商朗读、片头、片尾和填充内容的转录。
参数:
url(字符串,必填)- YouTube 视频 URL 或视频 IDlang(字符串,可选)- 字幕语言代码(默认:"en")
get_most_replayed
获取“最多重播”热图数据,显示观众最常重看的段落。
参数:
url(字符串,必填)- YouTube 视频 URL 或视频 ID
注意: 通常需要大约 5 万次以上的观看次数才能获得热图数据。
search_videos
使用完整筛选支持搜索 YouTube。
参数:
query(字符串,必填)- 搜索查询max_results(数字,可选)- 结果数量,1-50(默认:10)order(字符串,可选)-"relevance"、"date"、"viewCount"、"rating"(默认:"relevance")duration(字符串,可选)-"short"(少于 4 分钟)、"medium"(4-20 分钟)、"long"(超过 20 分钟)upload_date(字符串,可选)-"hour"、"day"、"week"、"month"、"year"type(字符串,可选)-"video"、"channel"、"playlist"(默认:"video")
get_video_metadata
获取 YouTube 视频的详细元数据。
参数:
url(字符串,必填)- YouTube 视频 URL 或视频 ID
返回: 标题、描述、频道、时长、观看/点赞/评论次数、标签、类别、缩略图、直播状态等。
get_channel_info
获取 YouTube 频道信息。
参数:
url(字符串,必填)- YouTube 频道 URL、@handle 或频道 ID
返回: 标题、描述、订阅者/视频/观看次数、国家/地区、自定义 URL 和缩略图。
get_playlist_items
获取 YouTube 播放列表中的所有视频。
参数:
url(字符串,必填)- YouTube 播放列表 URL 或播放列表 IDmax_results(数字,可选)- 项目数量,1-50(默认:25)
get_channel_videos
获取 YouTube 频道的近期视频。
参数:
url(字符串,必填)- YouTube 频道 URL、@handle 或频道 IDmax_results(数字,可选)- 视频数量,1-50(默认:25)order(字符串,可选)-"date"、"viewCount"(默认:"date")
get_trending_videos
获取当前热门/流行的 YouTube 视频。
参数:
region_code(字符串,可选)- ISO 3166-1 alpha-2 国家/地区代码(默认:"US")category_id(字符串,可选)- YouTube 类别 ID(例如,音乐为"10",游戏为"20",科学与技术为"28")max_results(数字,可选)- 结果数量,1-50(默认:10)
search_within_channel
在特定 YouTube 频道内搜索视频。
参数:
url(字符串,必填)- YouTube 频道 URL、@handle 或频道 IDquery(字符串,必填)- 搜索查询max_results(数字,可选)- 结果数量,1-50(默认:10)
get_video_comments
获取 YouTube 视频的顶级评论。
参数:
url(字符串,必填)- YouTube 视频 URL 或视频 IDmax_results(数字,可选)- 评论数量,1-100(默认:20)order(字符串,可选)-"relevance"、"time"(默认:"relevance")
calculate_engagement
计算 YouTube 视频的互动指标。
参数:
url(字符串,必填)- YouTube 视频 URL 或视频 ID
返回: 观看次数、点赞数、评论数、点赞率、评论率和整体互动率。
工作原理
此 MCP 服务器通过 stdio 传输连接到 Claude Code,并提供 15 个工具:
工具 | 数据来源 | 需要 API 密钥吗? |
| 本地解析 | 否 |
| youtube-transcript 库 | 否 |
| youtube-transcript 库 | 否 |
| youtube-transcript + SponsorBlock API | 否 |
| YouTube 页面(Innertube) | 否 |
| YouTube Data API v3 | 是 |
| YouTube Data API v3 | 是 |
| YouTube Data API v3 | 是 |
| YouTube Data API v3 | 是 |
| YouTube Data API v3 | 是 |
| YouTube Data API v3 | 是 |
| YouTube Data API v3 | 是 |
| YouTube Data API v3 | 是 |
| YouTube Data API v3 | 是 |
| YouTube Data API v3 | 是 |
注意: 5 个工具无需 API 密钥即可使用(字幕、SponsorBlock、热力图、URL 解析)。其余 10 个需要 YouTube Data API v3 密钥。
配置
环境变量
变量 | 是否必填 | 默认值 | 说明 |
| 是 | — | YouTube Data API v3 密钥 |
| 否 |
| API 超时时间(毫秒) |
YouTube API 配额
YouTube Data API v3 的每日配额为 10,000 个单位。每个工具消耗的配额不同:
操作 | 每次调用成本 |
| 100 个单位 |
| 1 个单位 |
| 1 个单位 |
| 1 个单位 |
| 1 个单位 |
| 1 个单位 |
提示: 搜索操作的成本最高。如果只需要最近上传的视频,请使用
get_channel_videos(1 个单位),而不是search_within_channel(100 个单位)。
故障排除
修复 API 密钥
如果您输入了错误的 API 密钥,请移除并重新安装:
claude mcp remove youtube然后使用上面第 3.3 步中的命令重新安装(使用与您最初安装时相同的 scope)。
MCP 服务器未显示
检查服务器是否已安装:
claude mcp list如果未列出,请按照第 3 步进行安装。
服务器无法启动
在 Google Cloud Console 中验证您的 API 密钥是否有效
检查 YouTube Data API 是否已启用:
前往 API Library
页面应显示“已启用”
检查 Node.js 版本(需要 18 或更高版本):
node --version确保服务器已构建 — 如果缺少
dist/index.js,请重新运行npm install
连接错误
检查
dist/index.js是否存在 — 如果不存在,请运行npm install确认
claude mcp add命令中的路径是绝对路径修改任何配置后重启 Claude Code
配额超出
如果您看到 “quotaExceeded” 错误:
等到太平洋时间午夜(配额每天重置)
使用其他 API 密钥
优先使用低成本工具(
get_video_metadata,1 个单位),而不是搜索工具(100 个单位)
字幕不可用
某些视频禁用了字幕功能。get_transcript 工具会返回清晰的错误消息。请尝试:
使用不同的语言代码(例如
lang: \"es\")即使没有手动字幕,也可能提供自动生成的字幕
超时错误
如果网络连接较慢,请增大 YOUTUBE_TIMEOUT 环境变量:
claude mcp add -s user youtube -e YOUTUBE_API_KEY=YOUR_KEY -e YOUTUBE_TIMEOUT=60000 -- node /path/to/dist/index.js查看当前配置
claude mcp list贡献
欢迎提交 Pull Request!请保持简单,并对初学者友好。
许可证
MIT
为 Claude Code 社区而制作
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseAqualityDmaintenanceIntegrates YouTube with Claude Code, enabling video transcript retrieval, search, metadata extraction, channel info, playlists, comments, trending videos, engagement analytics, chapter extraction, SponsorBlock integration, and most-replayed heatmaps.15386
- AlicenseAqualityDmaintenanceEnables YouTube integration with Claude Code, including video search, metadata retrieval, transcript fetching, channel exploration, and trending videos.81MIT
- FlicenseNot gradedqualityCmaintenanceEnables natural-language access to YouTube features such as transcripts, search, metadata, channels, playlists, comments, trending videos, engagement analytics, chapters, SponsorBlock filtering, and heatmaps.38
- FlicenseNot gradedqualityCmaintenanceEnables Claude.ai to search videos, get trending and channel feeds, retrieve video metadata and engagement stats, and fetch or search transcripts over HTTPS.
Related MCP Connectors
YouTube transcripts, search, channels, playlists and bulk transcript jobs for AI agents. 14 tools.
Provide token-optimized, structured YouTube data to enhance your LLM applications. Access efficien…
YouTube transcripts, subtitles, and video metadata as structured JSON via an Apify Actor.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/MudasirAli01/youtube-mcp-connector'
If you have feedback or need assistance with the MCP directory API, please join our Discord server