Skip to main content
Glama

transcripts_getTranscript

Retrieve the transcript of a YouTube video by specifying its video ID and optional language code. Use this tool to access video content text for analysis, translation, or accessibility purposes.

Instructions

Get the transcript of a YouTube video

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
languageNoLanguage code for the transcript
videoIdYesThe YouTube video ID

Implementation Reference

  • The primary handler function that fetches the YouTube video transcript using the YoutubeTranscript library and returns it structured with videoId, language, and transcript data.
    async getTranscript({ 
      videoId, 
      language = process.env.YOUTUBE_TRANSCRIPT_LANG || 'en' 
    }: TranscriptParams): Promise<any> {
      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)}`);
      }
    }
  • TypeScript interface defining the input parameters for the transcripts_getTranscript tool: videoId (required) and language (optional).
    export interface TranscriptParams {
      videoId: string;
      language?: string;
    }
  • src/server.ts:81-98 (registration)
    Tool registration in the MCP server's ListToolsRequestHandler, defining the tool name, description, and input schema matching TranscriptParams.
    {
        name: 'transcripts_getTranscript',
        description: 'Get the transcript of a YouTube video',
        inputSchema: {
            type: 'object',
            properties: {
                videoId: {
                    type: 'string',
                    description: 'The YouTube video ID',
                },
                language: {
                    type: 'string',
                    description: 'Language code for the transcript',
                },
            },
            required: ['videoId'],
        },
    },
  • Dispatch handler in the MCP CallToolRequestHandler that casts arguments to TranscriptParams and calls the TranscriptService.getTranscript method, formatting the result as MCP content.
    case 'transcripts_getTranscript': {
        const result = await transcriptService.getTranscript(args as unknown as TranscriptParams);
        return {
            content: [{
                type: 'text',
                text: JSON.stringify(result, null, 2)
            }]
        };
    }
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ZubeidHendricks/youtube-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server