google_search_autocomplete
Perform Google searches through the Serper MCP Server to retrieve current web information for queries, with options for location, language, and autocorrection.
Instructions
Search Google for results
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| q | Yes | The query to search for | |
| gl | No | The country to search in, e.g. us, uk, ca, au, etc. | |
| location | No | The location to search in, e.g. San Francisco, CA, USA | |
| hl | No | The language to search in, e.g. en, es, fr, de, etc. | |
| page | No | The page number to return, first page is 1 (integer value as string) | 1 |
| autocorrect | No | Automatically correct (boolean value as string: 'true' or 'false') | true |
Implementation Reference
- src/serper_mcp_server/core.py:14-17 (handler)Core handler function for the google_search_autocomplete tool. Extracts 'autocomplete' from tool name, builds Serper API URL, and fetches the response using the provided request.
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 model defining the input schema for the google_search_autocomplete tool, extending BaseRequest with 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')", ) - src/serper_mcp_server/server.py:41-60 (registration)Registers the google_search_autocomplete tool (via google_request_map) by creating a Tool object with name, description, and inputSchema from AutocorrectRequest.
@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 - src/serper_mcp_server/server.py:25-38 (registration)Maps the SerperTools.GOOGLE_SEARCH_AUTOCOMPLETE enum to AutocorrectRequest schema, used by list_tools() and call_tool() for this tool.
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, } - src/serper_mcp_server/server.py:73-79 (handler)Dispatch logic in the main MCP call_tool handler that invokes the google handler for google_search_autocomplete using the mapped schema and tool enum.
if not SerperTools.has_value(name): raise ValueError(f"Tool {name} not found") tool = SerperTools(name) request = google_request_map[tool](**arguments) result = await google(tool, request) return [TextContent(text=json.dumps(result, indent=2), type="text")]