使用说明
yt-dlp mcp
异步MCP服务,用于下载视频和音频 yt-dlp 并通过以下方式转录 组装AI --作为MCP工具公开给Claude和其他LLM客户。
┌──────────────────────┐
│ Claude / LLM app │
└──────────┬───────────┘
│ MCP (SSE/HTTP)
v
┌──────────────────────┐
│ mcp_server/ │
│ FastMCP proxy │
│ (fastmcp.cloud) │
└──────────┬───────────┘
│ CF Access service token
v
┌────────────────────────────────────────────────────────────────┐
│ Cloudflare Tunnel (terraform/) │
└────────────────────────────────┬───────────────────────────────┘
│
v
┌────────────────────────────────────────────────────────────────┐
│ backend/ (Docker) │
│ │
│ ┌────────────┐ ┌──────────────┐ ┌─────────────────────┐ │
│ │ FastMCP │──>│ Job Queue │──>│ Background Worker │ │
│ │ /mcp │ │ (SQLite) │ │ │ │
│ └────────────┘ └──────────────┘ │ 1. yt-dlp download │ │
│ │ 2. AssemblyAI API │ │
│ │ 3. Write artifacts │ │
│ └──────────┬──────────┘ │
│ │ │
│ v │
│ ┌─────────────────────┐ │
│ │ /data/transcripts/ │ │
│ │ {platform}/ │ │
│ │ {channel}/ │ │
│ │ {video_id}/ │ │
│ │ transcript.md │ │
│ │ transcript.json │ │
│ │ transcript.txt │ │
│ │ audio.mp3 │ │
│ │ metadata.json │ │
│ └─────────────────────┘ │
└────────────────────────────────────────────────────────────────┘
MCP工具
| 工具 | 说明 |
|---|---|
transcribe(url) |
排队下载+转录视频URL。立即返回 job_id. |
job_status(job_id) |
轮询作业进度: queued → downloading → transcribing → completed / failed |
search(query, limit) |
在所有成绩单中进行全文搜索 |
list_transcripts(platform, channel, limit) |
使用可选过滤器浏览可用成绩单 |
read_transcript(video_id, format) |
阅读成绩单 markdown, text,或 json |
重复的URL会自动进行重复数据消除——如果成绩单已经存在或作业正在执行中,则返回现有结果。
回购结构
yt-dlp-mcp/
├── mcp_server/ # FastMCP proxy (deployed to fastmcp.cloud)
│ ├── server.py # OAuth + CF Access → proxies to backend
│ └── pyproject.toml
├── backend/ # Transcription service (Docker)
│ ├── src/yt_dlp_mcp/ # MCP tools, worker, DB, services
│ ├── tests/
│ ├── Dockerfile
│ ├── docker-compose.yml
│ ├── pyproject.toml
│ └── scripts/ # deploy.sh, destroy.sh, terraformw.sh
├── terraform/ # Cloudflare Tunnel + DNS
├── .github/workflows/ # CI (lint/test/build) + Deploy (GHCR + terraform)
└── Makefile # Docker, terraform, and deploy shortcuts
快速开始
先决条件
- 码头工人
- 一 AssemblyAI API键
- Cloudflare帐户(用于隧道部署)
本地开发
# Install backend in editable mode
pip install -e backend/[dev]
# Run tests
pytest backend/tests -q
# Run the backend directly (needs ASSEMBLYAI_API_KEY)
cp backend/.env.example .env
# ... fill in your keys ...
yt-dlp-mcp
码头工人
make build # Build the image
make up # Start the backend (no tunnel)
make up-tunnel # Start backend + Cloudflare tunnel
make down # Stop everything
make health # Check /healthz
make logs-app # Tail logs
全面部署
# 1. Fill in .env from backend/.env.example
# 2. Deploy tunnel + DNS + start containers
make deploy
# Tear down
make destroy
仅限地形
make tf-init # terraform init
make tf-apply # terraform apply
make tf-destroy # terraform destroy
环境变量
创建 .env 在repo根目录(参见 backend/.env.example):
| 变量 | 必填 | 描述 |
|---|---|---|
ASSEMBLYAI_API_KEY |
是 | AssemblyAI转录API键 |
GOOGLE_CLIENT_ID |
对于OAuth | 谷歌OAuth客户端ID |
GOOGLE_CLIENT_SECRET |
对于OAuth | 谷歌OAuth客户端密钥 |
PUBLIC_BASE_URL |
对于OAuth | 服务的公共URL |
CLOUDFLARE_ACCOUNT_ID |
用于部署 | CF帐户ID |
CLOUDFLARE_ZONE_ID |
用于部署 | CF区域ID |
CLOUDFLARE_API_TOKEN |
用于部署 | CF API令牌 |
DOMAIN |
用于部署 | 例如。 pantainos.net |
SUBDOMAIN |
用于部署 | 例如。 yt-cli |
CI/CD
- 持续集成 --在每个推送/PR上运行:ruff、mypy、pytest、Docker构建冒烟测试
- 部署 --运行推送
main+nightly cron:构建并推送到GHCR,然后应用terraform