youtube-transcript-extractor
Extract the transcript from any YouTube video by providing the video URL. Enables AI systems to analyze and process video content directly for insights and workflow integration.
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 video ID from the input URL, fetches the transcript using the YoutubeTranscript library, joins all transcript text segments into a single string, and returns it formatted as MCP 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 tool's input parameter 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, providing 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, }, ], }; } );
- index.ts:3-4 (helper)Imports helper libraries: 'youtube-transcript' for fetching transcripts and 'get-video-id' for extracting video IDs from URLs.import { YoutubeTranscript } from 'youtube-transcript'; import getVideoId from 'get-video-id';