Skip to main content
Glama
efikuta
by efikuta

analyze_comment_intents

Extract user intents and actionable insights from YouTube comments to understand audience feedback, questions, and engagement patterns on specific videos.

Instructions

Analyze YouTube comments to extract user intents and actionable insights

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
intentCategoriesNoCustom intent categories to focus on (optional)
maxCommentsNoMaximum number of comments to analyze
videoIdYesYouTube video ID to analyze comments from

Implementation Reference

  • Main handler function `execute` in CommentIntentAnalyzer class that parses input, fetches comments, performs batch LLM analysis with fallback, generates comprehensive summary including intent distribution, sentiment, trends, and actionable insights.
    async execute(args: unknown): Promise<CommentIntentAnalysis> { const params = AnalyzeCommentIntentsSchema.parse(args); this.logger.info(`Analyzing comment intents for video: ${params.videoId}`); // Generate cache key const cacheKey = `comment_intents:${params.videoId}:${params.maxComments}:${JSON.stringify(params.intentCategories || [])}`; // Check cache first const cached = await this.cache.get<CommentIntentAnalysis>(cacheKey); if (cached) { this.logger.info(`Returning cached comment intent analysis for: ${params.videoId}`); return cached; } try { // Step 1: Get video details with comments const videoDetails = await this.youtubeClient.getVideoDetails({ videoId: params.videoId, includeTranscript: false, includeComments: true, maxComments: params.maxComments }); if (!videoDetails.comments || videoDetails.comments.length === 0) { throw new Error(`No comments found for video ${params.videoId}`); } // Step 2: Analyze comments in batches using LLM const intents = await this.analyzeCommentsInBatches( videoDetails.comments, params.intentCategories ); // Step 3: Generate summary and trends const analysis = await this.generateAnalysisSummary( params.videoId, intents, videoDetails.comments ); // Cache the result await this.cache.set(cacheKey, analysis, 3600); // 1 hour cache this.logger.info(`Comment intent analysis completed for ${params.videoId}: ${intents.length} intents identified`); return analysis; } catch (error) { this.logger.error(`Failed to analyze comment intents for ${params.videoId}:`, error); throw error; } }
  • Zod schema definition for input validation of analyze_comment_intents tool parameters.
    export const AnalyzeCommentIntentsSchema = z.object({ videoId: z.string().describe('YouTube video ID'), maxComments: z.number().min(10).max(500).default(100).describe('Maximum comments to analyze'), intentCategories: z.array(z.string()).optional().describe('Custom intent categories to detect'), includeReplies: z.boolean().default(false).describe('Whether to include comment replies'), });
  • src/index.ts:414-441 (registration)
    Tool registration in listTools handler, defining name, description, and input schema.
    { name: 'analyze_comment_intents', description: 'Analyze YouTube comments to extract user intents and actionable insights', inputSchema: { type: 'object', properties: { videoId: { type: 'string', description: 'YouTube video ID to analyze comments from' }, maxComments: { type: 'number', minimum: 10, maximum: 200, default: 100, description: 'Maximum number of comments to analyze' }, intentCategories: { type: 'array', items: { type: 'string' }, description: 'Custom intent categories to focus on (optional)' } }, required: ['videoId'] } },
  • src/index.ts:584-586 (registration)
    Dispatch in CallToolRequestSchema handler that routes to CommentIntentAnalyzer.execute()
    case 'analyze_comment_intents': result = await this.commentIntentTool.execute(args); break;
  • src/index.ts:179-179 (registration)
    Instantiation of CommentIntentAnalyzer class used as the tool handler instance.
    this.commentIntentTool = new CommentIntentAnalyzer(this.youtubeClient, this.cache, this.llmService, 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