Skip to main content
Glama
efikuta

YouTube Knowledge MCP

by efikuta

analyze_video_content

Analyze YouTube videos to extract summaries, topics, sentiment, keywords, and questions using AI-powered content analysis.

Instructions

Get AI-powered analysis and insights from video content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
videoIdYesYouTube video ID to analyze
analysisTypeNoTypes of analysis to perform
includeCommentsNoInclude comments in the analysis

Implementation Reference

  • Core handler method that executes the analyze_video_content tool logic: validates input, fetches video details, performs analysis (topics, sentiment, etc.), caches results, and returns structured analysis.
    async execute(args: unknown): Promise<{
      videoId: string;
      analysis: {
        topics?: string[];
        sentiment?: 'positive' | 'negative' | 'neutral';
        questions?: string[];
        summary?: string;
        keywords?: string[];
        readabilityScore?: number;
        contentType?: string;
        difficulty?: 'beginner' | 'intermediate' | 'advanced';
        engagement?: {
          likeRatio: number;
          commentEngagement: string;
          viewVelocity?: number;
        };
        timestamps?: Array<{
          time: number;
          topic: string;
          importance: number;
        }>;
      };
      metadata: {
        analysisTypes: string[];
        dataSourcesUsed: string[];
        processingTime: number;
      };
    }> {
      const startTime = Date.now();
      
      // Validate input parameters
      const params = AnalyzeVideoContentSchema.parse(args);
      
      this.logger.info(`Analyzing video content for: ${params.videoId}`);
    
      // Generate cache key
      const cacheKey = `analysis:${params.videoId}:${params.analysisType.sort().join(',')}:${params.includeComments}`;
    
      // Check cache first
      const cached = await this.cache.get(cacheKey);
      if (cached) {
        this.logger.info(`Returning cached analysis for: ${params.videoId}`);
        return cached;
      }
    
      try {
        // Get video details
        const videoDetails = await this.youtubeClient.getVideoDetails({
          videoId: params.videoId,
          includeTranscript: true,
          includeComments: params.includeComments,
          maxComments: 50
        });
    
        const analysis: any = {};
        const dataSourcesUsed: string[] = ['video_metadata'];
    
        // Perform requested analysis types
        for (const analysisType of params.analysisType) {
          switch (analysisType) {
            case 'topics':
              analysis.topics = await this.extractTopics(videoDetails, dataSourcesUsed);
              break;
            case 'sentiment':
              analysis.sentiment = await this.analyzeSentiment(videoDetails, dataSourcesUsed);
              break;
            case 'questions':
              analysis.questions = await this.extractQuestions(videoDetails, dataSourcesUsed);
              break;
            case 'summary':
              analysis.summary = await this.generateSummary(videoDetails, dataSourcesUsed);
              break;
            case 'keywords':
              analysis.keywords = await this.extractKeywords(videoDetails, dataSourcesUsed);
              break;
          }
        }
    
        // Add additional analysis
        analysis.readabilityScore = this.calculateReadabilityScore(videoDetails);
        analysis.contentType = this.identifyContentType(videoDetails);
        analysis.difficulty = this.assessDifficulty(videoDetails);
        analysis.engagement = this.analyzeEngagement(videoDetails);
        analysis.timestamps = this.generateTimestamps(videoDetails);
    
        const result = {
          videoId: params.videoId,
          analysis,
          metadata: {
            analysisTypes: params.analysisType,
            dataSourcesUsed,
            processingTime: Date.now() - startTime
          }
        };
    
        // Cache the result
        await this.cache.set(cacheKey, result, 3600); // 1 hour TTL
    
        this.logger.info(`Analysis completed for: ${params.videoId} in ${Date.now() - startTime}ms`);
        
        return result;
    
      } catch (error) {
        this.logger.error(`Failed to analyze video content for ${params.videoId}:`, error);
        throw error;
      }
    }
  • Zod schema defining input parameters for the analyze_video_content tool.
    export const AnalyzeVideoContentSchema = z.object({
      videoId: z.string().describe('YouTube video ID to analyze'),
      analysisType: z.array(z.enum(['topics', 'sentiment', 'questions', 'summary', 'keywords'])).default(['summary']).describe('Types of analysis to perform'),
      includeComments: z.boolean().default(false).describe('Include comments in the analysis'),
    });
  • src/index.ts:322-348 (registration)
    Tool registration in the listTools response, specifying name, description, and input schema.
      name: 'analyze_video_content',
      description: 'Get AI-powered analysis and insights from video content',
      inputSchema: {
        type: 'object',
        properties: {
          videoId: {
            type: 'string',
            description: 'YouTube video ID to analyze'
          },
          analysisType: {
            type: 'array',
            items: {
              type: 'string',
              enum: ['topics', 'sentiment', 'questions', 'summary', 'keywords']
            },
            default: ['summary'],
            description: 'Types of analysis to perform'
          },
          includeComments: {
            type: 'boolean',
            default: false,
            description: 'Include comments in the analysis'
          }
        },
        required: ['videoId']
      }
    },
  • src/index.ts:571-573 (registration)
    Switch case in callTool handler that dispatches to the AnalyzeContentTool.execute method.
    case 'analyze_video_content':
      result = await this.analyzeTool.execute(args);
      break;
  • src/index.ts:174-174 (registration)
    Instantiation of the AnalyzeContentTool handler instance.
    this.analyzeTool = new AnalyzeContentTool(this.youtubeClient, this.cache, this.transcriptProcessor, this.logger);
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 mentions 'AI-powered analysis' but lacks details on permissions, rate limits, processing time, or output format. For a tool with three parameters and no output schema, this is a significant gap in transparency about how the tool behaves and what to expect.

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 without unnecessary words. It avoids redundancy and wastes no space, making it easy for an agent to parse quickly while conveying the essential function.

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 complexity (AI analysis with multiple parameter options), lack of annotations, and no output schema, the description is insufficiently complete. It doesn't address behavioral aspects like error handling, output structure, or usage constraints, leaving critical gaps for the agent to understand the tool's full context and operation.

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?

Schema description coverage is 100%, so the input schema fully documents parameters like 'videoId' and 'analysisType.' The description adds no additional semantic context beyond implying general analysis, such as explaining what 'insights' entail or how parameters interact. This meets the baseline for high schema coverage but doesn't enhance understanding.

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 as 'Get AI-powered analysis and insights from video content,' specifying the action ('analysis and insights'), resource ('video content'), and method ('AI-powered'). However, it doesn't distinguish this from sibling tools like 'simplify_video_transcript' or 'generate_video_chapters,' which also process video content, leaving some ambiguity about scope differentiation.

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 sibling tools like 'get_video_details' for basic metadata or 'simplify_video_transcript' for text processing, nor does it specify prerequisites such as video accessibility or analysis scope. This leaves the agent without context for tool selection.

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