Skip to main content
Glama

getVideoCategories

Read-onlyIdempotent

Retrieve YouTube video categories for any region. Get category IDs and titles to filter trending videos by category.

Instructions

Retrieves available video categories for a specific region. Returns a list of YouTube video categories with their IDs and titles that can be used for filtering trending videos or other category-specific operations. Different regions may have different available categories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
regionCodeNoTwo-letter country code (e.g., 'US', 'GB', 'JP'). Defaults to 'US'US

Implementation Reference

  • The executeImpl method that implements the tool's logic: it calls youtubeService.getVideoCategories(regionCode) and formats the result.
    protected async executeImpl(
      params: z.infer<typeof getVideoCategoriesSchema>
    ): Promise<CallToolResult> {
      const { regionCode } = params;
    
      const categories =
        await this.container.youtubeService.getVideoCategories(regionCode);
      return formatSuccess(categories);
    }
  • Zod schema defining the input: an optional regionCode (2-letter country code, defaults to 'US').
    export const getVideoCategoriesSchema = z.object({
      regionCode: regionCodeSchema
        .default("US")
        .describe(
          "Two-letter country code (e.g., 'US', 'GB', 'JP'). Defaults to 'US'"
        ),
    });
  • Import of GetVideoCategoriesTool and its inclusion in the TOOL_CLASSES array for registration with the MCP server.
    import { GetVideoCategoriesTool } from "./general/getVideoCategories.js";
    import { FindConsistentOutlierChannelsTool } from "./general/findConsistentOutlierChannels.js";
    
    interface ITool {
      readonly name: string;
      readonly description: string;
      readonly schema: z.ZodObject<z.ZodRawShape>;
      execute(args: z.infer<this["schema"]>): Promise<CallToolResult>;
    }
    
    type ToolConstructor = new (container: IServiceContainer) => ITool;
    
    // 1. Maintain a list of Constructors
    const TOOL_CLASSES = [
      GetVideoDetailsTool,
      SearchVideosTool,
      GetTranscriptsTool,
      GetVideoCommentsTool,
      GetChannelStatisticsTool,
      GetChannelTopVideosTool,
      GetTrendingVideosTool,
      GetVideoCategoriesTool,
    ];
  • The youtubeService.getVideoCategories method that makes the actual YouTube API call (videoCategories.list) and caches results with a static (1 year) TTL.
    async getVideoCategories(regionCode: string = "US") {
      const cacheKey = this.cacheService.createOperationKey(
        "getVideoCategories",
        {
          regionCode,
        }
      );
    
      const operation = async () => {
        try {
          const response = await this.trackCost(
            () =>
              this.youtube.videoCategories.list({
                part: ["snippet"],
                regionCode: regionCode,
              }),
            API_COSTS["videoCategories.list"]
          );
    
          const categories = response.data.items?.map((category) => ({
            id: category.id,
            title: category.snippet?.title,
          }));
    
          return categories || [];
        } catch (error) {
          if (error instanceof AppError) throw error;
          throw new YouTubeApiError(
            `YouTube API call for getVideoCategories failed for regionCode: ${regionCode}`,
            error
          );
        }
      };
    
      return this.cacheService.getOrSet(
        cacheKey,
        operation,
        CACHE_TTLS.STATIC,
        CACHE_COLLECTIONS.VIDEO_CATEGORIES,
        { regionCode }
      );
    }
  • Cache TTL config: STATIC = ONE_YEAR, used for video categories since they rarely change.
    // For truly static data that rarely or never changes, like video categories.
    STATIC: ONE_YEAR,
Behavior4/5

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

Annotations already declare the tool as read-only and idempotent. The description adds useful behavioral context: it returns categories with IDs and titles, and that categories vary by region. No contradictions.

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?

Two short sentences that first state the action, then elaborate on return and usage. Every sentence adds value with no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple list retrieval tool with no output schema, the description adequately explains what is returned (IDs and titles) and the region-dependency. No significant gaps given the tool's simplicity.

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?

The single parameter regionCode is fully described in the input schema (coverage 100%). The tool description does not add additional meaning beyond what the schema already provides, so baseline of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it retrieves video categories for a specific region, and mentions the return includes IDs and titles. This distinguishes it from sibling tools like getTrendingVideos or searchVideos, which are for different purposes.

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

Usage Guidelines4/5

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

The description provides clear context for when to use the tool (e.g., for filtering trending videos or category-specific operations), and notes region dependency. However, it does not explicitly mention when not to use it or name alternatives.

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/kirbah/mcp-youtube'

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