Skip to main content
Glama
easyhak

YouTube Search & Download MCP Server

by easyhak

search_videos

Search YouTube videos by query to find relevant content, retrieve metadata, and support downloading without an API key.

Instructions

Search YouTube for videos matching a query.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
max_resultsNo
output_formatNojson

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The 'search_videos' function is defined as an MCP tool, handling the search request by validating input, using a provider to perform the search, and formatting the output.
    @mcp.tool(name="search_videos")
    async def search_videos(query: str, max_results: int = 10, output_format: str = "json") -> str:
        """Search YouTube for videos matching a query."""
        try:
            logger.info(f"Search request: query='{query}', max_results={max_results}")
    
            # Validate query
            validated_query = validate_query(query)
    
            # Create search parameters
            params = SearchParams(
                query=validated_query,
                max_results=max_results,
            )
    
            # Execute search
            provider = get_search_provider()
            videos = await provider.search(params)
    
            # Format results
            formatter = get_formatter(output_format)
            result = formatter.format_videos(videos)
    
            logger.info(f"Search completed: found {len(videos)} videos")
            return result
    
        except InvalidQueryError as e:
            logger.warning(f"Invalid query: {e.message}")
            return json.dumps({"error": "invalid_query", "message": e.message})
        except NetworkError as e:
            logger.error(f"Network error: {e.message}")
            return json.dumps(
                {
                    "error": "network_error",
                    "message": "Failed to connect to YouTube. Please try again.",
                    "details": e.message,
                }
            )
        except SearchProviderError as e:
            logger.error(f"Search provider error: {e.message}", exc_info=True)
            return json.dumps(
                {
                    "error": "search_failed",
                    "message": "Search operation failed. Please try a different query.",
                    "details": e.message,
                }
            )
        except Exception:
            logger.exception("Unexpected error in search_videos")
            return json.dumps(
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the basic action but doesn't mention important traits like whether this requires authentication, rate limits, what kind of results are returned (e.g., video metadata, URLs), or any constraints on the search. This leaves significant gaps for an agent to understand how to use it effectively.

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 extremely concise - a single sentence that directly states the tool's purpose with zero wasted words. It's front-loaded and gets straight to the point without unnecessary elaboration.

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 moderate complexity (3 parameters, no annotations) but the presence of an output schema, the description is minimally adequate. The output schema helps compensate for missing return value details, but the description lacks crucial behavioral context and parameter guidance that would make it truly complete for effective use.

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?

With 0% schema description coverage, the description provides no parameter information beyond what's implied by the tool name ('query'). It doesn't explain the 'max_results' parameter for limiting results or 'output_format' for controlling response format. However, since there's an output schema, some parameter context might be inferred from expected returns, keeping it at baseline.

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 ('Search YouTube for videos') and the resource ('videos matching a query'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'search_playlists' or 'get_video_info', which would require specifying it's for video search specifically rather than other YouTube content types.

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 sibling tools like 'search_playlists' for playlist searches or 'get_video_info' for retrieving details about specific videos, leaving the agent to guess based on tool names alone.

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

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