youtube-mcp
youtube-mcp
这是一个MCP服务器,让你可以直接从Claude分析@ザビエル-zav的YouTube频道。
目标是实现像“上周的视频哪个CTR最好?”这样的问题,能够获取真实数据来回答。
基于Node.js开发(不使用Python)。将YouTube Analytics API / Reporting API / Data API v3
封装在官方的Node库(googleapis、google-auth-library)中,
并通过MCP官方的TypeScript SDK(@modelcontextprotocol/sdk)作为工具公开。
使用的API及分工
想要的数据 | API | 获取方式 |
播放量、观看时长、平均观看保持率、订阅增减、流量来源、观众群体 | YouTube Analytics API | 请求后立即返回JSON |
缩略图展示次数、展示次数CTR | YouTube Reporting API (Bulk Reports) | 预先注册任务 → 每天生成CSV → 下载后 |
视频标题、描述、评论 | YouTube Data API v3 | 请求后立即返回JSON |
只有CTR的获取方式根本不同(批量报告),因此通过 register-reach-job.js
注册任务 → 用 download-reports.js 定期将CSV累积到本地,走的是另一条路径。
Related MCP server: YouTube MCP Server
设置
1. Google Cloud Console
创建项目
启用以下3个API
YouTube Analytics API
YouTube Reporting API
YouTube Data API v3
配置OAuth同意屏幕(用户类型=外部,将自己的Google账号添加到测试用户)
在 凭据 > OAuth客户端ID > 应用类型=桌面应用 中创建,并下载JSON
将下载的JSON以
client_secret.json的名称放在此仓库根目录下绝对不要提交
client_secret.json以及首次认证后生成的token.json。 虽然已在.gitignore中,但注意不要误用git add -f。
2. Node.js和依赖包
需要Node.js 18以上(如果未安装,从 nodejs.org 安装LTS版。
安装程序中已包含 npm,因此基本不需要像Python那样单独设置PATH)。
npm install3. 注册触达报告(CTR)任务 — 最优先执行
Reporting API 从“注册任务之日”开始生成数据,过去的数据最多也只能追溯到 注册时点的30天前。注册越晚,过去的CTR数据丢失越多, 所以请在其他工作之前先执行这一步。
npm run register-reach-job首次会打开浏览器要求认证(之后通过 token.json 自动更新)。
4. 启动MCP服务器
npm start如果要从Claude Desktop使用,请在 claude_desktop_config.json 中按如下方式注册。
{
"mcpServers": {
"youtube-analytics": {
"command": "node",
"args": ["/absolute/path/to/youtube-mcp/server.js"]
}
}
}5. 下载触达报告(注册后数小时〜2天)
npm run download-reportsCSV会累积到 data/reach/<report_type>/ 目录下。报告会在YouTube侧保留60天
(过去数据部分为30天)后消失,因此请定期(最好每天1次)持续执行。
Windows可使用任务计划程序,Mac/Linux可注册到cron。
get_reach 工具会读取这些本地CSV。
公开工具列表
工具名 | 参数 | 返回内容 |
|
| 整个期间的播放量・观看时长・订阅增减 |
|
| 播放量排名靠前的视频及其基本数据 |
|
| 指定视频的详细数据 |
|
| 观看保持率曲线(按10%分段)+最大流失点 |
|
| 流量来源的构成 |
|
| 缩略图展示次数和CTR(从本地累积CSV汇总) |
|
| 评论列表(按相关度排序) |
输出不是原始JSON,而是返回四舍五入后的数值、上限约20条左右的文本表格 (为了减少Claude侧的上下文消耗)。
已知限制
Analytics API的数据比YouTube Studio显示最多延迟约2天。有时无法获取“昨天的数据”。
get_reach只查看已下载到本地的CSV。未执行download-reports.js期间的数据不会出现。channel_reach_basic_a1/channel_reach_combined_a1的准确列结构尚未确认。get_reach采用了通过关键词推测列名来读取的备用方案,但请用实际下载的CSV表头确认一次。未添加写入类权限(只读)。不存在误修改或删除视频的途径。
部署目标的分支
想要使用的地方 | 所需内容 |
Claude Desktop 应用 | 本地运行 |
claude.ai (Web/手机) | 需要作为可通过HTTPS访问的远程MCP服务器公开 |
如果也想在手机上使用,最快的方式是将 StdioServerTransport 切换为 StreamableHTTPServerTransport
(@modelcontextprotocol/sdk/server/streamableHttp.js),
并搭载到现有的托管环境中。
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
- AlicenseNot gradedqualityDmaintenanceEnables Claude to access and manage YouTube channel data through the YouTube Data API v3 and YouTube Analytics API. Provides tools for reading analytics, fetching video metadata, searching uploads, and updating video SEO directly from Claude.91MIT
- FlicenseNot gradedqualityDmaintenanceProvides AI assistants with comprehensive YouTube analytics and channel management capabilities, including channel performance, video analytics, audience insights, and content strategy tools.391
- AlicenseAqualityDmaintenanceEnables YouTube integration with Claude Code, including video search, metadata retrieval, transcript fetching, channel exploration, and trending videos.81MIT
- AlicenseAqualityCmaintenanceEnables AI assistants to access YouTube organic analytics, including channel stats, video performance, watch time, and audience engagement, via the YouTube Data API v3 and Analytics API v2.621MIT
Related MCP Connectors
YouTube transcripts, search, channels, playlists and bulk transcript jobs for AI agents. 14 tools.
Agent-callable creator intelligence: 952+ scored YouTube creators across 180 niches.
Provide token-optimized, structured YouTube data to enhance your LLM applications. Access efficien…
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/Zavier0305/youtube-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server