Skip to main content
Glama
easyhak

YouTube Search & Download MCP Server

by easyhak

download_video

Download YouTube videos with configurable quality settings and output formats. Specify video ID, choose quality preset, and select format for saving media files.

Instructions

Download a YouTube video with configurable quality.

Args: video_id: YouTube video ID (11 characters) quality: Quality preset - "best", "high" (1080p), "medium" (720p), "low" (480p) output_dir: Download directory path (uses config default if not specified) format: Output format - "mp4", "webm", "mkv" (default: "mp4")

Returns: JSON with download status, file path, file size, and metadata

Example: download_video("dQw4w9WgXcQ", quality="high", format="mp4")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
video_idYes
qualityNobest
output_dirNo
formatNomp4

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The tool handler that receives the MCP tool request, validates input, and orchestrates the download.
    async def download_video(
        video_id: str,
        quality: str = "best",
        output_dir: str | None = None,
        format: str = "mp4",
    ) -> str:
        """
        Download a YouTube video with configurable quality.
    
        Args:
            video_id: YouTube video ID (11 characters)
            quality: Quality preset - "best", "high" (1080p), "medium" (720p), "low" (480p)
            output_dir: Download directory path (uses config default if not specified)
            format: Output format - "mp4", "webm", "mkv" (default: "mp4")
    
        Returns:
            JSON with download status, file path, file size, and metadata
    
        Example:
            download_video("dQw4w9WgXcQ", quality="high", format="mp4")
        """
        try:
            logger.info(
                f"Download video request: video_id='{video_id}', quality='{quality}', format='{format}'"
            )
    
            # Validate video ID
            if not validate_video_id(video_id):
                raise InvalidQueryError(f"Invalid video ID format: {video_id}")
    
            # Create download parameters
            params = DownloadParams(
                video_id=video_id,
                quality=quality,
                output_dir=output_dir,
                format=format,
                download_type="video",
            )
    
            # Execute download
            downloader = get_downloader()
            result = await downloader.download_video(params)
    
            logger.info(f"Video download completed: {result.file_path}")
            return json.dumps(result.model_dump(), indent=2)
  • The actual implementation of the video download logic using yt-dlp.
    async def download_video(self, params: DownloadParams) -> DownloadResult:
        """
        Download a video with specified quality and format.
    
        Args:
            params: Download parameters
    
        Returns:
            Download result with file path and metadata
    
        Raises:
            VideoNotFoundError: If video doesn't exist
            DownloadError: If download operation fails
            DiskSpaceError: If insufficient disk space
            PermissionError: If cannot write to output directory
        """
        logger.info(
            f"Starting video download: {params.video_id} "
            f"(quality={params.quality}, format={params.format})"
        )
        return await self._download(params, is_video=True)
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses that the tool downloads a video with configurable quality and format, and returns JSON with status and metadata, which covers basic behavior. However, it lacks details on potential side effects (e.g., file system changes, network usage), error handling, or rate limits, leaving gaps in behavioral transparency.

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 front-loaded with the core purpose, followed by organized sections for Args, Returns, and an Example. Every sentence adds value, with no wasted words, and the example illustrates usage efficiently, making it highly concise and easy to parse.

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 complexity (4 parameters, no annotations, but has output schema), the description is mostly complete: it covers purpose, parameters, returns, and includes an example. However, it lacks behavioral details like side effects or error handling, and while the output schema exists, the description could benefit from more context on what 'download status' entails. It's adequate but has minor 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 detailing all 4 parameters: video_id (YouTube ID, 11 characters), quality (presets with resolutions), output_dir (path with default behavior), and format (options with default). It adds meaning beyond the bare schema, including examples and defaults, making parameter semantics clear and comprehensive.

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 tool's purpose with a specific verb ('Download') and resource ('YouTube video'), and distinguishes it from siblings like download_audio (audio vs. video) and get_video_info (info retrieval vs. download). It specifies configurable quality, making the purpose explicit and differentiated.

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 implies usage context through parameter details (e.g., quality presets, output directory), but does not explicitly state when to use this tool versus alternatives like download_audio or get_video_info. It provides clear guidance on parameter usage but lacks explicit sibling differentiation in usage scenarios.

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