Skip to main content
Glama
by garylab

google_search_reviews

Retrieve Google reviews and ratings for specific places or topics using the Serper MCP Server. Filter by location, language, and sort order to access relevant data for analysis or insights.

Instructions

Search Google for results

Input Schema

NameRequiredDescriptionDefault
cidNoThe CID to search in
fidYesThe FID
glNoThe country to search in, e.g. us, uk, ca, au, etc.
hlNoThe language to search in, e.g. en, es, fr, de, etc.
nextPageTokenNoThe next page token to use
placeIdNoThe place ID to search in
sortByNoThe sort order to usemostRelevant
topicIdNoThe topic ID to search in

Input Schema (JSON Schema)

{ "$defs": { "ReviewSortBy": { "enum": [ "mostRelevant", "newest", "highestRating", "lowestRating" ], "title": "ReviewSortBy", "type": "string" } }, "properties": { "cid": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "description": "The CID to search in", "title": "Cid" }, "fid": { "description": "The FID", "title": "Fid", "type": "string" }, "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" }, "nextPageToken": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "description": "The next page token to use", "title": "Nextpagetoken" }, "placeId": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "description": "The place ID to search in", "title": "Placeid" }, "sortBy": { "anyOf": [ { "$ref": "#/$defs/ReviewSortBy" }, { "type": "null" } ], "default": "mostRelevant", "description": "The sort order to use" }, "topicId": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "description": "The topic ID to search in", "title": "Topicid" } }, "required": [ "fid" ], "title": "ReviewsRequest", "type": "object" }

Implementation Reference

  • Handler function that implements the core logic for the 'google_search_reviews' tool (and other Google tools). It extracts the endpoint ('reviews') from the tool name and calls the Serper API via fetch_json.
    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)
  • Pydantic schema/model for input validation of the 'google_search_reviews' tool.
    class ReviewsRequest(BaseModel): fid: str = Field(..., description="The FID") cid: Optional[str] = Field(None, description="The CID to search in") placeId: Optional[str] = Field(None, description="The place ID to search in") sortBy: Optional[str] = Field( "mostRelevant", pattern=r"^(mostRelevant|newest|highestRating|lowestRating)$", description="The sort order to use (enum value as string: 'mostRelevant', 'newest', 'highestRating', 'lowestRating')", ) topicId: Optional[str] = Field(None, description="The topic ID to search in") nextPageToken: Optional[str] = Field(None, description="The next page token to use") 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." )
  • Dictionary mapping tool enums to their corresponding request schemas, used for tool registration in list_tools() and request creation in 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, }
  • Helper function that performs the actual HTTP POST request to the Serper API endpoint with authentication and returns the JSON response.
    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()
  • StrEnum defining all tool names, including 'google_search_reviews', used for validation and dispatch.
    class SerperTools(StrEnum): GOOGLE_SEARCH = "google_search" GOOGLE_SEARCH_IMAGES = "google_search_images" GOOGLE_SEARCH_VIDEOS = "google_search_videos" GOOGLE_SEARCH_PLACES = "google_search_places" GOOGLE_SEARCH_MAPS = "google_search_maps" GOOGLE_SEARCH_REVIEWS = "google_search_reviews" GOOGLE_SEARCH_NEWS = "google_search_news" GOOGLE_SEARCH_SHOPPING = "google_search_shopping" GOOGLE_SEARCH_LENS = "google_search_lens" GOOGLE_SEARCH_SCHOLAR = "google_search_scholar" GOOGLE_SEARCH_PATENTS = "google_search_patents" GOOGLE_SEARCH_AUTOCOMPLETE = "google_search_autocomplete" WEBPAGE_SCRAPE = "webpage_scrape"

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