Skip to main content
Glama
garylab
by garylab

google_search_places

Find local businesses and places using Google search with location-based filtering, language options, and automatic query correction.

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

  • Handler function that implements the core logic for the google_search_places tool by deriving the API endpoint '/places' from the tool name and calling the Serper API with the 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)
  • Input schema used for google_search_places tool (AutocorrectRequest, inherits from BaseRequest with query 'q', location, etc.). Mapped in server.py.
    class AutocorrectRequest(BaseRequest): autocorrect: Optional[str] = Field( "true", pattern=r"^(true|false)$", description="Automatically correct (boolean value as string: 'true' or 'false')", )
  • Maps the tool enum SerperTools.GOOGLE_SEARCH_PLACES to its schema AutocorrectRequest for use in 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, }
  • Registers the google_search_places tool (via loop over google_request_map) with MCP server, providing name and inputSchema.
    @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
  • MCP tool call handler that dispatches google_search_places calls by parsing arguments into schema, calling the google handler, and returning JSON response.
    @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")]

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