ddg-video-search
Search for videos using DuckDuckGo with options to filter by region, safe search, time limit, resolution, duration, license type, and result count.
Instructions
Search for videos using DuckDuckGo
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keywords | Yes | Search query keywords | |
| region | No | Region code (e.g., wt-wt, us-en, uk-en) | wt-wt |
| safesearch | No | Safe search level | moderate |
| timelimit | No | Time limit (d=day, w=week, m=month) | |
| resolution | No | Video resolution | |
| duration | No | Video duration | |
| license_videos | No | Video license type | |
| max_results | No | Maximum number of results to return |
Implementation Reference
- src/ddg_mcp/server.py:323-367 (handler)The handler function block within handle_call_tool that executes the ddg-video-search logic: parses arguments, performs video search using DDGS().videos(), formats results as numbered list with title, publisher, duration, URL, published date, description, and returns as TextContent.elif name == "ddg-video-search": keywords = arguments.get("keywords") if not keywords: raise ValueError("Missing keywords") region = arguments.get("region", "wt-wt") safesearch = arguments.get("safesearch", "moderate") timelimit = arguments.get("timelimit") resolution = arguments.get("resolution") duration = arguments.get("duration") license_videos = arguments.get("license_videos") max_results = arguments.get("max_results", 10) # Perform search ddgs = DDGS() results = ddgs.videos( keywords=keywords, region=region, safesearch=safesearch, timelimit=timelimit, resolution=resolution, duration=duration, license_videos=license_videos, max_results=max_results ) # Format results formatted_results = f"Video search results for '{keywords}':\n\n" for i, result in enumerate(results, 1): formatted_results += ( f"{i}. {result.get('title', 'No title')}\n" f" Publisher: {result.get('publisher', 'Unknown')}\n" f" Duration: {result.get('duration', 'Unknown')}\n" f" URL: {result.get('content', 'No URL')}\n" f" Published: {result.get('published', 'No date')}\n" f" {result.get('description', 'No description')}\n\n" ) return [ types.TextContent( type="text", text=formatted_results, ) ]
- src/ddg_mcp/server.py:143-160 (registration)Registration of the ddg-video-search tool in the list_tools() handler, including the tool name, description, and JSON schema for input validation with required 'keywords' and optional parameters like region, safesearch, etc.types.Tool( name="ddg-video-search", description="Search for videos using DuckDuckGo", inputSchema={ "type": "object", "properties": { "keywords": {"type": "string", "description": "Search query keywords"}, "region": {"type": "string", "description": "Region code (e.g., wt-wt, us-en, uk-en)", "default": "wt-wt"}, "safesearch": {"type": "string", "enum": ["on", "moderate", "off"], "description": "Safe search level", "default": "moderate"}, "timelimit": {"type": "string", "enum": ["d", "w", "m"], "description": "Time limit (d=day, w=week, m=month)"}, "resolution": {"type": "string", "enum": ["high", "standard"], "description": "Video resolution"}, "duration": {"type": "string", "enum": ["short", "medium", "long"], "description": "Video duration"}, "license_videos": {"type": "string", "enum": ["creativeCommon", "youtube"], "description": "Video license type"}, "max_results": {"type": "integer", "description": "Maximum number of results to return", "default": 10}, }, "required": ["keywords"], }, ),
- src/ddg_mcp/server.py:146-159 (schema)Input schema (JSON Schema) for the ddg-video-search tool defining properties and requirements for arguments passed to the handler.inputSchema={ "type": "object", "properties": { "keywords": {"type": "string", "description": "Search query keywords"}, "region": {"type": "string", "description": "Region code (e.g., wt-wt, us-en, uk-en)", "default": "wt-wt"}, "safesearch": {"type": "string", "enum": ["on", "moderate", "off"], "description": "Safe search level", "default": "moderate"}, "timelimit": {"type": "string", "enum": ["d", "w", "m"], "description": "Time limit (d=day, w=week, m=month)"}, "resolution": {"type": "string", "enum": ["high", "standard"], "description": "Video resolution"}, "duration": {"type": "string", "enum": ["short", "medium", "long"], "description": "Video duration"}, "license_videos": {"type": "string", "enum": ["creativeCommon", "youtube"], "description": "Video license type"}, "max_results": {"type": "integer", "description": "Maximum number of results to return", "default": 10}, }, "required": ["keywords"], },