transcripts_getTranscript
Extract video transcripts from YouTube to analyze spoken content, enable accessibility, or create text-based resources from video material.
Instructions
Get the transcript of a YouTube video
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| videoId | Yes | The YouTube video ID | |
| language | No | Language code for the transcript |
Implementation Reference
- src/services/transcript.ts:24-42 (handler)Core handler function that fetches the YouTube video transcript using the YoutubeTranscript library and formats the response.async getTranscript({ videoId, language = process.env.YOUTUBE_TRANSCRIPT_LANG || 'en' }: TranscriptParams): Promise<unknown> { try { this.initialize(); // YoutubeTranscript.fetchTranscript only accepts videoId const transcript = await YoutubeTranscript.fetchTranscript(videoId); return { videoId, language, transcript }; } catch (error) { throw new Error(`Failed to get transcript: ${error instanceof Error ? error.message : String(error)}`); } }
- src/types.ts:37-40 (schema)TypeScript interface defining the input parameters for the transcript tool (videoId required, language optional).export interface TranscriptParams { videoId: string; language?: string; }
- src/server-utils.ts:178-197 (registration)Registers the 'transcripts_getTranscript' tool with Zod input schema and a thin handler that delegates to TranscriptService.'transcripts_getTranscript', { title: 'Get Video Transcript', description: 'Get the transcript of a YouTube video', annotations: { readOnlyHint: true, idempotentHint: true }, inputSchema: { videoId: z.string().describe('The YouTube video ID'), language: z.string().optional().describe('Language code for the transcript'), }, }, async ({ videoId, language }) => { const result = await transcriptService.getTranscript({ videoId, language }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } );