Skip to main content
Glama
by garylab

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

NameRequiredDescriptionDefault
glNoThe country to search in, e.g. us, uk, ca, au, etc.
hlNoThe language to search in, e.g. en, es, fr, de, etc.
urlYesThe 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

  • 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)
  • 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." )
  • 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, }
  • 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(), ), )

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