google_search_places
Search Google for locations, businesses, or points of interest. Specify queries, countries, languages, and pages to retrieve relevant, up-to-date data via the Serper MCP Server.
Instructions
Search Google for results
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| autocorrect | No | Automatically correct | |
| gl | No | The country to search in, e.g. us, uk, ca, au, etc. | |
| hl | No | The language to search in, e.g. en, es, fr, de, etc. | |
| location | No | The location to search in, e.g. San Francisco, CA, USA | |
| page | No | The page number to return, first page is 1 | |
| q | Yes | The query to search for |
Implementation Reference
- src/serper_mcp_server/core.py:14-18 (handler)Core handler function that constructs the Serper API URL for 'google_search_places' (uri_path='places') and calls fetch_json to execute the HTTP POST 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)
- src/serper_mcp_server/core.py:25-40 (helper)Helper function that performs the actual HTTP POST to the Serper API endpoint with the request payload.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()
- src/serper_mcp_server/server.py:41-60 (registration)MCP server tool registration via @server.list_tools(), iterates over google_request_map (which includes 'google_search_places') to register tools with their schemas.@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)Mapping of tool names (SerperTools.GOOGLE_SEARCH_PLACES = 'google_search_places') to their input schema classes, used in list_tools and call_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, }
- Input schema for 'google_search_places' tool (AutocorrectRequest, inherits from BaseRequest with query params). Used to validate arguments and generate inputSchema.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:62-82 (handler)MCP @server.call_tool() handler that dispatches 'google_search_places' calls: validates tool name, instantiates schema, calls core google() function, and returns JSON result.@server.call_tool() async def call_tool(name: str, arguments: dict[str, Any]) -> Sequence[TextContent | ImageContent | EmbeddedResource]: if not SERPER_API_KEY: return [TextContent(text=f"SERPER_API_KEY is empty!", type="text")] try: if name == SerperTools.WEBPAGE_SCRAPE.value: request = WebpageRequest(**arguments) result = await scape(request) return [TextContent(text=json.dumps(result, indent=2), type="text")] 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")] except Exception as e: return [TextContent(text=f"Error: {str(e)}", type="text")]