YouTube转录MCP服务器
用于获取YouTube视频转录(字幕)的MCP服务器。无需身份验证即可工作,支持自动和手动字幕。
运输: 超文本传输协议 --建议用于远程服务器。
跑步```bash
docker compose up -d --build
服务器将在 `http://:8000/mcp`
## 代理配置
Dockerfile包括需要它们的网络环境的代理设置:```dockerfile
ENV http_proxy=http://proxy.server.com:8080
ENV https_proxy=http://proxy.server.com:8080
ENV no_proxy=localhost,127.0.0.1
如果你不需要代理:
- 删除或注释掉这些行
Dockerfile
如果您需要不同的代理设置:
- 更新中的代理URL
Dockerfile以匹配您的网络配置
连接到VS代码
添加 mcp.json (VS代码全局设置):```json
{
"servers": {
"youtube-transcript": {
"url": "http://:8000/mcp",
"type": "http"
}
}
}
## 工具
所有工具都返回JSON `ok: bool` 现场。程序输入错误(空视频、无效范围)增加;运行时错误(未找到视频,网络)返回 `{"ok": false, "error": "..."}`.
### 转录本
|工具|参数|注释|
|------|--------|-------|
| `get_transcript` | `video`, `languages="en,ru"`, `timestamps=true` |完整成绩单,可选 `[MM:SS]` |
| `list_available_transcripts` | `video` |可用语言+自动/手动标志|
| `get_transcript_chunk` | `video`, `from_sec`, `to_sec`, `languages="en,ru"`, `timestamps=true` |时间范围切片|
| `search_in_transcript` | `video`, `query`, `languages="en,ru"`, `context_chars=50` |使用时间戳进行不区分大小写的搜索|
### 视频元数据
|工具|参数|注释|
|------|--------|-------|
| `get_video_info` | `video` |标题、频道、持续时间、视图、描述、标签|
| `get_video_chapters` | `video` |章节标题+开始/结束秒数(可能为空)|
| `get_thumbnail_url` | `video`, `quality="max"` |其中之一 `max`, `high`, `medium`, `default` |
### 发现
|工具|参数|注释|
|------|--------|-------|
| `search_videos` | `query`, `max_results=10` (第50章)| YouTube搜索|
| `get_channel_info` | `channel` | `@handle`、完整URL或UC…ID|
| `list_channel_videos` | `channel`, `max_results=20` (上限100)|最近上传|
| `get_playlist_videos` | `playlist`, `max_results=50` (上限200)|播放列表ID或完整URL|
`video` 接受ID或任何URL: `watch?v=…`, `youtu.be/…`, `shorts/…`, `embed/…`.
## 测试```bash
pip install -r requirements-dev.txt
pytest # unit only (fast)
pytest --run-integration # also hit real YouTube