Skip to main content
Glama
jedarden

YouTube Transcript DL MCP Server

by jedarden

get_transcript

Extract transcript text from YouTube videos to access spoken content in text, JSON, or SRT formats for analysis, translation, or accessibility purposes.

Instructions

Extract transcript from a single YouTube video

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
videoIdYesYouTube video ID or URL
languageNoLanguage code (e.g., "en", "es", "fr")en
formatNoOutput formatjson

Implementation Reference

  • MCP tool handler for 'get_transcript'. Validates args, calls YouTubeTranscriptService.getTranscript, formats response as MCP content with JSON text.
    private async handleGetTranscript(args: any) {
      const { videoId, language = 'en', format = 'json' } = args;
      
      if (!videoId) {
        throw new McpError(ErrorCode.InvalidParams, 'videoId is required');
      }
    
      const result = await this.transcriptService.getTranscript(videoId, language, format);
      
      return {
        content: [{
          type: 'text',
          text: JSON.stringify(result, null, 2)
        }]
      };
    }
  • Registration of the 'get_transcript' tool in the listTools response, including name, description, and input schema definition.
    {
      name: 'get_transcript',
      description: 'Extract transcript from a single YouTube video',
      inputSchema: {
        type: 'object',
        properties: {
          videoId: {
            type: 'string',
            description: 'YouTube video ID or URL'
          },
          language: {
            type: 'string',
            description: 'Language code (e.g., "en", "es", "fr")',
            default: 'en'
          },
          format: {
            type: 'string',
            enum: ['text', 'json', 'srt'],
            description: 'Output format',
            default: 'json'
          }
        },
        required: ['videoId']
      }
    },
  • Input schema and metadata for the 'get_transcript' tool used for validation in MCP listTools.
    {
      name: 'get_transcript',
      description: 'Extract transcript from a single YouTube video',
      inputSchema: {
        type: 'object',
        properties: {
          videoId: {
            type: 'string',
            description: 'YouTube video ID or URL'
          },
          language: {
            type: 'string',
            description: 'Language code (e.g., "en", "es", "fr")',
            default: 'en'
          },
          format: {
            type: 'string',
            enum: ['text', 'json', 'srt'],
            description: 'Output format',
            default: 'json'
          }
        },
        required: ['videoId']
      }
    },
  • Core helper function implementing transcript extraction logic: caching, video ID extraction, Python script execution for fetching transcript data from YouTube, result processing, error handling.
    public async getTranscript(
      videoId: string,
      language: string = 'en',
      format: 'text' | 'json' | 'srt' = 'json'
    ): Promise<TranscriptResponse> {
      try {
        // Clean video ID from URL if needed
        const cleanVideoId = this.extractVideoId(videoId);
        const cacheKey = `transcript:${cleanVideoId}:${language}:${format}`;
    
        // Check cache first
        const cached = this.cache.get<TranscriptResponse>(cacheKey);
        if (cached) {
          this.logger.debug(`Cache hit for video ${cleanVideoId}`);
          return cached;
        }
    
        this.logger.info(`Fetching transcript for video: ${cleanVideoId}`);
    
        // Call Python script to get transcript
        const command = `python3 "${this.pythonScript}" fetch --video-id "${cleanVideoId}" --language "${language}"`;
        const { stdout, stderr } = await execAsync(command);
    
        if (stderr) {
          this.logger.warn(`Python script warning: ${stderr}`);
        }
    
        const pythonResult: PythonTranscriptResult = JSON.parse(stdout);
    
        if (!pythonResult.success) {
          throw new Error(pythonResult.error || 'Failed to fetch transcript');
        }
    
        // Convert to our format
        const transcript: TranscriptItem[] = pythonResult.transcript.map(item => ({
          text: item.text,
          start: item.start,
          duration: item.duration
        }));
    
        const response: TranscriptResponse = {
          videoId: cleanVideoId,
          title: await this.getVideoTitle(cleanVideoId), // Try to get title
          language,
          transcript,
          metadata: {
            extractedAt: new Date().toISOString(),
            source: 'youtube-transcript-api',
            duration: pythonResult.metadata?.duration || transcript.reduce((acc, item) => acc + item.duration, 0)
          }
        };
    
        // Cache the response
        this.cache.set(cacheKey, response);
    
        this.logger.info(`Successfully extracted transcript for video ${cleanVideoId}`);
        return response;
    
      } catch (error) {
        this.logger.error(`Failed to extract transcript for video ${videoId}:`, error);
        
        // Return structured error response
        return {
          videoId: this.extractVideoId(videoId),
          title: 'Error',
          language,
          transcript: [],
          metadata: {
            extractedAt: new Date().toISOString(),
            source: 'youtube-transcript-api',
            error: error instanceof Error ? error.message : 'Unknown error'
          }
        };
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Extract') but doesn't describe what happens if the video lacks a transcript, rate limits, authentication needs, error handling, or the structure of the output. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core purpose and appropriately sized for the tool's complexity, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is incomplete. It lacks information on output format details, error cases, or behavioral traits. Without annotations or an output schema, the description should do more to compensate, such as explaining what the extracted transcript looks like or common pitfalls.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds no parameter semantics beyond what the input schema provides. Since schema description coverage is 100%, the schema already documents videoId, language, and format with descriptions and defaults. The baseline score of 3 is appropriate as the schema does the heavy lifting, but the description doesn't enhance understanding of parameter usage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Extract') and resource ('transcript from a single YouTube video'), distinguishing it from siblings like get_bulk_transcripts (multiple videos) and get_playlist_transcripts (playlist). However, it doesn't explicitly differentiate from format_transcript, which might be for post-processing rather than extraction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose get_transcript over get_bulk_transcripts for multiple videos, or when format_transcript might be needed for processing. There's no context about prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/jedarden/yt-transcript-dl-mcp'

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