
# `yutu`
[](https://gitmoji.dev)
[](https://goreportcard.com/report/github.com/eat-pray-ai/yutu)
[](https://github.com/eat-pray-ai/yutu?tab=Apache-2.0-1-ov-file)
[](https://pkg.go.dev/github.com/eat-pray-ai/yutu)
[](https://raw.githack.com/wiki/eat-pray-ai/yutu/coverage.html)
[](https://github.com/eat-pray-ai/yutu/stargazers)
[](https://github.com/eat-pray-ai/yutu/releases/latest)
[](https://github.com/eat-pray-ai/yutu/actions/workflows/publish.yml)
[](https://github.com/eat-pray-ai/yutu/actions/workflows/codeql.yml)
[](https://github.com/eat-pray-ai/yutu/actions/workflows/test.yml)
[](https://linux.do/tag/2234-tag/2234)
[](https://github.com/eat-pray-ai/yutu/releases/latest)
[](https://formulae.brew.sh/formula/yutu)
[](https://winstall.app/apps/eat-pray-ai.yutu)
[](https://www.npmjs.com/package/@eat-pray-ai/yutu)
[](https://www.producthunt.com/products/yutu?embed=true&utm_source=badge-featured&utm_medium=badge&utm_campaign=badge-youtube-cli-mcp-server-skill-and-agent)
`yutu` 是一个 YouTube CLI、MCP 服务器和 AI Agent,可以自动化您的整个 YouTube 工作流程——从上传和优化视频到管理评论、播放列表和频道品牌——帮助您获得更多播放量、更高的点击率和更强的观众互动,同时大幅减少手动操作。
[](https://asciinema.org/a/wXIHU4ciFBAKrHfaFNkMoIs12)
## 目录
- [前提条件](#前提条件)
- [安装](#安装)
- [Agent](#agent)
- [MCP 服务器](#mcp-服务器)
- [Skills](#skills)
- [使用方法](#使用方法)
- [功能特性](#功能特性)
- [贡献](#贡献)
## 前提条件
开始之前,您需要在 [Google Cloud Platform](https://console.cloud.google.com/) 上创建一个账户来新建**项目**,并为该项目启用以下 API,位置在 `APIs & Services -> Enable APIs and services -> + ENABLE APIS AND SERVICES`:
- [YouTube Data API v3(必需)](https://console.cloud.google.com/apis/api/youtubeanalytics.googleapis.com/overview)
- [YouTube Analytics API(可选)](https://console.cloud.google.com/apis/api/youtubeanalytics.googleapis.com/overview)
- [YouTube Reporting API(可选)](https://console.cloud.google.com/apis/api/youtubereporting.googleapis.com/overview)
启用 API 后,创建一个 `OAuth content screen`,将您自己设置为测试用户,然后创建一个类型为 `Desktop app` 的 `OAuth Client ID`。
将此凭据下载到本地机器,命名为 `client_secret.json`,它应该看起来像这样:
```json
{
"installed": {
"client_id": "11181119.apps.googleusercontent.com",
"project_id": "yutu-11181119",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "XXXXXXXXXXXXXXXX",
"redirect_uris": [
"http://localhost"
]
}
}
```
要验证此凭据,请运行以下命令:
```shell
❯ yutu auth --credential client_secret.json
```
浏览器窗口将打开,要求您授权访问您的 YouTube 账户。授权后,将生成一个令牌并保存到 `youtube.token.json`。
```json
{
"access_token": "ya29.XXXXXXXXX",
"token_type":"Bearer",
"refresh_token":"1//XXXXXXXXXX",
"expiry": "2024-05-26T18:49:56.1911165+08:00",
"expires_in": 3599
}
```
默认情况下,`yutu` 将从当前目录读取 `client_secret.json` 和 `youtube.token.json`,`--credential/-c` 和 `--cacheToken/-t` 标志仅在 `auth` 子命令中可用。要在所有子命令中修改默认路径,请设置这些环境变量:
```shell
❯ export YUTU_CREDENTIAL=client_secret.json
❯ export YUTU_CACHE_TOKEN=youtube.token.json
# 或
❯ YUTU_CREDENTIAL=client_secret.json YUTU_CACHE_TOKEN=youtube.token.json yutu subcommand --flag value
```
### 全局环境变量
| 变量 | 描述 | 默认值 |
|--------------------|------------------------------------|----------------------|
| `YUTU_CREDENTIAL` | OAuth 客户端密钥的路径、Base64 或 JSON | `client_secret.json` |
| `YUTU_CACHE_TOKEN` | 缓存的 OAuth 令牌的路径、Base64 或 JSON | `youtube.token.json` |
| `YUTU_ROOT` | 文件解析的根目录 | 当前工作目录 |
| `YUTU_LOG_LEVEL` | 日志级别:`DEBUG`、`INFO`、`WARN`、`ERROR` | `INFO` |
## 安装
您可以直接从[发布页面](https://github.com/eat-pray-ai/yutu/releases/latest)下载 `yutu`,或使用以下您喜欢的方法。
GitHub Actions
yutu 有两个可用的 GitHub Action,一个是通用 action,另一个专用于上传视频到 YouTube。更多信息请参考 [youtube-action](https://github.com/eat-pray-ai/youtube-action) 和 [youtube-uploader](https://github.com/eat-pray-ai/youtube-uploader)。
Node.js
```shell
❯ npm i -g @eat-pray-ai/yutu
```
Docker
```shell
❯ docker pull ghcr.io/eat-pray-ai/yutu:latest
❯ docker run --rm ghcr.io/eat-pray-ai/yutu:latest
# 确保 client_secret.json 在当前目录中
❯ docker run --rm -it -u $(id -u):$(id -g) -v $(pwd):/app -p 8216:8216 ghcr.io/eat-pray-ai/yutu:latest
```
Gopher
```shell
❯ go install github.com/eat-pray-ai/yutu@latest
```
Linux
```shell
❯ curl -sSfL https://raw.githubusercontent.com/eat-pray-ai/yutu/main/scripts/install.sh | bash
```
macOS
使用 [Homebrew🍺](https://brew.sh/) 安装 `yutu`(推荐),或运行 shell 脚本。
```shell
❯ brew install yutu
# 或
❯ curl -sSfL https://raw.githubusercontent.com/eat-pray-ai/yutu/main/scripts/install.sh | bash
```
Windows
```shell
❯ winget install yutu
```
验证安装
使用其关联的加密签名证明来验证 `yutu` 的完整性和来源。
```shell
# Docker
❯ gh attestation verify oci://ghcr.io/eat-pray-ai/yutu:latest --repo eat-pray-ai/yutu
# Linux 和 macOS(如果使用 shell 脚本安装)
❯ gh attestation verify $(which yutu) --repo eat-pray-ai/yutu
# Windows
❯ gh attestation verify $(where.exe yutu.exe) --repo eat-pray-ai/yutu
```
## Agent
`yutu` 提供了一种 Agent 模式来自动化 YouTube 工作流程。该系统采用多 Agent 架构,由中央编排器将任务委派给专门的 Agent:
| Agent | 角色 | 能力 |
|------------------|------------------------------|----------------------------------------|
| **Orchestrator** | 协调整个工作流程,规划策略,并将任务委派给子 Agent | YouTube 增长策略、SEO 优化、任务路由 |
| **Retrieval** | 从 YouTube 和网络收集数据(只读) | 列出/搜索视频、频道、播放列表、评论、字幕、订阅、成员等;Google 搜索 |
| **Modifier** | 创建和更新 YouTube 内容 | 上传视频、创建播放列表、更新元数据、发布评论、设置缩略图、管理字幕和水印 |
| **Destroyer** | 处理需要格外谨慎的破坏性操作 | 删除视频、播放列表、评论、字幕、订阅、频道版块和水印 |
目前,Agent 模式仍在积极开发中,仅支持 Google 的 Gemini 模型,需设置以下环境变量:
```shell
❯ export YUTU_ADVANCED_MODEL=google:gemini-3.1-pro-preview
❯ export YUTU_LITE_MODEL=google:gemini-3-flash-preview
❯ export YUTU_LLM_API_KEY=your_gemini_api_key
// 可选设置
❯ export GOOGLE_GEMINI_BASE_URL=https://generativelanguage.googleapis.com/
❯ export YUTU_AGENT_INSTRUCTION=Your custom instruction here
```
`YUTU_ADVANCED_MODEL` 用于编排 Agent,`YUTU_LITE_MODEL` 用于其他所有 Agent。两者均使用 `provider:modelName` 格式(目前仅支持 `google`)。如果只设置了其中一个,另一个将使用相同的值。
### Agent 环境变量
| 变量 | 描述 | 必填 |
|------------------------------|-----------------------------------------|--------------------------------------------------|
| `YUTU_ADVANCED_MODEL` | 编排 Agent 使用的模型(格式:`provider:modelName`) | `YUTU_ADVANCED_MODEL` 和 `YUTU_LITE_MODEL` 至少设置一个 |
| `YUTU_LITE_MODEL` | 子 Agent 使用的模型(格式:`provider:modelName`) | `YUTU_ADVANCED_MODEL` 和 `YUTU_LITE_MODEL` 至少设置一个 |
| `YUTU_LLM_API_KEY` | 模型提供商的 API 密钥 | 是 |
| `GOOGLE_GEMINI_BASE_URL` | Gemini API 的 BASE_URL | 否 |
| `YUTU_AGENT_INSTRUCTION` | 编排 Agent 的自定义指令 | 否 |
| `YUTU_RETRIEVAL_INSTRUCTION` | 检索 Agent 的自定义指令 | 否 |
| `YUTU_MODIFIER_INSTRUCTION` | 修改 Agent 的自定义指令 | 否 |
| `YUTU_DESTROYER_INSTRUCTION` | 删除 Agent 的自定义指令 | 否 |
然后运行以下命令查看详细用法:
```
❯ yutu agent --help
❯ yutu agent --args "help"
# console mode
❯ yutu agent --args "console"
# web mode with three sub-launchers: api, a2a and webui
❯ yutu agent --args "web api a2a webui"
```
## MCP 服务器
在将 `yutu` 用作 MCP 服务器之前,请确保已安装 `yutu`(参见[安装](#安装)部分),并且您有有效的 `client_secret.json` 和 `youtube.token.json` 文件(参考[前提条件](#前提条件)部分)。
您可以通过点击下方徽章将 `yutu` 添加为 VS Code 或 Cursor 中的 MCP 服务器,或使用下面的 CLI 命令。
[](https://insiders.vscode.dev/redirect/mcp/install?name=yutu&config=%7B%22type%22%3A%20%22stdio%22%2C%22command%22%3A%20%22yutu%22%2C%22args%22%3A%20%5B%22mcp%22%5D%2C%22env%22%3A%20%7B%22YUTU_CREDENTIAL%22%3A%20%22%2Fabsolute%2Fpath%2Fto%2Fclient_secret.json%22%2C%22YUTU_CACHE_TOKEN%22%3A%20%22%2Fabsolute%2Fpath%2Fto%2Fyoutube.token.json%22%7D%7D)
[](https://cursor.com/install-mcp?name=yutu&config=JTdCJTIyY29tbWFuZCUyMiUzQSUyMnl1dHUlMjBtY3AlMjIlMkMlMjJlbnYlMjIlM0ElN0IlMjJZVVRVX0NSRURFTlRJQUwlMjIlM0ElMjIlMkZhYnNvbHV0ZSUyRnBhdGglMkZ0byUyRmNsaWVudF9zZWNyZXQuanNvbiUyMiUyQyUyMllVVFVfQ0FDSEVfVE9LRU4lMjIlM0ElMjIlMkZhYnNvbHV0ZSUyRnBhdGglMkZ0byUyRnlvdXR1YmUudG9rZW4uanNvbiUyMiU3RCU3RA%3D%3D)
Claude Code
```shell
# Stdio 模式
❯ claude mcp add -e YUTU_CREDENTIAL=/absolute/path/to/client_secret.json \
-e YUTU_CACHE_TOKEN=/absolute/path/to/youtube.token.json \
yutu -- yutu mcp
# HTTP 模式(先启动服务器:yutu mcp --mode http --auth)
❯ claude mcp add --transport http \
--client-id YOUR_CLIENT_ID.apps.googleusercontent.com \
--client-secret \
yutu http://localhost:8216/mcp
```
Codex
```shell
# Stdio 模式
❯ codex mcp add --env YUTU_CREDENTIAL=/absolute/path/to/client_secret.json \
--env YUTU_CACHE_TOKEN=/absolute/path/to/youtube.token.json \
yutu -- yutu mcp
# HTTP 模式(先启动服务器:yutu mcp --mode http --auth)
❯ codex mcp add --url http://localhost:8216/mcp \
--oauth-client-id YOUR_CLIENT_ID.apps.googleusercontent.com \
yutu
```
手动配置(VS Code、Cursor、OpenCode 等)
将以下配置添加到您的 MCP 设置中。记得将 `YUTU_CREDENTIAL` 和 `YUTU_CACHE_TOKEN` 的值替换为您本地机器上的正确路径。
```json
{
"yutu": {
"type": "stdio",
"command": "yutu",
"args": [
"mcp"
],
"env": {
"YUTU_CREDENTIAL": "/absolute/path/to/client_secret.json",
"YUTU_CACHE_TOKEN": "/absolute/path/to/youtube.token.json"
}
}
}
```
## Skills
`yutu` 提供了一个统一的 [skill](https://opencode.ai/docs/skills),为 AI Agent 扩展 YouTube 领域知识、常用工作流和 SEO 最佳实践——涵盖视频、播放列表、评论、频道、字幕、订阅等。
```shell
❯ npx skills add https://github.com/eat-pray-ai/yutu/tree/main/skills/youtube
```
完整的支持操作列表请参见 [skills/youtube/SKILL.md](skills/youtube/SKILL.md)。
## 使用方法
```shell
❯ yutu
yutu is a CLI, MCP server, and AI agent for YouTube that can automate almost all YouTube workflows.
Environment variables:
YUTU_CREDENTIAL Path/Base64/JSON of OAuth client secret (default: client_secret.json)
YUTU_CACHE_TOKEN Path/Base64/JSON of cached OAuth token (default: youtube.token.json)
YUTU_ROOT Root directory for file resolution (default: current working directory)
YUTU_LOG_LEVEL Log level: DEBUG, INFO, WARN, ERROR (default: INFO)
Usage:
yutu [flags]
yutu [command]
Available Commands:
activity Manage activities on YouTube
agent Start an agent to automate YouTube workflows
auth Authenticate with YouTube APIs
caption Manage YouTube video captions
channel Manage YouTube channels
channelBanner Manage YouTube channel banners
channelSection Manage YouTube channel sections
comment Manage YouTube comments
commentThread Manage YouTube comment threads
completion Generate the autocompletion script for the specified shell
help Help about any command
i18nLanguage Manage YouTube i18n languages
i18nRegion Manage YouTube i18n regions
mcp Start MCP server
member Manage YouTube channel members
membershipsLevel Manage YouTube memberships levels
playlist Manage YouTube playlists
playlistImage Manage YouTube playlist images
playlistItem Manage YouTube playlist items
search Manage YouTube search
subscription Manage YouTube subscriptions
superChatEvent Manage YouTube Super Chat events
thirdPartyLink Manage YouTube third-party links
thumbnail Manage YouTube video thumbnails
version Show the version of yutu
video Manage YouTube videos
videoAbuseReportReason Manage YouTube video abuse report reasons
videoCategory Manage YouTube video categories
watermark Manage YouTube watermarks
Flags:
-h, --help help for yutu
Use "yutu [command] --help" for more information about a command.
```
## 功能特性
请参考 [FEATURES.md](docs/FEATURES.md) 获取更多信息。
## 贡献
请参考 [CONTRIBUTING.md](docs/CONTRIBUTING.md) 获取更多信息。
## Star 历史
[](https://star-history.com/#eat-pray-ai/yutu&Date)