get-google-reviews
Retrieve Google reviews for businesses using search terms, Place IDs, or CIDs to analyze customer feedback and ratings.
Instructions
Retrieve Google reviews for businesses or places.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keyword | No | Business name or search term | |
| cid | No | Google Maps CID | |
| placeId | No | Google Place ID | |
| reviews | No | Number of reviews to fetch | |
| sortBy | No | Sort order | relevant |
| language | No | Language code (e.g., 'en') | en |
| location | No | Location context | London,England,United Kingdom |
Implementation Reference
- src/index.ts:311-336 (handler)The asynchronous handler function for the 'get-google-reviews' tool. It validates required inputs, retrieves the API key, makes a POST request to the Dumpling AI backend endpoint '/api/v1/get-google-reviews' with the parameters, handles errors, and returns the response data as structured text content.
async ({ keyword, cid, placeId, reviews, sortBy, language, location }) => { if (!keyword && !cid && !placeId) throw new Error("Either keyword, cid, or placeId is required"); const apiKey = process.env.DUMPLING_API_KEY; if (!apiKey) throw new Error("DUMPLING_API_KEY not set"); const response = await fetch(`${NWS_API_BASE}/api/v1/get-google-reviews`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ keyword, cid, placeId, reviews, sortBy, language, location, }), }); if (!response.ok) throw new Error(`Failed: ${response.status} ${await response.text()}`); const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } - src/index.ts:286-310 (schema)Zod input schema for the 'get-google-reviews' tool, defining optional parameters like keyword, cid, placeId, number of reviews, sorting, language, and location with defaults and descriptions.
{ keyword: z.string().optional().describe("Business name or search term"), cid: z.string().optional().describe("Google Maps CID"), placeId: z.string().optional().describe("Google Place ID"), reviews: z .number() .optional() .default(10) .describe("Number of reviews to fetch"), sortBy: z .enum(["relevant", "newest", "highest_rating", "lowest_rating"]) .optional() .default("relevant") .describe("Sort order"), language: z .string() .optional() .default("en") .describe("Language code (e.g., 'en')"), location: z .string() .optional() .default("London,England,United Kingdom") .describe("Location context"), }, - src/index.ts:283-337 (registration)The server.tool() call that registers the 'get-google-reviews' MCP tool, specifying its name, description, input schema, and handler function.
server.tool( "get-google-reviews", "Retrieve Google reviews for businesses or places.", { keyword: z.string().optional().describe("Business name or search term"), cid: z.string().optional().describe("Google Maps CID"), placeId: z.string().optional().describe("Google Place ID"), reviews: z .number() .optional() .default(10) .describe("Number of reviews to fetch"), sortBy: z .enum(["relevant", "newest", "highest_rating", "lowest_rating"]) .optional() .default("relevant") .describe("Sort order"), language: z .string() .optional() .default("en") .describe("Language code (e.g., 'en')"), location: z .string() .optional() .default("London,England,United Kingdom") .describe("Location context"), }, async ({ keyword, cid, placeId, reviews, sortBy, language, location }) => { if (!keyword && !cid && !placeId) throw new Error("Either keyword, cid, or placeId is required"); const apiKey = process.env.DUMPLING_API_KEY; if (!apiKey) throw new Error("DUMPLING_API_KEY not set"); const response = await fetch(`${NWS_API_BASE}/api/v1/get-google-reviews`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ keyword, cid, placeId, reviews, sortBy, language, location, }), }); if (!response.ok) throw new Error(`Failed: ${response.status} ${await response.text()}`); const data = await response.json(); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } );