Skip to main content
Glama

analyze-channel-videos

Evaluate recent videos from a YouTube channel to uncover performance trends by analyzing metrics like views, ratings, and upload dates. Specify channel ID and sorting preferences for targeted insights.

Instructions

Analyze recent videos from a specific channel to identify performance trends

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelIdYes
maxResultsNo
sortByNo

Implementation Reference

  • The handler function that executes the tool's logic. It searches for recent videos in the specified channel, retrieves detailed statistics for each video, computes average performance metrics (views, likes, comments), and returns a JSON summary.
    async ({ channelId, maxResults = 10, sortBy = 'date' }) => {
      try {
        // First get all videos from the channel
        const searchResponse = await youtubeService.youtube.search.list({
          part: ['snippet'],
          channelId,
          maxResults,
          order: sortBy,
          type: ['video']
        });
    
        // Extract videoIds and filter out any null or undefined values
        const videoIds: string[] = searchResponse.data.items
          ?.map(item => item.id?.videoId)
          .filter((id): id is string => id !== null && id !== undefined) || [];
    
        if (videoIds.length === 0) {
          return {
            content: [{
              type: 'text',
              text: `No videos found for channel ${channelId}`
            }]
          };
        }
    
        // Then get detailed stats for each video
        const videosResponse = await youtubeService.youtube.videos.list({
          part: ['snippet', 'statistics', 'contentDetails'],
          id: videoIds
        });
    
        interface VideoAnalysisItem {
          videoId: string;
          title: string | null | undefined;
          publishedAt: string | null | undefined;
          duration: string | null | undefined;
          viewCount: number;
          likeCount: number;
          commentCount: number;
        }
    
        const videoAnalysis: VideoAnalysisItem[] = videosResponse.data.items?.map(video => ({
          videoId: video.id || '',
          title: video.snippet?.title,
          publishedAt: video.snippet?.publishedAt,
          duration: video.contentDetails?.duration,
          viewCount: Number(video.statistics?.viewCount || 0),
          likeCount: Number(video.statistics?.likeCount || 0),
          commentCount: Number(video.statistics?.commentCount || 0)
        })) || [];
    
        // Calculate averages
        if (videoAnalysis.length > 0) {
          const avgViews = videoAnalysis.reduce((sum: number, video: VideoAnalysisItem) => sum + video.viewCount, 0) / videoAnalysis.length;
          const avgLikes = videoAnalysis.reduce((sum: number, video: VideoAnalysisItem) => sum + video.likeCount, 0) / videoAnalysis.length;
          const avgComments = videoAnalysis.reduce((sum: number, video: VideoAnalysisItem) => sum + video.commentCount, 0) / videoAnalysis.length;
    
          const result = {
            channelId,
            videoCount: videoAnalysis.length,
            averages: {
              viewCount: avgViews,
              likeCount: avgLikes,
              commentCount: avgComments
            },
            videos: videoAnalysis
          };
    
          return {
            content: [{
              type: 'text',
              text: JSON.stringify(result, null, 2)
            }]
          };
        }
    
        return {
          content: [{
            type: 'text',
            text: `No video data available for analysis`
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: `Error analyzing channel videos: ${error}`
          }],
          isError: true
        };
      }
    }
  • Zod schema defining the input parameters for the tool: channelId (required string), maxResults (optional number 1-50), sortBy (optional enum: 'date', 'viewCount', 'rating').
    {
      channelId: z.string().min(1),
      maxResults: z.number().min(1).max(50).optional(),
      sortBy: z.enum(['date', 'viewCount', 'rating']).optional()
    },
  • src/index.ts:561-563 (registration)
    The server.tool call that registers the 'analyze-channel-videos' tool with its name and description.
    server.tool(
      'analyze-channel-videos',
      'Analyze recent videos from a specific channel to identify performance trends',
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 analyzing 'recent videos' and 'performance trends,' but fails to specify what 'recent' means (e.g., time frame), what 'analyze' entails (e.g., statistical methods, output format), or any limitations like rate limits or authentication needs. For a tool with no annotations, this is a significant gap in transparency.

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, well-structured sentence that efficiently conveys the core action and goal without unnecessary words. It's front-loaded with the main purpose ('analyze recent videos'), making it easy to parse quickly, and every part of the sentence contributes directly to understanding the tool's 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 complexity of analyzing videos for trends, no annotations, no output schema, and low schema description coverage, the description is incomplete. It doesn't explain what 'performance trends' include (e.g., views, engagement), how results are returned, or any behavioral constraints. For a tool that likely involves data processing and output, more context is needed to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate for undocumented parameters. It implies the use of 'channelId' and hints at 'recent videos' (which could relate to 'maxResults' or 'sortBy'), but doesn't explain what 'maxResults' controls (e.g., number of videos analyzed) or how 'sortBy' affects the analysis. With 3 parameters and no schema descriptions, the description adds minimal semantic value beyond basic inference.

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 with a specific verb ('analyze') and resource ('recent videos from a specific channel'), and it specifies the outcome ('identify performance trends'). However, it doesn't explicitly differentiate this from sibling tools like 'get-channel-stats' or 'get-video-stats', which might also provide performance insights, so it falls short of a perfect score.

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 prerequisites, such as needing a valid channel ID, or compare it to siblings like 'get-channel-stats' for broader channel analysis or 'search-videos' for different video retrieval methods. This lack of context leaves the agent to infer usage scenarios.

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

Related 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/coyaSONG/youtube-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server