youtube-transcript-extractor
Extract text transcripts from YouTube videos to analyze and work with video content directly.
Instructions
Extracts the transcript of a YouTube video.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | a youtube video url |
Implementation Reference
- index.ts:20-35 (handler)Handler function that extracts the transcript from a YouTube video by parsing the video ID from the input URL, fetching the transcript using YoutubeTranscript, joining the text parts, and returning it as text content.async ({ input }) => { const videoData = getVideoId(input); const output = await YoutubeTranscript.fetchTranscript(videoData.id as string).then((transcript: any) => { const text = transcript.map((t: any) => t.text).join(' '); return text; }); return { content: [ { type: "text", text: output, }, ], }; }
- index.ts:17-19 (schema)Zod schema defining the input as a string representing a YouTube video URL.{ input: z.string().describe("a youtube video url"), },
- index.ts:14-36 (registration)Registers the 'youtube-transcript-extractor' tool with the MCP server, including name, description, input schema, and handler function.server.tool( "youtube-transcript-extractor", "Extracts the transcript of a YouTube video.", { input: z.string().describe("a youtube video url"), }, async ({ input }) => { const videoData = getVideoId(input); const output = await YoutubeTranscript.fetchTranscript(videoData.id as string).then((transcript: any) => { const text = transcript.map((t: any) => t.text).join(' '); return text; }); return { content: [ { type: "text", text: output, }, ], }; } );