Skip to main content
Glama
efikuta
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);

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