google_search_maps
Retrieve Google Maps search results by entering a query, location, place ID, or country code using the Serper MCP Server for accurate, location-based web data.
Instructions
Search Google for results
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cid | No | The CID to search in | |
| 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. | |
| ll | No | The GPS position & zoom level | |
| page | No | The page number to return, first page is 1 | |
| placeId | No | The place ID to search in | |
| q | Yes | The query to search for |
Input Schema (JSON Schema)
{
"properties": {
"cid": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The CID to search in",
"title": "Cid"
},
"gl": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The country to search in, e.g. us, uk, ca, au, etc.",
"title": "Gl"
},
"hl": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The language to search in, e.g. en, es, fr, de, etc.",
"title": "Hl"
},
"ll": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The GPS position & zoom level",
"title": "Ll"
},
"page": {
"anyOf": [
{
"minimum": 1,
"type": "integer"
},
{
"type": "null"
}
],
"default": 1,
"description": "The page number to return, first page is 1",
"title": "Page"
},
"placeId": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The place ID to search in",
"title": "Placeid"
},
"q": {
"description": "The query to search for",
"title": "Q",
"type": "string"
}
},
"required": [
"q"
],
"title": "MapsRequest",
"type": "object"
}
Implementation Reference
- src/serper_mcp_server/core.py:14-19 (handler)The google function implements the core logic for the google_search_maps tool by deriving the API endpoint '/maps' from the tool name and calling the fetch_json helper to POST the request to 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)
- src/serper_mcp_server/core.py:25-40 (handler)Helper function that performs the actual HTTP POST to the Serper API, used by google handler.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 model defining the input schema/validation for the google_search_maps tool.class MapsRequest(BaseModel): q: str = Field(..., description="The query to search for") ll: Optional[str] = Field(None, description="The GPS position & zoom level") placeId: Optional[str] = Field(None, description="The place ID to search in") cid: Optional[str] = Field(None, description="The CID to search in") gl: Optional[str] = Field( None, description="The country to search in, e.g. us, uk, ca, au, etc." ) hl: Optional[str] = Field( None, description="The language to search in, e.g. en, es, fr, de, etc." ) page: Optional[str] = Field( "1", pattern=r"^[1-9]\d*$", description="The page number to return, first page is 1 (integer value as string)", )
- src/serper_mcp_server/server.py:25-38 (registration)Dictionary mapping SerperTools enum (including GOOGLE_SEARCH_MAPS) to their respective request schemas, used for tool registration and 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, }
- src/serper_mcp_server/server.py:62-82 (registration)The MCP call_tool handler that dispatches google_search_maps calls to the google function using the request map.@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")]