yt-mcp
MCP server for managing YouTube channels using Data API v3 and Analytics. Supports video upload, comments, playlists, and analytics via ~30 tools, with stateless OAuth authentication.
README
yt-mcp — YouTube MCP Server
MCP server quản lý kênh YouTube (Data API v3 + Analytics), kiến trúc stateless
theo tinh thần Facebook MCP: server không lưu token người dùng. Client giữ
refresh token, server đổi ra access token và cache RAM theo sha256(refresh_token).
Xem thiết kế chi tiết + lý do từng quyết định: docs/thiet-ke.md.
Kiến trúc
server.py → khai báo tool @mcp.tool() (passthrough mỏng)
manager.py → điều phối, ráp tham số
youtube_api.py → gọi Data API v3 + Analytics (google-api-python-client)
auth.py → refresh→access + cache theo hash(refresh token)
jobs.py → upload async in-memory (job)
web.py → route /auth, /auth/callback, /upload
config.py → scope + hằng số
run_http.py → streamable-http (stateless) + gắn route web
Chuẩn bị Google Cloud (1 lần)
- Tạo project ở Google Cloud Console (tài khoản
hoangtuanbka93@gmail.com). - Bật YouTube Data API v3 và YouTube Analytics API.
- OAuth consent screen: External → Publish app → In production (chấp nhận "unverified"; nếu Testing thì refresh token chết sau 7 ngày).
- Tạo OAuth client ID kiểu Web application. Thêm Authorized redirect URI:
https://<host>.<tailnet>.ts.net/auth/callback. - Lấy
client_id+client_secret.
Cấu hình & chạy
Tạo file .env cạnh compose.yaml:
GOOGLE_CLIENT_ID=xxx.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=xxx
PUBLIC_BASE_URL=https://my-host.tailnet-name.ts.net
docker compose up -d --build
- Endpoint MCP:
https://<host>.<tailnet>.ts.net/mcp - Trang lấy token:
https://<host>.<tailnet>.ts.net/auth - Trang đẩy file:
https://<host>.<tailnet>.ts.net/upload
Lấy refresh token (1 lần)
Mở https://<host>.<tailnet>.ts.net/auth bằng browser → đồng ý (bấm qua cảnh báo
"unverified app" 1 lần) → trang hiện refresh token → copy.
Khai báo ở MCP client
"yt-mcp": {
"url": "https://<host>.<tailnet>.ts.net/mcp",
"headers": { "x-youtube-refresh-token": "1//dán_refresh_token_ở_đây" }
}
Quản nhiều kênh = khai báo nhiều kết nối, mỗi cái một refresh token khác.
Upload video
source của youtube_video_upload nhận 3 dạng:
| Nguồn | source |
Cách đưa file lên |
|---|---|---|
| File trên laptop | id up_xxx |
mở /upload kéo-thả, hoặc curl -F file=@video.mp4 https://<host>/upload |
| File có URL | https://.../video.mp4 |
server tự tải |
| File trên máy chủ | /data/video.mp4 |
bỏ vào thư mục ./data (đã mount) |
Upload chạy nền → trả job_id → poll bằng youtube_upload_status(job_id).
Danh sách tool (~30)
- Channel:
youtube_channel_get(bỏ trống = whoami),youtube_channel_update - Video:
youtube_video_get,youtube_video_list_mine,youtube_video_update,youtube_video_delete,youtube_video_rate,youtube_video_set_privacy - Upload:
youtube_video_upload,youtube_upload_status - Search:
youtube_search - Comment:
youtube_comment_list,youtube_comment_thread_get,youtube_comment_reply,youtube_comment_moderate,youtube_comment_delete - Playlist:
youtube_playlist_create/list/get/update/delete,youtube_playlist_items,youtube_playlist_item_add/remove - Analytics:
youtube_analytics_video/channel/top_videos
Ràng buộc đã biết
- Quota dùng chung: 1 OAuth app = 10.000 unit/ngày cho mọi client (upload=1.600/lần). Chạm trần thì xin Google nâng quota.
- Upload file client-local luôn 2 bước (đẩy file → gọi tool).
- Job upload lưu in-memory → mất khi restart container.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.