Skip to main content
Glama

get-trending-videos

Retrieve trending YouTube videos by region and category to analyze popular content trends. Supports up to 50 results for detailed insights into audience preferences.

Instructions

Retrieve trending videos by region and category. This helps analyze current popular content trends.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryIdNo
maxResultsNo
regionCodeNo

Implementation Reference

  • The handler function that implements the core logic of the 'get-trending-videos' tool. It uses the YouTube Data API v3 to fetch trending videos by calling videos.list with chart='mostPopular', processes the response to extract relevant fields, and returns formatted JSON data.
    async ({ regionCode = 'US', categoryId, maxResults = 10 }) => {
      try {
        const response = await youtubeService.youtube.videos.list({
          part: ['snippet', 'contentDetails', 'statistics'],
          chart: 'mostPopular',
          regionCode,
          videoCategoryId: categoryId,
          maxResults
        });
    
        const trendingVideos = response.data.items?.map(video => ({
          videoId: video.id,
          title: video.snippet?.title,
          channelTitle: video.snippet?.channelTitle,
          publishedAt: video.snippet?.publishedAt,
          viewCount: video.statistics?.viewCount,
          likeCount: video.statistics?.likeCount,
          commentCount: video.statistics?.commentCount
        }));
    
        return {
          content: [{
            type: 'text',
            text: JSON.stringify(trendingVideos, null, 2)
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: `Error fetching trending videos: ${error}`
          }],
          isError: true
        };
      }
  • src/index.ts:479-523 (registration)
    The registration of the 'get-trending-videos' tool in the MCP server using server.tool(). Includes the tool name, description, Zod input schema for parameters (regionCode, categoryId, maxResults), and the handler function.
    server.tool(
      'get-trending-videos',
      'Retrieve trending videos by region and category. This helps analyze current popular content trends.',
      {
        regionCode: z.string().length(2).optional(),
        categoryId: z.string().optional(),
        maxResults: z.number().min(1).max(50).optional()
      },
      async ({ regionCode = 'US', categoryId, maxResults = 10 }) => {
        try {
          const response = await youtubeService.youtube.videos.list({
            part: ['snippet', 'contentDetails', 'statistics'],
            chart: 'mostPopular',
            regionCode,
            videoCategoryId: categoryId,
            maxResults
          });
    
          const trendingVideos = response.data.items?.map(video => ({
            videoId: video.id,
            title: video.snippet?.title,
            channelTitle: video.snippet?.channelTitle,
            publishedAt: video.snippet?.publishedAt,
            viewCount: video.statistics?.viewCount,
            likeCount: video.statistics?.likeCount,
            commentCount: video.statistics?.commentCount
          }));
    
          return {
            content: [{
              type: 'text',
              text: JSON.stringify(trendingVideos, null, 2)
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: 'text',
              text: `Error fetching trending videos: ${error}`
            }],
            isError: true
          };
        }
      }
    );
  • The Zod schema defining the input parameters for the 'get-trending-videos' tool: optional regionCode (2-letter ISO), categoryId, and maxResults (1-50).
    {
      regionCode: z.string().length(2).optional(),
      categoryId: z.string().optional(),
      maxResults: z.number().min(1).max(50).optional()
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the tool 'helps analyze current popular content trends,' which implies a read-only operation for trend analysis, but lacks details on rate limits, authentication needs, pagination, or what 'trending' entails (e.g., algorithm, time frame). This is a significant gap for a tool with no annotation coverage.

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 appropriately sized and front-loaded, with two concise sentences that directly state the tool's function and its analytical purpose. There is no wasted text, and every sentence adds value, making it efficient and easy to parse.

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 (3 parameters, no output schema, no annotations), the description is incomplete. It lacks details on behavioral traits, parameter usage, and return values, which are crucial for a tool with no structured data support. This makes it inadequate for full understanding by an AI agent.

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?

The schema description coverage is 0%, so the description must compensate for undocumented parameters. It mentions 'by region and category,' which hints at 'regionCode' and 'categoryId,' but doesn't explain the third parameter 'maxResults' or provide any details on format, constraints, or usage. This leaves key parameters inadequately explained.

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 ('Retrieve') and resource ('trending videos'), and specifies the filtering criteria ('by region and category'). It distinguishes from siblings like 'search-videos' by focusing on trending content rather than general search, though it doesn't explicitly contrast them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for 'analyze current popular content trends,' suggesting it's for trend analysis rather than other purposes. However, it doesn't explicitly state when to use this tool versus alternatives like 'search-videos' or 'get-video-stats,' nor does it provide exclusions or prerequisites, leaving some ambiguity.

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