"""Tool definitions for yt-fetch MCP server."""
from mcp.types import Tool
def create_tools() -> list[Tool]:
"""Create and return all available tools."""
return [
Tool(
name="search_videos",
description="Search YouTube for videos with various filters and sorting options",
inputSchema={
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "Search query for YouTube videos",
},
"max_results": {
"type": "integer",
"description": "Maximum number of results to return (1-50)",
"minimum": 1,
"maximum": 50,
"default": 10,
},
"order": {
"type": "string",
"enum": ["relevance", "date", "rating", "viewCount", "title"],
"description": "Order to sort results by",
"default": "relevance",
},
"published_after": {
"type": "string",
"description": "Return videos published after this date (RFC 3339 format)",
},
"published_before": {
"type": "string",
"description": "Return videos published before this date (RFC 3339 format)",
},
"duration": {
"type": "string",
"enum": ["short", "medium", "long"],
"description": "Filter by video duration (short: <4min, medium: 4-20min, long: >20min)",
},
"video_type": {
"type": "string",
"enum": ["any", "episode", "movie"],
"description": "Type of video to search for",
},
"region_code": {
"type": "string",
"description": "ISO 3166-1 alpha-2 country code for region-specific results",
},
},
"required": ["query"],
},
),
Tool(
name="get_video_details",
description="Get detailed information about a specific YouTube video",
inputSchema={
"type": "object",
"properties": {
"video_id": {"type": "string", "description": "YouTube video ID"}
},
"required": ["video_id"],
},
),
Tool(
name="get_channel_info",
description="Get information about a YouTube channel",
inputSchema={
"type": "object",
"properties": {
"channel_id": {
"type": "string",
"description": "YouTube channel ID",
}
},
"required": ["channel_id"],
},
),
Tool(
name="filter_videos",
description="Apply custom filters to a list of videos",
inputSchema={
"type": "object",
"properties": {
"videos": {
"type": "array",
"description": "List of VideoInfo objects to filter",
"items": {"type": "object"},
},
"min_views": {
"type": "integer",
"description": "Minimum view count",
"minimum": 0,
},
"max_views": {
"type": "integer",
"description": "Maximum view count",
"minimum": 0,
},
"min_duration": {
"type": "string",
"description": "Minimum duration in ISO 8601 format (e.g., PT5M for 5 minutes)",
},
"max_duration": {
"type": "string",
"description": "Maximum duration in ISO 8601 format (e.g., PT30M for 30 minutes)",
},
"keywords": {
"type": "array",
"items": {"type": "string"},
"description": "Keywords that must be present in title or description",
},
"exclude_keywords": {
"type": "array",
"items": {"type": "string"},
"description": "Keywords that must NOT be present in title or description",
},
},
"required": ["videos"],
},
),
Tool(
name="get_transcripts",
description="Extract transcripts from selected videos for detailed analysis",
inputSchema={
"type": "object",
"properties": {
"video_ids": {
"type": "array",
"items": {"type": "string"},
"description": "List of YouTube video IDs to analyze",
},
"analysis_type": {
"type": "string",
"enum": ["summary", "detailed", "highlights", "transcript"],
"description": "Type of analysis to perform",
"default": "summary",
},
},
"required": ["video_ids"],
},
),
Tool(
name="trending_analysis",
description="Get and analyze trending videos in specific categories",
inputSchema={
"type": "object",
"properties": {
"category_id": {
"type": "string",
"description": "YouTube category ID (e.g., '28' for Science & Technology)",
},
"region_code": {
"type": "string",
"description": "ISO 3166-1 alpha-2 country code",
"default": "US",
},
"max_results": {
"type": "integer",
"description": "Maximum number of trending videos to return",
"minimum": 1,
"maximum": 50,
"default": 25,
},
},
},
),
]