Skip to main content
Glama
efikuta
by efikuta

analyze_video_content

Analyze YouTube videos to extract key insights including topics, sentiment, questions, summaries, and keywords from video content and comments.

Instructions

Get AI-powered analysis and insights from video content

Input Schema

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

Implementation Reference

  • Main handler function in AnalyzeContentTool.execute() that parses args with schema, fetches video data, performs analysis, and returns results with caching.
    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; } }
  • src/index.ts:322-348 (registration)
    Tool registration in the list of available tools, including 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)
    Dispatch to handler in the tool call switch statement.
    case 'analyze_video_content': result = await this.analyzeTool.execute(args); break;
  • Zod schema definition for input validation used in the handler.
    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:174-174 (registration)
    Instantiation of the AnalyzeContentTool handler instance.
    this.analyzeTool = new AnalyzeContentTool(this.youtubeClient, this.cache, this.transcriptProcessor, this.logger);

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