get-google-reviews
Retrieve Google reviews for businesses or places by providing search terms, CID, or Place ID. Specify the number of reviews, sort order, language, and location for tailored results.
Instructions
Retrieve Google reviews for businesses or places.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cid | No | Google Maps CID | |
| keyword | No | Business name or search term | |
| language | No | Language code (e.g., 'en') | en |
| location | No | Location context | London,England,United Kingdom |
| placeId | No | Google Place ID | |
| reviews | No | Number of reviews to fetch | |
| sortBy | No | Sort order | relevant |
Implementation Reference
- src/index.ts:311-336 (handler)The handler function for the 'get-google-reviews' tool, which proxies requests to the Dumpling API to fetch Google reviews based on provided parameters.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:287-310 (schema)Input schema definition using Zod for validating parameters like keyword, cid, placeId, etc., for the 'get-google-reviews' tool.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 registration call that defines and registers the 'get-google-reviews' tool with its name, description, schema, and handler.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) }] }; } );