Skip to main content
Glama

search-videos

Search YouTube videos with advanced filters like channel, duration, publish date, quality, and more. Customize results by relevancy, view count, or date. Retrieve up to 50 videos per search.

Instructions

Search for YouTube videos with advanced filtering options. Supports parameters: - query: Search term (required) - maxResults: Number of results to return (1-50) - channelId: Filter by specific channel - order: Sort by date, rating, viewCount, relevance, title - type: Filter by resource type (video, channel, playlist) - videoDuration: Filter by length (short: <4min, medium: 4-20min, long: >20min) - publishedAfter/publishedBefore: Filter by publish date (ISO format) - videoCaption: Filter by caption availability - videoDefinition: Filter by quality (standard/high) - regionCode: Filter by country (ISO country code)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelIdNo
maxResultsNo
orderNo
publishedAfterNo
publishedBeforeNo
queryYes
regionCodeNo
typeNo
videoCaptionNo
videoDefinitionNo
videoDurationNo

Implementation Reference

  • src/index.ts:207-263 (registration)
    Full registration of the 'search-videos' MCP tool, including name, description, input schema with Zod validation, and inline handler function that delegates to YouTubeService.searchVideos
      server.tool(
        'search-videos',
        'Search for YouTube videos with advanced filtering options. Supports parameters: \
    - query: Search term (required) \
    - maxResults: Number of results to return (1-50) \
    - channelId: Filter by specific channel \
    - order: Sort by date, rating, viewCount, relevance, title \
    - type: Filter by resource type (video, channel, playlist) \
    - videoDuration: Filter by length (short: <4min, medium: 4-20min, long: >20min) \
    - publishedAfter/publishedBefore: Filter by publish date (ISO format) \
    - videoCaption: Filter by caption availability \
    - videoDefinition: Filter by quality (standard/high) \
    - regionCode: Filter by country (ISO country code)',
        {
          query: z.string().min(1),
          maxResults: z.number().min(1).max(50).optional(),
          channelId: z.string().optional(),
          order: z.enum(['date', 'rating', 'relevance', 'title', 'videoCount', 'viewCount']).optional(),
          type: z.enum(['video', 'channel', 'playlist']).optional(),
          videoDuration: z.enum(['any', 'short', 'medium', 'long']).optional(),
          publishedAfter: z.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/).optional(),
          publishedBefore: z.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/).optional(),
          videoCaption: z.enum(['any', 'closedCaption', 'none']).optional(),
          videoDefinition: z.enum(['any', 'high', 'standard']).optional(),
          regionCode: z.string().length(2).optional()
        },
        async ({ query, maxResults = 10, channelId, order, type, videoDuration, publishedAfter, publishedBefore, videoCaption, videoDefinition, regionCode }) => {
          try {
            const searchResults = await youtubeService.searchVideos(query, maxResults, {
              channelId,
              order,
              type,
              videoDuration,
              publishedAfter,
              publishedBefore,
              videoCaption,
              videoDefinition,
              regionCode
            });
    
            return {
              content: [{
                type: 'text',
                text: JSON.stringify(searchResults, null, 2)
              }]
            };
          } catch (error) {
            return {
              content: [{
                type: 'text',
                text: `Error searching videos: ${error}`
              }],
              isError: true
            };
          }
        }
      );
  • Core handler implementation in YouTubeService class that performs the actual YouTube API search.list call with all supported filters and options for video search.
    async searchVideos(
      query: string,
      maxResults: number = 10,
      options: {
        channelId?: string;
        order?: string;
        type?: string;
        videoDuration?: string;
        publishedAfter?: string;
        publishedBefore?: string;
        videoCaption?: string;
        videoDefinition?: string;
        regionCode?: string;
      } = {}
    ): Promise<youtube_v3.Schema$SearchListResponse> {
      try {
        const response = await this.youtube.search.list({
          part: ['snippet'],
          q: query,
          maxResults,
          type: options.type ? [options.type] : ['video'],
          channelId: options.channelId,
          order: options.order,
          videoDuration: options.videoDuration,
          publishedAfter: options.publishedAfter,
          publishedBefore: options.publishedBefore,
          videoCaption: options.videoCaption,
          videoDefinition: options.videoDefinition,
          regionCode: options.regionCode
        });
        return response.data;
      } catch (error) {
        console.error('Error searching videos:', error);
        throw error;
      }
    }
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 'advanced filtering options' and lists parameters, but fails to describe key behaviors: it doesn't specify if this is a read-only operation, mention rate limits, authentication needs, pagination, or the format of returned results. For a search tool with 11 parameters and no output schema, 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.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, starting with the core purpose. It efficiently lists parameters in a bullet-like format without unnecessary elaboration. However, it could be slightly more structured (e.g., grouping related parameters) and includes some redundancy (e.g., repeating 'Filter by' for multiple parameters), preventing a perfect score.

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

Completeness3/5

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

Given the tool's complexity (11 parameters, no annotations, no output schema), the description is partially complete. It excels in parameter semantics but lacks behavioral context (e.g., result format, error handling) and usage guidelines. Without an output schema, the description should ideally hint at return values, but it doesn't, leaving gaps in overall completeness.

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

Parameters5/5

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

The description adds substantial meaning beyond the input schema, which has 0% schema description coverage. It explains each parameter's purpose (e.g., 'query: Search term (required)', 'videoDuration: Filter by length (short: <4min, medium: 4-20min, long: >20min)'), including details like required status, value ranges, and formats (ISO format for dates). This fully compensates for the schema's lack of descriptions.

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: 'Search for YouTube videos with advanced filtering options.' It specifies the verb ('search') and resource ('YouTube videos'), and the 'advanced filtering options' distinguishes it from basic search tools. However, it doesn't explicitly differentiate from sibling tools like 'get-trending-videos' or 'analyze-channel-videos', which prevents 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 lists parameters but doesn't indicate scenarios where this search is preferred over sibling tools (e.g., 'get-trending-videos' for trending content or 'analyze-channel-videos' for channel-specific analysis). This lack of comparative context leaves the agent without usage direction.

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