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
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| max_results | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/friday_mcp_server/tools/web.py:39-55 (handler)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) - src/friday_mcp_server/tools/web.py:37-55 (registration)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]]: