Skip to main content
Glama
misanthropic-ai

DuckDuckGo MCP Server

ddg-text-search

Search the web for text-based information using DuckDuckGo's search engine with customizable filters for region, safe search, time limits, and result quantity.

Instructions

Search the web for text results using DuckDuckGo

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordsYesSearch query keywords
regionNoRegion code (e.g., wt-wt, us-en, uk-en)wt-wt
safesearchNoSafe search levelmoderate
timelimitNoTime limit (d=day, w=week, m=month, y=year)
max_resultsNoMaximum number of results to return

Implementation Reference

  • The handle_call_tool function dispatches to the specific handler for 'ddg-text-search'. It extracts parameters, performs the DuckDuckGo text search using DDGS().text(), formats the results into a numbered list with title, URL, and body, and returns as TextContent.
    @server.call_tool()
    async def handle_call_tool(
        name: str, arguments: dict | None
    ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        """
        Handle tool execution requests.
        """
        if not arguments:
            raise ValueError("Missing arguments")
    
        if name == "ddg-text-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")
            max_results = arguments.get("max_results", 10)
            
            # Perform search
            ddgs = DDGS()
            results = ddgs.text(
                keywords=keywords,
                region=region,
                safesearch=safesearch,
                timelimit=timelimit,
                max_results=max_results
            )
            
            # Format results
            formatted_results = f"Search results for '{keywords}':\n\n"
            for i, result in enumerate(results, 1):
                formatted_results += (
                    f"{i}. {result.get('title', 'No title')}\n"
                    f"   URL: {result.get('href', 'No URL')}\n"
                    f"   {result.get('body', 'No description')}\n\n"
                )
            
            return [
                types.TextContent(
                    type="text",
                    text=formatted_results,
                )
            ]
  • The input schema and registration for the 'ddg-text-search' tool in the list_tools handler, defining parameters like keywords (required), region, safesearch, timelimit, and max_results.
    types.Tool(
        name="ddg-text-search",
        description="Search the web for text results 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", "y"], "description": "Time limit (d=day, w=week, m=month, y=year)"},
                "max_results": {"type": "integer", "description": "Maximum number of results to return", "default": 10},
            },
            "required": ["keywords"],
        },
    ),
  • The handle_list_tools function registers the 'ddg-text-search' tool among others by returning a list of Tool objects.
    @server.list_tools()
    async def handle_list_tools() -> list[types.Tool]:
        """
        List available tools.
        Each tool specifies its arguments using JSON Schema validation.
        """
        return [
            types.Tool(
                name="ddg-text-search",
                description="Search the web for text results 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", "y"], "description": "Time limit (d=day, w=week, m=month, y=year)"},
                        "max_results": {"type": "integer", "description": "Maximum number of results to return", "default": 10},
                    },
                    "required": ["keywords"],
                },
            ),
            types.Tool(
                name="ddg-image-search",
                description="Search the web for images 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", "y"], "description": "Time limit (d=day, w=week, m=month, y=year)"},
                        "size": {"type": "string", "enum": ["Small", "Medium", "Large", "Wallpaper"], "description": "Image size"},
                        "color": {"type": "string", "enum": ["color", "Monochrome", "Red", "Orange", "Yellow", "Green", "Blue", "Purple", "Pink", "Brown", "Black", "Gray", "Teal", "White"], "description": "Image color"},
                        "type_image": {"type": "string", "enum": ["photo", "clipart", "gif", "transparent", "line"], "description": "Image type"},
                        "layout": {"type": "string", "enum": ["Square", "Tall", "Wide"], "description": "Image layout"},
                        "license_image": {"type": "string", "enum": ["any", "Public", "Share", "ShareCommercially", "Modify", "ModifyCommercially"], "description": "Image license type"},
                        "max_results": {"type": "integer", "description": "Maximum number of results to return", "default": 10},
                    },
                    "required": ["keywords"],
                },
            ),
            types.Tool(
                name="ddg-news-search",
                description="Search for news articles 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)"},
                        "max_results": {"type": "integer", "description": "Maximum number of results to return", "default": 10},
                    },
                    "required": ["keywords"],
                },
            ),
            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"],
                },
            ),
            types.Tool(
                name="ddg-ai-chat",
                description="Chat with DuckDuckGo AI",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "keywords": {"type": "string", "description": "Message or question to send to the AI"},
                        "model": {"type": "string", "enum": ["gpt-4o-mini", "llama-3.3-70b", "claude-3-haiku", "o3-mini", "mistral-small-3"], "description": "AI model to use", "default": "gpt-4o-mini"},
                    },
                    "required": ["keywords"],
                },
            ),
        ]
Behavior2/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 of behavioral disclosure. It states the tool performs a web search but doesn't mention any behavioral traits such as rate limits, authentication needs, response format, or potential side effects. For a search tool with no annotation coverage, this is a significant gap in 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 a single, efficient sentence that directly states the tool's purpose without any unnecessary words. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a web search with 5 parameters) and the lack of both annotations and an output schema, the description is insufficient. It doesn't explain what the tool returns, how results are structured, or any behavioral aspects, leaving critical gaps for the agent to understand the tool fully.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds no parameter-specific information beyond what the input schema provides. Since schema description coverage is 100%, the baseline score is 3. The description doesn't elaborate on parameter usage, constraints, or examples, so it doesn't add value beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Search the web for text results') and the resource ('using DuckDuckGo'), which is specific and unambiguous. However, it doesn't explicitly distinguish this tool from its siblings like ddg-image-search or ddg-news-search, though the 'text results' wording implies a distinction from those other search types.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus its siblings (ddg-ai-chat, ddg-image-search, ddg-news-search, ddg-video-search). It doesn't mention any prerequisites, alternatives, or exclusions, leaving the agent to infer usage based on the tool name alone.

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/misanthropic-ai/ddg-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server