Skip to main content
Glama
efikuta

YouTube Knowledge MCP

by efikuta

analyze_comment_intents

Extract user intents and actionable insights from YouTube comments to understand audience engagement and feedback patterns.

Instructions

Analyze YouTube comments to extract user intents and actionable insights

Input Schema

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

Implementation Reference

  • Entry point execute method of CommentIntentAnalyzer class that handles tool execution: parses args, checks cache, fetches comments, analyzes intents in batches using LLM, generates summary, caches result
    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 defining input parameters for the analyze_comment_intents tool
    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:415-441 (registration)
    Tool registration in listTools handler: 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 case in CallToolRequestSchema handler that routes to commentIntentTool.execute
    case 'analyze_comment_intents':
      result = await this.commentIntentTool.execute(args);
      break;
  • src/index.ts:179-179 (registration)
    Instantiation of CommentIntentAnalyzer class for use as the tool handler
    this.commentIntentTool = new CommentIntentAnalyzer(this.youtubeClient, this.cache, this.llmService, this.logger);
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 'analyze' and 'extract' but does not specify whether this is a read-only operation, requires authentication, has rate limits, or details the output format (e.g., structured insights vs. raw data). For a tool with no annotations, this lack of behavioral context is a significant gap.

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 directly states the tool's purpose without unnecessary words. It is front-loaded with the core action and outcome, making it easy to parse and understand quickly, which is ideal for conciseness.

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 complexity of analyzing comments for intents and insights, the description is incomplete. No annotations are provided to clarify behavioral traits, and there is no output schema to explain return values. The description alone does not compensate for these gaps, making it inadequate for a tool that likely produces structured insights from unstructured data.

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 the parameters (videoId, maxComments, intentCategories). The description adds no additional semantic meaning beyond what the schema provides (e.g., it does not explain what 'intentCategories' might include or how analysis is performed), resulting in a baseline score of 3 as the schema does the heavy lifting.

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 action ('analyze YouTube comments') and the outcome ('extract user intents and actionable insights'), which is specific and informative. However, it does not explicitly differentiate this tool from sibling tools like 'analyze_video_content' or 'simplify_video_transcript', which might also involve comment or content analysis, leaving some ambiguity about its unique role.

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 does not mention scenarios where it is preferred over sibling tools (e.g., 'analyze_video_content' for broader analysis or 'simplify_video_transcript' for transcript processing), nor does it specify prerequisites or exclusions, leaving the agent to infer usage context.

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