google_search_lens
Perform targeted Google searches by specifying URLs, countries, and languages to retrieve relevant web information via the Serper MCP Server.
Instructions
Search Google for results
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| 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. | |
| url | Yes | The url to search |
Input Schema (JSON Schema)
{
"properties": {
"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"
},
"url": {
"description": "The url to search",
"title": "Url",
"type": "string"
}
},
"required": [
"url"
],
"title": "LensRequest",
"type": "object"
}
Implementation Reference
- src/serper_mcp_server/core.py:14-17 (handler)Core handler function for Google Serper tools. For 'google_search_lens', extracts 'lens' from tool name and calls Serper API at https://google.serper.dev/lens with the LensRequest payload.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/server.py:73-79 (handler)Dispatch logic in the main @server.call_tool() handler. For 'google_search_lens', parses tool enum, validates arguments against LensRequest schema, calls core.google, and returns JSON result.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")]
- Pydantic input schema (LensRequest) used for validating arguments to the google_search_lens tool.class LensRequest(BaseModel): url: str = Field(..., description="The url to search") 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." )
- src/serper_mcp_server/server.py:25-38 (registration)Mapping from SerperTools enum values to their corresponding request schemas, including GOOGLE_SEARCH_LENS to LensRequest. Used in both tool listing and call 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:45-52 (registration)Loop in @server.list_tools() that registers the google_search_lens tool (name="google_search_lens") with its schema.for k, v in google_request_map.items(): tools.append( Tool( name=k.value, description="Search Google for results", inputSchema=v.model_json_schema(), ), )