Skip to main content
Glama
easyhak

YouTube Search & Download MCP Server

by easyhak

get_video_info

Retrieve detailed metadata for YouTube videos including description, tags, and statistics by providing the video ID. Supports JSON or Markdown output formats.

Instructions

Get detailed information about a specific YouTube video.

Args: video_id: YouTube video ID (11 characters, e.g., "dQw4w9WgXcQ") output_format: Output format - "json" or "markdown" (default: "json")

Returns: Detailed video information including description, tags, and statistics

Example: get_video_info("dQw4w9WgXcQ", output_format="markdown")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
video_idYes
output_formatNojson

Implementation Reference

  • The implementation of the 'get_video_info' MCP tool, which validates the video ID, fetches details from the search provider, and formats the response.
    @mcp.tool()
    async def get_video_info(video_id: str, output_format: str = "json") -> str:
        """
        Get detailed information about a specific YouTube video.
    
        Args:
            video_id: YouTube video ID (11 characters, e.g., "dQw4w9WgXcQ")
            output_format: Output format - "json" or "markdown" (default: "json")
    
        Returns:
            Detailed video information including description, tags, and statistics
    
        Example:
            get_video_info("dQw4w9WgXcQ", output_format="markdown")
        """
        try:
            logger.info(f"Get video info request: video_id='{video_id}'")
    
            # Validate video ID
            if not validate_video_id(video_id):
                raise InvalidQueryError(f"Invalid video ID format: {video_id}")
    
            # Get video details
            provider = get_search_provider()
            details = await provider.get_video_details(video_id)
    
            # Format results
            formatter = get_formatter(output_format)
            result = formatter.format_video_details(details)
    
            logger.info(f"Retrieved info for: {details.title}")
            return result
    
        except InvalidQueryError as e:
            logger.warning(f"Invalid video ID: {e.message}")
            return json.dumps({"error": "invalid_video_id", "message": e.message})
        except VideoNotFoundError as e:
            logger.warning(f"Video not found: {e.message}")
            return json.dumps(
                {"error": "video_not_found", "message": "Video not found or unavailable."}
            )
        except NetworkError as e:
            logger.error(f"Network error: {e.message}")
            return json.dumps(
                {
                    "error": "network_error",
                    "message": "Failed to connect to YouTube.",
                    "details": e.message,
                }
            )
        except Exception:
            logger.exception("Unexpected error in get_video_info")
            return json.dumps(
                {"error": "internal_error", "message": "An unexpected error occurred."}
            )

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