
tubekit
io.github.santiriera626由 GitHub 账号 santiriera626 发布v0.3.0更新于 Oct 24, 2026
Compliance-aware MCP server for YouTube publishing, analytics and creator insights.
概览
带合规校验的 MCP 服务器,让助手代你在自己的 YouTube 频道上传、管理视频并查看分析数据,并记录配额与审计日志。
- 可以做什么
- 用本地合规规则库校验视频元数据,在发布前拦截问题
- 上传视频、设置缩略图,修改标题、描述、标签或隐私状态
- 读取视频状态、列出上传视频与播放列表,并创建、更新、排序或移除播放列表条目
- 获取频道、多频道组合与单视频的分析报告,含收入估算与 YPP 进度
- 汇总、列出并读取评论串,并在本地记录评论已读状态
- 检查 OAuth 授权是否有效,并为大文件申请一次性上传地址
- 适用场景
- 适合让助手实际运营一个 YouTube 频道:发布视频、整理播放列表、处理评论或汇报数据,同时希望有合规拦截、配额核算和审计记录,而不是直接暴露原始 API。
- 运行要求
- 以 stdio 在本地运行(PyPI 包,用 uvx 或 uv tool install 启动)。需要启用 YouTube Data API v3(报告还需 Analytics API)的 Google Cloud 项目、Desktop 类型 OAuth 客户端 JSON(TUBEKIT_OAUTH_CLIENT_SECRETS_PATH)、Fernet 主密钥(TUBEKIT_MASTER_KEY_PATH)、SQLite 状态文件(TUBEKIT_STATE_DB_PATH),以及每个频道一次交互式 OAuth 授权。
安装
在 SourceWeft 中
- 打开 控制台中的 tubekit,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
tubekit-mcp
Compliance-aware Model Context Protocol server for YouTube publishing, analytics, and creator insights — every action gated, metered, and audited before it touches a channel.
[CI] [License: FSL-1.1-MIT] [Python 3.11+] [Type-checked: mypy strict] [Lint: ruff]
tubekit-mcp is an MCP server: you connect it to an MCP client (Claude Desktop,
Claude Code, …) and the assistant can then publish and manage videos on a
YouTube channel on your behalf, with compliance checks, quota accounting,
idempotent uploads and a tamper-evident audit log on every state-changing call.
Licensed under FSL-1.1-MIT — run and self-host it freely,
commercially or not; each release becomes plain MIT two years after publication.
Architecture
A single tool call (e.g. upload_video) flows through a compliance gate, a
quota / idempotency ledger, an OAuth refresh, the YouTube API, and a
tamper-evident audit row — with the pure core kept free of protocol concerns,
a boundary enforced in CI by an AST fitness test
(tests/unit/services/test_no_fastmcp_imports.py).
Why this exists. Agents are starting to operate real YouTube channels — and a channel is an asset you can lose. One bad call can publish a video that violates policy, burn the day's API quota (an upload costs 1600 of the default 10,000 daily units), or double-publish on a retry. Generic YouTube wrappers hand the agent the raw API;
tubekitwraps every call in the guardrails an unattended operator needs: a compliance gate before anything goes live, quota accounted before it is spent, idempotent retries, OAuth tokens encrypted at rest (fingerprint-only logging), and a tamper-evident audit chain of everything the agent did. Full design rationale in ADR 0001.
Usage
Prerequisites
Before an assistant can act on a channel you need, once per channel:
- A Google Cloud project with the YouTube Data API v3 (and YouTube
Analytics API if you use
get_analytics) enabled. - An OAuth client of type Desktop app, downloaded as
client_secret.json. - The channel whose Google account will grant the consent.
The OAuth grant is interactive and only happens here — tubekit stores the
resulting refresh token Fernet-encrypted and never prints it. Never used
Google Cloud Console? docs/runbooks/gcp-setup.md
walks the whole thing from zero (project, APIs, consent screen, client type,
and the two Google policies — token expiry in testing, private-locked uploads
for unaudited projects — that surprise people later). The consent flows
themselves are in
docs/runbooks/oauth-bootstrap.md.
Install
From PyPI:
Use uv tool install, not uvx, for a real setup: the one-time steps below need
the tubekit CLI to still be there afterwards. uvx tubekit-mcp runs the stdio
server from a throwaway environment, which is what an MCP client's config points
at once the setup is done.
The server will not start yet, and that is deliberate — it refuses to run without a master key rather than inventing one, since that key is what encrypts your OAuth tokens at rest. One-time setup below is the two commands that fix it.
Or from source, for development:
(uv itself installs with curl -LsSf https://astral.sh/uv/install.sh | sh.)
Try it in 60 seconds — no Google account needed
The compliance engine is pure-local, so you can watch the gate and its
self-correction Suggestions work before touching Google Cloud:
An error-severity violation — say a 126-character title — fails the gate with
exit 1 and a machine-applicable fix (suggestion: action=truncate field=metadata.title value=100). That is the same Suggestion an agent
receives from a rejected upload_video and applies before retrying (ADR D8).
tubekit compliance list prints the rule catalog; tubekit compliance manifest exports it for external auditors.
Install with an AI agent
Rather not type the commands above yourself? Paste the block below into Claude
Code (or any coding agent with shell access) and it will clone, install and
register the server for you. It stops at the boundary above: no Google
account, client_secret.json or OAuth consent is involved.
Restart your MCP client after registration; it can now call tubekit.health()
and list the full tool catalog. Every tool that takes a channel argument —
validate_compliance included — needs a configured channel, which means
completing One-time setup — including the OAuth consent in
docs/runbooks/oauth-bootstrap.md —
yourself. The compliance gate itself is testable without any channel via
step 3's tubekit compliance test.
One-time setup
Connect to an MCP client (stdio)
Most clients launch the server over stdio. Add this to the client's MCP
config (for Claude Desktop: claude_desktop_config.json):
Restart the client. The assistant now sees the tools below plus a
tubekit.health() probe. Ask it, e.g., "upload ./intro.mp4 to mychannel" and
it will call upload_video, which gates on compliance, charges quota, refreshes
OAuth and writes an audit row — all transparently.
Available tools
Playlist writes take a
playlist_item_id, never a bare video id: the same video may appear in a list more than once, so YouTube cannot disambiguate from the video alone. Get the ids from onelist_playlist_itemscall (1 unit) and reuse them — the services deliberately do not resolve them for you, because that would be a quota charge the caller never asked for.Playlists are not run through the compliance registry: it scores video metadata (thumbnail, category, tags, synthetic-media declaration), none of which a playlist has, and its
TITLE_TOO_LONGwould apply the video ceiling (100) to a resource whose real ceiling is 150. What is enforced instead is what Google documents for the playlist resource: a non-empty title, a validprivacyStatus, ≤150 characters of title, ≤5000 of description, and no<,>or U+2028 in either. Those limits live in the YouTube Help page, not in the Data API reference — which documents none, and is why they were missed at first.
Comments tools need the channel grant to carry
youtube.force-ssl(moderation-status filtering is owner-only). Verify withcheck_oauth; if missing, re-consent once:tubekit auth setup-channel --scopes …,https://www.googleapis.com/auth/youtube.force-ssl.
Revenue figures across the report tools are estimated ad + YouTube Premium
revenue only (memberships, Super Chat and Shopping are not exposed by the
channel-level APIs), lag ~2 days (period.revenue_complete_until), and are
finalized around the 10th of the following month. Thumbnail impressions/CTR are
not available in the targeted Analytics API. get_analytics remains the raw
escape hatch for any ad-hoc query.
Every tool returns a ToolResult envelope (ok + data, or a structured
ToolError whose code is one of the documented error codes). On a compliance
failure the error carries a Suggestion the assistant can apply and retry — the
self-correction loop described in ADR D8.
HTTP transport (multi-user)
For remote / multi-tenant use, run the HTTP transport instead. It requires a per-client Bearer API token scoped to specific channels and tools, with an optional per-token rate limit:
Clients send Authorization: Bearer <token>. Requests that are
unauthenticated, out-of-scope, or rate-limited get JSON-RPC errors
(-32001..-32006). GET /healthz returns the liveness payload; the
per-channel detail (aliases, OAuth expiry) is added only for a valid Bearer and
narrowed to that token's channels. Manage tokens with
tubekit auth list | show | revoke | rotate.
To run this centrally on a VPS (one server, many projects connecting over
HTTPS), follow docs/runbooks/vps-deploy.md —
a self-contained, step-by-step deployment guide (systemd + Traefik + per-project
tokens) written for an infra team.
Media ingest (remote upload_video)
upload_video(video_path) reads the file from the server's filesystem — a
client-local path can never resolve on a remote deployment. There are two ways
to get the media onto the server.
Brokered upload (recommended, no ssh). The agent orchestrates the whole
transfer over HTTP via the MCP. Call request_ingest_upload, then PUT the
bytes to the one-time URL it returns (same Bearer token), then upload_video
with the returned server-side path:
The server streams the body to a staging .part, verifies size_bytes + sha256,
and atomically publishes before upload_video reads it. The URL is a single-use,
channel-bound capability with a TTL; an interrupted transfer resumes via HEAD +
Content-Range. Design rationale: ADR 0002.
Requires TUBEKIT_INGEST_UPLOAD_URL_BASE to be set (otherwise the tool returns
precondition_failed).
rsync convention (fallback, requires ssh). Transfer out-of-band, then call the tool with the server-side path:
Set TUBEKIT_INGEST_DIR to the in-server ingest path (e.g. /ingest): when a
video_path is unreadable the tool returns validation_error with a
suggestion pointing the calling agent at this convention. See the
media-ingest section of the VPS runbook
for the volume mount and retention policy.
Environment variables
All settings use the TUBEKIT_ prefix (see .env.example):
A lost
state.db/master.keypair means re-bootstrapping every channel. Back them up together — seedocs/runbooks/state-db-backup.md.
Hosted version
Gatecast is the hosted tier of tubekit — same engine, run and kept alive for you. It is pre-launch; the waiting list is the whole thing so far. Self-hosting with this repo is and stays fully supported.
Development
make demo-stack-up brings up the Jaeger/Prometheus/Grafana observability stack
with five provisioned dashboards (docker-compose.demo.yml, docs/grafana/).
Repository layout
Contributing & security
- Contributions are welcome — see
CONTRIBUTING.mdfor the workflow and quality bar. - Report security vulnerabilities privately per
SECURITY.md. - Release history is in
CHANGELOG.md; the roadmap lives indocs/ROADMAP.md.
License
FSL-1.1-MIT © 2026 sriera
The Functional Source License in plain words: read it, run it, modify it, self-host it for your own channels — commercially or not. The one thing it forbids is offering tubekit itself to others as a competing product or service. Each release additionally becomes plain MIT two years after its publication, automatically and irrevocably.
来源:README.md,提交 6d29e6a
工具
0版本历史
1- v0.3.0最新Sep 16, 2026
评分
已满足适用检查项的 40%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
请在仓库或注册中心条目中声明许可证。