Skip to main content
Glama
yubinkim444

ai-first-scraper-mcp

search_web

Run a web search and retrieve the top results as clean Markdown, combining search and reading to get fresh information in one call.

Instructions

Run a web search and return the top-k result pages already converted to clean Markdown. Use this whenever you need fresh information from the public web — it combines search and read in one call.

Args: q: The user's query (free text). k: How many results to fetch (1–10, default 5). max_tokens: Optional per-result soft cap on the returned Markdown.

Returns: A list of {url, title, snippet, ok, markdown, word_count, error?} result objects. Use title and snippet to decide which results are worth citing, then drop the markdown field into your prompt.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYes
kNo
max_tokensNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The async handler function for the search_web tool. Takes a search query string 'q', optional 'k' (number of results, default 5), and optional 'max_tokens'. Makes a GET request to the SEARCH_URL /search endpoint with these params and returns the 'results' list from the JSON response.
    @mcp.tool()
    async def search_web(q: str, k: int = 5, max_tokens: Optional[int] = None) -> list[dict]:
        """Run a web search and return the top-k result pages already converted to
        clean Markdown. Use this whenever you need fresh information from the
        public web — it combines search and read in one call.
    
        Args:
            q: The user's query (free text).
            k: How many results to fetch (1–10, default 5).
            max_tokens: Optional per-result soft cap on the returned Markdown.
    
        Returns:
            A list of `{url, title, snippet, ok, markdown, word_count, error?}`
            result objects. Use `title` and `snippet` to decide which results are
            worth citing, then drop the `markdown` field into your prompt.
        """
        params: dict[str, str | int] = {"q": q, "k": k}
        if max_tokens:
            params["max_tokens"] = max_tokens
        async with httpx.AsyncClient(timeout=DEFAULT_TIMEOUT) as client:
            resp = await client.get(f"{SEARCH_URL}/search", params=params)
            resp.raise_for_status()
            return resp.json().get("results", [])
  • The tool is registered as an MCP tool using the @mcp.tool() decorator on the search_web function. The FastMCP instance 'mcp' is created on line 32.
    @mcp.tool()
  • The input schema is defined through type hints in the function signature: q (str), k (int, default 5), max_tokens (Optional[int]). The return type is list[dict], documented to contain keys: url, title, snippet, ok, markdown, word_count, error?.
    @mcp.tool()
  • The SEARCH_URL config constant used by search_web to determine the upstream search API endpoint. Defaults to https://ai-first-search.onrender.com and can be overridden via the SEARCH_URL environment variable.
    SCRAPER_URL = os.getenv("SCRAPER_URL", "https://ai-first-scraper.onrender.com").rstrip("/")
    SEARCH_URL = os.getenv("SEARCH_URL", "https://ai-first-search.onrender.com").rstrip("/")
    DEFAULT_TIMEOUT = float(os.getenv("AFS_TIMEOUT", "45"))
Behavior3/5

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

No annotations provided, so description bears full burden. It describes the main behavior (search and convert to markdown) and return format, but does not disclose potential limitations like rate limiting, error handling, or result filtering details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear action sentence followed by detailed Args/Returns. It is slightly verbose but every sentence adds value. Front-loaded with purpose, then parameter details.

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

Completeness4/5

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

Given the tool's simplicity (3 parameters, no nested objects), the description is sufficiently complete. It covers the return format, though the actual output schema is not in the prompt. Sibling tools provide context for selection.

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

Parameters5/5

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

Schema description coverage is 0%, but the description adds full semantic meaning for all parameters: q is 'free text', k is 'how many results (1-10, default 5)', max_tokens is 'optional per-result soft cap'. This fully compensates for missing schema descriptions.

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?

The description explicitly states 'Run a web search and return the top-k result pages already converted to clean Markdown', providing a specific verb and resource. It distinguishes itself from sibling tools (fetch_page, fetch_pages_batch) by noting that it combines search and read in one call.

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

Usage Guidelines4/5

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

The description gives clear guidance: 'Use this whenever you need fresh information from the public web'. It implies that siblings are for fetching known URLs, but does not explicitly state when not to use this tool.

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/yubinkim444/ai-first-scraper-mcp'

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