Skip to main content
Glama
efikuta

YouTube Knowledge MCP

by efikuta

get_video_details

Retrieve comprehensive YouTube video data including metadata, transcripts, and comments to analyze content and gather insights.

Instructions

Get comprehensive information about a specific YouTube video

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
videoIdYesYouTube video ID
includeTranscriptNoWhether to include video transcript
includeCommentsNoWhether to include video comments
maxCommentsNoMaximum number of comments to retrieve
commentsOrderNoSort order for commentsrelevance

Implementation Reference

  • The primary handler function for the 'get_video_details' tool. Validates input using the schema, checks cache and quota, fetches raw data from YouTubeClient, enhances with analysis (transcript processing, comment analysis, engagement metrics), caches the result, and handles errors with partial cache fallback.
    async execute(args: unknown): Promise<VideoDetailsResult> {
      // Validate input parameters
      const params = GetVideoDetailsSchema.parse(args);
      
      this.logger.info(`Getting video details for: ${params.videoId}`);
    
      // Generate cache key
      const cacheKey = this.cache.getVideoDetailsKey(
        params.videoId, 
        params.includeTranscript, 
        params.includeComments
      );
    
      // Check cache first
      const cached = await this.cache.get<VideoDetailsResult>(cacheKey);
      if (cached) {
        this.logger.info(`Returning cached video details for: ${params.videoId}`);
        return cached;
      }
    
      // Check quota before making API call
      const operationCost = this.calculateOperationCost(params);
      if (!this.quotaManager.canPerformOperation(operationCost)) {
        throw new QuotaExceededError('Insufficient quota for video details operation');
      }
    
      try {
        // Get video details from YouTube API
        const result = await this.youtubeClient.getVideoDetails(params);
        
        // Record quota usage
        await this.quotaManager.recordUsage(operationCost, 'video_details');
        
        // Enhance the result with additional processing
        const enhancedResult = await this.enhanceVideoDetails(result, params);
        
        // Cache the result
        await this.cache.set(cacheKey, enhancedResult);
        
        this.logger.info(`Video details retrieved for: ${params.videoId}`);
        
        return enhancedResult;
    
      } catch (error) {
        this.logger.error(`Failed to get video details for ${params.videoId}:`, error);
        
        // Try to return partial cached data if quota exceeded
        if (error instanceof QuotaExceededError) {
          const partialCache = await this.getPartialCachedData(params.videoId);
          if (partialCache) {
            this.logger.warn('Returning partial cached data due to quota limits');
            return partialCache;
          }
        }
        
        throw error;
      }
    }
  • Zod schema for input validation of get_video_details tool parameters, defining videoId as required and optional flags for transcript, comments with limits.
    export const GetVideoDetailsSchema = z.object({
      videoId: z.string().describe('YouTube video ID'),
      includeTranscript: z.boolean().default(true).describe('Whether to include video transcript'),
      includeComments: z.boolean().default(true).describe('Whether to include video comments'),
      maxComments: z.number().min(1).max(100).default(50).describe('Maximum number of comments to retrieve'),
      commentsOrder: z.enum(['relevance', 'time']).default('relevance').describe('Sort order for comments'),
    });
  • src/index.ts:259-295 (registration)
    Tool registration in the listTools response, defining name, description, and inputSchema matching the Zod schema.
    {
      name: 'get_video_details',
      description: 'Get comprehensive information about a specific YouTube video',
      inputSchema: {
        type: 'object',
        properties: {
          videoId: {
            type: 'string',
            description: 'YouTube video ID'
          },
          includeTranscript: {
            type: 'boolean',
            default: true,
            description: 'Whether to include video transcript'
          },
          includeComments: {
            type: 'boolean',
            default: true,
            description: 'Whether to include video comments'
          },
          maxComments: {
            type: 'number',
            minimum: 1,
            maximum: 100,
            default: 50,
            description: 'Maximum number of comments to retrieve'
          },
          commentsOrder: {
            type: 'string',
            enum: ['relevance', 'time'],
            default: 'relevance',
            description: 'Sort order for comments'
          }
        },
        required: ['videoId']
      }
    },
  • src/index.ts:563-565 (registration)
    Handler dispatch in the CallToolRequestSchema handler switch statement, routing 'get_video_details' calls to VideoDetailsTool.execute()
    case 'get_video_details':
      result = await this.videoDetailsTool.execute(args);
      break;
  • Supporting helper in YouTubeClient that performs the actual YouTube API calls for video details, optionally fetching transcript and comments.
    async getVideoDetails(params: GetVideoDetailsParams): Promise<VideoDetailsResult> {
      try {
        const videos = await this.getVideosByIds([params.videoId]);
        const video = videos[0];
        
        if (!video) {
          throw new YouTubeAPIError(`Video not found: ${params.videoId}`);
        }
    
        const result: VideoDetailsResult = { video };
    
        // Get transcript if requested
        if (params.includeTranscript) {
          try {
            result.transcript = await this.getVideoTranscript(params.videoId);
          } catch (error) {
            this.logger.warn(`Failed to get transcript for ${params.videoId}:`, error);
          }
        }
    
        // Get comments if requested
        if (params.includeComments) {
          try {
            result.comments = await this.getVideoComments(
              params.videoId,
              params.maxComments,
              params.commentsOrder
            );
          } catch (error) {
            this.logger.warn(`Failed to get comments for ${params.videoId}:`, error);
          }
        }
    
        return result;
    
      } catch (error) {
        this.handleError(error);
        throw error;
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'comprehensive information' but doesn't specify what that includes beyond the parameters (e.g., metadata like title, duration, or statistics), whether it's a read-only operation, potential rate limits, authentication needs, or error handling. For a tool with 5 parameters and no annotation coverage, this leaves significant behavioral gaps.

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 that front-loads the core purpose ('Get comprehensive information about a specific YouTube video'). There is no wasted verbiage, repetition, or unnecessary details, making it highly concise and well-structured for quick understanding.

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

Completeness3/5

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

Given the complexity (5 parameters, no annotations, no output schema), the description is minimally adequate. It states the purpose clearly but lacks behavioral context, usage guidelines, and details on return values. With no output schema, the description doesn't explain what 'comprehensive information' includes, leaving gaps in completeness. It meets a basic threshold but doesn't fully address the tool's scope.

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 input schema has 100% description coverage, providing clear details for all 5 parameters (e.g., videoId, includeTranscript, maxComments range). The description adds no additional parameter semantics beyond implying 'comprehensive information,' which aligns with the schema but doesn't enhance it. With high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate but also doesn't detract.

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 ('Get') and resource ('comprehensive information about a specific YouTube video'). It distinguishes from siblings like 'get_trending_videos' (which lists videos) and 'analyze_video_content' (which analyzes rather than retrieves information). However, it doesn't explicitly differentiate from all siblings like 'simplify_video_transcript' or 'generate_video_chapters', which prevents a perfect score.

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 prerequisites (e.g., needing a valid video ID), exclusions (e.g., not for batch processing), or comparisons to siblings like 'youtube_search' (for finding videos) or 'analyze_video_content' (for deeper analysis). Usage is implied by the name and purpose but not explicitly stated.

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/efikuta/youtube-knowledge-mcp'

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