Add mcp-youtube MCP server for downloading YouTube subtitles - #3
Conversation
Implements the @anaisbetts/mcp-youtube package: an MCP stdio server exposing a download_youtube_url tool that fetches English subtitles via yt-dlp, strips VTT/SRT timing and markup noise, and returns the transcript so Claude can summarize YouTube videos. Includes bun tests for the subtitle cleaner, tsconfig, and README. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UDZyqVgbhHovtSKV4gzyRh
|
Important Review available on request
Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds a new standalone mcp-youtube/ MCP stdio server package that downloads and cleans YouTube subtitles via yt-dlp, enabling downstream clients to consume transcript text.
Changes:
- Introduces an MCP server with a
download_youtube_urltool that invokesyt-dlpand returns cleaned subtitle text. - Adds
stripVttNoisesubtitle-cleaning helper with Bun unit tests. - Adds package scaffolding (README, tsconfig, lockfile, gitignore) for publishing/building.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
mcp-youtube/src/index.ts |
Implements MCP server tool and subtitle-cleaning helper. |
mcp-youtube/test/strip-vtt-noise.test.ts |
Adds Bun tests for subtitle-cleaning behavior. |
mcp-youtube/package.json |
Defines package metadata, bin entry, deps, and scripts. |
mcp-youtube/tsconfig.json |
TypeScript configuration for the project. |
mcp-youtube/README.md |
Documents usage, prerequisites, and development commands. |
mcp-youtube/bun.lock |
Locks dependency versions for Bun. |
mcp-youtube/.gitignore |
Ignores build output and node_modules. |
Suppressed comments (1)
mcp-youtube/src/index.ts:144
- This entrypoint check is fragile when process.argv[1] is relative. Resolve argv[1] and convert it to a file URL before comparing to import.meta.url.
if (import.meta.url === `file://${process.argv[1]}`) {
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const seen = new Set<string>(); | ||
| const lines: string[] = []; | ||
|
|
||
| for (const rawLine of subtitles.split(/\r?\n/)) { | ||
| const line = rawLine | ||
| .replace(/<[^>]+>/g, "") | ||
| .replace(/\[Music\]|\[Applause\]/gi, "") | ||
| .trim(); | ||
|
|
||
| if ( | ||
| line === "" || | ||
| /^\d+$/.test(line) || | ||
| /^WEBVTT/.test(line) || | ||
| /^(Kind|Language):/.test(line) || | ||
| /-->/.test(line) | ||
| ) { | ||
| continue; | ||
| } | ||
|
|
||
| if (!seen.has(line)) { | ||
| seen.add(line); | ||
| lines.push(line); | ||
| } | ||
| } |
| import fs from "node:fs"; | ||
| import os from "node:os"; | ||
| import path from "node:path"; |
| try { | ||
| await spawnPromise( |
| let content = ""; | ||
| for (const file of fs.readdirSync(tempDir)) { | ||
| const fileContent = fs.readFileSync(path.join(tempDir, file), "utf8"); | ||
| content += `${file}\n====================\n${stripVttNoise(fileContent)}\n`; | ||
| } | ||
|
|
| "srt", | ||
| url, | ||
| ], | ||
| { cwd: tempDir, detached: true }, |
| content: [ | ||
| { | ||
| type: "text", | ||
| text: `Error downloading video: ${err}`, |
| description: | ||
| "Download YouTube subtitles from a URL, this tool means that Claude can read YouTube subtitles, and should no longer tell the user that it is not possible to summarize a YouTube video.", |
| "scripts": { | ||
| "prepublish": "git clean -xdf dist && bun build --target node src/index.ts --outdir dist", | ||
| "test": "bun test" | ||
| }, |
| "devDependencies": { | ||
| "shx": "^0.3.4", | ||
| "bun-types": "latest" | ||
| } |
Summary
Implements the
@anaisbetts/mcp-youtubepackage (v0.7.3) as a newmcp-youtube/project: a Model Context Protocol stdio server that lets Claude read YouTube video subtitles so it can summarize and answer questions about video content.What's included
src/index.ts— MCP server exposing a singledownload_youtube_urltool. It runsyt-dlpto fetch English subtitles (manual or auto-generated, converted to SRT) into a temp directory, cleans out WEBVTT headers, timing lines, sequence numbers, inline tags, and duplicated auto-caption cues, and returns the transcript text. Temp files are cleaned up withrimrafin all paths.test/strip-vtt-noise.test.ts— Bun tests for the subtitle-cleaning helper (4 passing).package.json— as specified in the task, with"type": "module"added so the ESM build runs under Node.tsconfig.json,README.md(install/usage docs incl.yt-dlpprerequisite),.gitignore,bun.lock.Verification
bun test: 4 pass, 0 failbun build --target node src/index.ts --outdir distsucceedsinitialize+tools/listcorrectly returns thedownload_youtube_urltool🤖 Generated with Claude Code
https://claude.ai/code/session_01UDZyqVgbhHovtSKV4gzyRh
Generated by Claude Code