Skip to main content
Glama
easyhak

YouTube Search & Download MCP Server

by easyhak

search_playlists

Find YouTube playlists by entering a search query, with options to set result limits and output formats for playlist metadata.

Instructions

Search YouTube for playlists matching a query.

Args: query: Search query string (e.g., "python tutorial playlist") max_results: Maximum number of results to return (1-50, default: 10) output_format: Output format - "json" or "markdown" (default: "json")

Returns: Formatted search results with playlist metadata

Example: search_playlists("machine learning course", max_results=5, output_format="json")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
max_resultsNo
output_formatNojson

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function `search_playlists` which is registered as an MCP tool. It validates the input, calls the search provider, formats the results, and handles exceptions.
    @mcp.tool()
    async def search_playlists(
        query: str, max_results: int = 10, output_format: str = "json"
    ) -> str:
        """
        Search YouTube for playlists matching a query.
    
        Args:
            query: Search query string (e.g., "python tutorial playlist")
            max_results: Maximum number of results to return (1-50, default: 10)
            output_format: Output format - "json" or "markdown" (default: "json")
    
        Returns:
            Formatted search results with playlist metadata
    
        Example:
            search_playlists("machine learning course", max_results=5, output_format="json")
        """
        try:
            logger.info(f"Playlist search request: query='{query}', max_results={max_results}")
    
            # Validate query
            validated_query = validate_query(query)
    
            # Execute search
            provider = get_search_provider()
            playlists = await provider.search_playlists(validated_query, max_results)
    
            # Format results
            formatter = get_formatter(output_format)
            result = formatter.format_playlists(playlists)
    
            logger.info(f"Playlist search completed: found {len(playlists)} playlists")
            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": "Playlist search operation failed. Please try a different query.",
                    "details": e.message,
                }
            )
        except Exception:
            logger.exception("Unexpected error in search_playlists")
            return json.dumps(
                {
                    "error": "internal_error",
                    "message": "An unexpected error occurred. Please try again later.",
                }
            )
  • The `register_playlist_tools` function that registers the tools to the FastMCP instance.
    def register_playlist_tools(mcp: FastMCP) -> None:
        """
        Register all playlist-related tools with the MCP server.
    
        Args:
            mcp: FastMCP server instance
        """
Behavior3/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 describes the core functionality (searching YouTube) and output formatting options, but doesn't mention rate limits, authentication requirements, error conditions, or whether this is a read-only operation. The description adds basic context but leaves significant behavioral aspects unspecified.

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 well-structured and efficiently organized with clear sections (description, args, returns, example). Every sentence earns its place by providing essential information without redundancy. The front-loaded purpose statement is followed by necessary details in a logical flow.

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

Completeness4/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 (search operation with 3 parameters), no annotations, and the presence of an output schema, the description is reasonably complete. It covers purpose, parameters, returns, and provides an example. However, it could be more complete by addressing authentication needs, rate limits, or error handling, especially since no annotations exist to fill these gaps.

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?

With 0% schema description coverage, the description fully compensates by providing detailed parameter information. It explains all three parameters: 'query' (search query string with example), 'max_results' (range and default), and 'output_format' (options and default). This adds substantial meaning beyond what the bare schema provides.

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 the specific action ('Search YouTube for playlists') and resource ('playlists'), distinguishing it from sibling tools like 'search_videos' (which searches for videos) and 'get_playlist_info' (which retrieves info for a specific playlist). The verb 'search' combined with the resource 'playlists' provides precise differentiation.

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 this tool (searching YouTube for playlists matching a query), but it doesn't explicitly state when NOT to use it or mention specific alternatives. It implies usage through the example and sibling tool names, but lacks explicit guidance on choosing between 'search_playlists' and 'search_videos' or other playlist-related tools.

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