
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 分
請在儲存庫或註冊中心條目中宣告授權條款。