Skip to main content
Glama
garylab
by garylab

google_search_autocomplete

Retrieve autocomplete suggestions for Google searches to enhance query accuracy. Supports location, language, and autocorrection settings for precise results.

Instructions

Search Google for results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
autocorrectNoAutomatically correct
glNoThe country to search in, e.g. us, uk, ca, au, etc.
hlNoThe language to search in, e.g. en, es, fr, de, etc.
locationNoThe location to search in, e.g. San Francisco, CA, USA
pageNoThe page number to return, first page is 1
qYesThe query to search for

Implementation Reference

  • Executes the tool logic for google_search_autocomplete (and other Google tools) by deriving the API endpoint '/autocomplete' from the tool name and posting the request to the Serper API.
    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)
  • Pydantic input schema for the google_search_autocomplete tool, inheriting from BaseRequest (query, location, etc.) and adding an autocorrect option.
    class AutocorrectRequest(BaseRequest): autocorrect: Optional[str] = Field( "true", pattern=r"^(true|false)$", description="Automatically correct (boolean value as string: 'true' or 'false')", )
  • Maps SerperTools enum values (including GOOGLE_SEARCH_AUTOCOMPLETE) to input schema classes for use in tool registration and dispatching.
    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, }
  • MCP server decorator that lists all tools, including google_search_autocomplete, providing name, description, and input schema.
    @server.list_tools() async def list_tools() -> List[Tool]: tools = [] for k, v in google_request_map.items(): tools.append( Tool( name=k.value, description="Search Google for results", inputSchema=v.model_json_schema(), ), ) tools.append(Tool( name=SerperTools.WEBPAGE_SCRAPE, description="Scrape webpage by url", inputSchema=WebpageRequest.model_json_schema(), )) return tools
  • Enum constant defining the tool name string 'google_search_autocomplete' used throughout the codebase.
    GOOGLE_SEARCH_AUTOCOMPLETE = "google_search_autocomplete"

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