Skip to main content
Glama
JeremyLakeyJr

Friday MCP Server

search_web

Search the web using DuckDuckGo. Submit a query and optionally set max results to receive top ranked web pages.

Instructions

Search the web with DuckDuckGo and return the top results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
max_resultsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The 'search_web' tool handler: accepts 'query' (str) and optional 'max_results' (int, default 5). It runs a DuckDuckGo search synchronously via DDGS in a thread pool (asyncio.to_thread) and returns a list of dicts with title, snippet, and url.
    async def search_web(query: str, max_results: int = 5) -> list[dict[str, str]]:
        """Search the web with DuckDuckGo and return the top results."""
    
        def _search() -> list[dict[str, str]]:
            from duckduckgo_search import DDGS
    
            with DDGS() as ddgs:
                return [
                    {
                        "title": result.get("title", ""),
                        "snippet": result.get("body", ""),
                        "url": result.get("href", ""),
                    }
                    for result in ddgs.text(query, max_results=max_results)
                ]
    
        return await asyncio.to_thread(_search)
  • The 'search_web' tool is registered via the @mcp.tool() decorator inside web.register(), which is called from register_all_tools() in tools/__init__.py, which is called from build_server() in server.py.
    def register(mcp, *, config) -> None:
        @mcp.tool()
        async def search_web(query: str, max_results: int = 5) -> list[dict[str, str]]:
            """Search the web with DuckDuckGo and return the top results."""
    
            def _search() -> list[dict[str, str]]:
                from duckduckgo_search import DDGS
    
                with DDGS() as ddgs:
                    return [
                        {
                            "title": result.get("title", ""),
                            "snippet": result.get("body", ""),
                            "url": result.get("href", ""),
                        }
                        for result in ddgs.text(query, max_results=max_results)
                    ]
    
            return await asyncio.to_thread(_search)
  • The type signature defines the schema: 'query' (required string) and 'max_results' (optional int, default 5). Return type is list[dict[str,str]].
    async def search_web(query: str, max_results: int = 5) -> list[dict[str, str]]:
Behavior2/5

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

No annotations provided, so description carries full burden. Mentions 'DuckDuckGo' and 'top results', but does not disclose rate limits, authentication, or result format details.

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?

Single sentence, front-loaded with key info, no filler. Every word is necessary and informative.

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

Completeness3/5

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

For a simple search tool with existing output schema, description covers basics but leaves ambiguity about 'top results' and does not mention any limitations or edge cases.

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

Parameters2/5

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

Schema description coverage is 0%. Description mentions 'top results' hinting at 'max_results', but does not add meaning for 'query' or explain parameter usage beyond tool name.

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?

Clearly states verb 'Search', resource 'the web', specific engine 'DuckDuckGo', and outcome 'return the top results'. Distinct from siblings like 'fetch_url' and 'get_world_news'.

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

Usage Guidelines3/5

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

No explicit when/when-not or alternatives provided. Implied usage for general web searches, but lacks guidance on when to choose this over sibling tools.

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/JeremyLakeyJr/mcp-server'

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