Skip to main content
Glama
garylab

Serper MCP Server

by garylab

google_search_autocomplete

Retrieve Google search results with configurable country, location, language, page, and autocorrect options.

Instructions

Search Google for results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYesThe query to search for
glNoThe country to search in, e.g. us, uk, ca, au, etc.
locationNoThe location to search in, e.g. San Francisco, CA, USA
hlNoThe language to search in, e.g. en, es, fr, de, etc.
pageNoThe page number to return, first page is 1 (integer value as string)1
autocorrectNoAutomatically correct (boolean value as string: 'true' or 'false')true

Implementation Reference

  • Core handler: when google_search_autocomplete is called, this parses the tool name's last segment ('autocomplete') to build the Serper API URL (https://google.serper.dev/autocomplete) and delegates to fetch_json.
    async def google(tool: SerperTools, request: BaseModel) -> Dict[str, Any]:
        uri_path = tool.value.split("_")[-1]
        url = f"https://google.serper.dev/{uri_path}"
        return await fetch_json(url, request)
    
    
    async def scape(request: WebpageRequest) -> Dict[str, Any]:
        url = "https://scrape.serper.dev"
        return await fetch_json(url, request)
    
    
    async def fetch_json(url: str, request: BaseModel) -> Dict[str, Any]:
        payload = request.model_dump(exclude_none=True)
        headers = {
            'X-API-KEY': SERPER_API_KEY,
            'Content-Type': 'application/json'
        }
    
        ssl_context = ssl.create_default_context(cafile=certifi.where())
        connector = aiohttp.TCPConnector(ssl=ssl_context)
    
        timeout = aiohttp.ClientTimeout(total=AIOHTTP_TIMEOUT)
        async with aiohttp.ClientSession(connector=connector, timeout=timeout) as session:
            async with session.post(url, headers=headers, json=payload) as response:
                response.raise_for_status()
                return await response.json()
  • Pydantic schema for the google_search_autocomplete tool input. Extends BaseRequest (q, gl, location, hl, page) with an autocorrect field.
    class AutocorrectRequest(BaseRequest):
        autocorrect: Optional[str] = Field(
            "true",
            pattern=r"^(true|false)$",
            description="Automatically correct (boolean value as string: 'true' or 'false')",
        )
  • Tool registration via MCP list_tools: iterates google_request_map including GOOGLE_SEARCH_AUTOCOMPLETE to register the tool with its schema.
    for k, v in google_request_map.items():
        tools.append(
            Tool(
                name=k.value,
                description="Search Google for results",
                inputSchema=v.model_json_schema(),
  • Enum definition mapping 'google_search_autocomplete' string to SerperTools.GOOGLE_SEARCH_AUTOCOMPLETE.
    GOOGLE_SEARCH_AUTOCOMPLETE = "google_search_autocomplete"
  • Map that associates the GOOGLE_SEARCH_AUTOCOMPLETE enum value with the AutocorrectRequest schema, used by call_tool to dispatch.
    google_request_map = {
        SerperTools.GOOGLE_SEARCH: SearchRequest,
        SerperTools.GOOGLE_SEARCH_IMAGES: SearchRequest,
        SerperTools.GOOGLE_SEARCH_VIDEOS: SearchRequest,
        SerperTools.GOOGLE_SEARCH_PLACES: AutocorrectRequest,
        SerperTools.GOOGLE_SEARCH_MAPS: MapsRequest,
        SerperTools.GOOGLE_SEARCH_REVIEWS: ReviewsRequest,
        SerperTools.GOOGLE_SEARCH_NEWS: SearchRequest,
        SerperTools.GOOGLE_SEARCH_SHOPPING: ShoppingRequest,
        SerperTools.GOOGLE_SEARCH_LENS: LensRequest,
        SerperTools.GOOGLE_SEARCH_SCHOLAR: AutocorrectRequest,
        SerperTools.GOOGLE_SEARCH_PATENTS: PatentsRequest,
        SerperTools.GOOGLE_SEARCH_AUTOCOMPLETE: AutocorrectRequest,
    }
Behavior2/5

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

No annotations are present, and the description fails to disclose behavioral traits. It is unclear whether the tool returns autocomplete suggestions or full search results, which is misleading given the tool name.

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

Conciseness2/5

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

The description is extremely short but lacks essential information, making it under-specified rather than concise. It fails to earn its place by omitting key details.

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

Completeness1/5

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

Given no output schema, no annotations, and a name-description mismatch, the description is completely inadequate. It does not explain the tool's purpose, return value, or differentiation from 11 siblings.

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?

Input schema provides 100% coverage of parameter descriptions, so the description adds no additional meaning. Baseline score of 3 applies.

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

Purpose2/5

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

The description 'Search Google for results' is vague and does not differentiate from sibling tools like google_search. The name suggests autocomplete functionality, but the description contradicts that by implying general search results.

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?

No guidance is provided on when to use this tool versus alternatives such as google_search. There is no mention of context or conditions for use.

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

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