Skip to main content
Glama
cablate

MCP Google Map Server

search_nearby

Find nearby locations by specifying a center point, keyword, radius, and filters like open status or minimum rating. Ideal for identifying places such as restaurants or cafés in your vicinity using Google Maps data.

Instructions

搜尋附近的地點

Input Schema

NameRequiredDescriptionDefault
centerYes搜尋中心點
keywordNo搜尋關鍵字(例如:餐廳、咖啡廳)
minRatingNo最低評分要求(0-5)
openNowNo是否只顯示營業中的地點
radiusNo搜尋半徑(公尺)

Input Schema (JSON Schema)

{ "properties": { "center": { "description": "搜尋中心點", "properties": { "isCoordinates": { "default": false, "description": "是否為經緯度座標", "type": "boolean" }, "value": { "description": "地址、地標名稱或經緯度座標(經緯度座標格式: lat,lng)", "type": "string" } }, "required": [ "value" ], "type": "object" }, "keyword": { "description": "搜尋關鍵字(例如:餐廳、咖啡廳)", "type": "string" }, "minRating": { "description": "最低評分要求(0-5)", "maximum": 5, "minimum": 0, "type": "number" }, "openNow": { "default": false, "description": "是否只顯示營業中的地點", "type": "boolean" }, "radius": { "default": 1000, "description": "搜尋半徑(公尺)", "type": "number" } }, "required": [ "center" ], "type": "object" }

Implementation Reference

  • Main handler function that executes the tool logic: creates PlacesSearcher instance and calls its searchNearby method, formats the response.
    async function ACTION(params: SearchNearbyParams): Promise<{ content: any[]; isError?: boolean }> { try { // Create a new PlacesSearcher instance with the current request's API key const apiKey = getCurrentApiKey(); const placesSearcher = new PlacesSearcher(apiKey); const result = await placesSearcher.searchNearby(params); if (!result.success) { return { content: [{ type: "text", text: result.error || "Search failed" }], isError: true, }; } return { content: [ { type: "text", text: `location: ${JSON.stringify(result.location, null, 2)}\n` + JSON.stringify(result.data, null, 2), }, ], isError: false, }; } catch (error: any) { const errorMessage = error instanceof Error ? error.message : JSON.stringify(error); return { isError: true, content: [{ type: "text", text: `Error searching nearby places: ${errorMessage}` }], }; } }
  • Zod schema defining input parameters for the search_nearby tool.
    const SCHEMA = { center: z.object({ value: z.string().describe("Address, landmark name, or coordinates (coordinate format: lat,lng)"), isCoordinates: z.boolean().default(false).describe("Whether the value is coordinates"), }).describe("Search center point (e.g. value: 49.3268778,-123.0585982, isCoordinates: true)"), keyword: z.string().optional().describe("Search keyword (e.g., restaurant, cafe, hotel)"), radius: z.number().default(1000).describe("Search radius in meters"), openNow: z.boolean().default(false).describe("Only show places that are currently open"), minRating: z.number().min(0).max(5).optional().describe("Minimum rating requirement (0-5)"), };
  • src/config.ts:24-28 (registration)
    Registration of the search_nearby tool in the server configuration array.
    name: SearchNearby.NAME, description: SearchNearby.DESCRIPTION, schema: SearchNearby.SCHEMA, action: (params: SearchNearbyParams) => SearchNearby.ACTION(params), },
  • Helper method in PlacesSearcher class that performs the actual nearby search using Google Maps tools and processes results.
    async searchNearby(params: { center: { value: string; isCoordinates: boolean }; keyword?: string; radius?: number; openNow?: boolean; minRating?: number }): Promise<SearchNearbyResponse> { try { const location = await this.mapsTools.getLocation(params.center); const places = await this.mapsTools.searchNearbyPlaces({ location, keyword: params.keyword, radius: params.radius, openNow: params.openNow, minRating: params.minRating, }); return { location: location, success: true, data: places.map((place) => ({ name: place.name, place_id: place.place_id, address: place.formatted_address, location: place.geometry.location, rating: place.rating, total_ratings: place.user_ratings_total, open_now: place.opening_hours?.open_now, })), }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : "An error occurred during search", }; } }
  • Low-level helper in GoogleMapsTools that calls Google Places API placesNearby and applies minRating filter.
    async searchNearbyPlaces(params: SearchParams): Promise<PlaceResult[]> { const searchParams = { location: params.location, radius: params.radius || 1000, keyword: params.keyword, opennow: params.openNow, language: this.defaultLanguage, key: this.apiKey, }; try { const response = await this.client.placesNearby({ params: searchParams, }); let results = response.data.results; if (params.minRating) { results = results.filter((place) => (place.rating || 0) >= (params.minRating || 0)); } return results as PlaceResult[]; } catch (error: any) { Logger.error("Error in searchNearbyPlaces:", error); throw new Error(`Failed to search nearby places: ${extractErrorMessage(error)}`); } }

Other Tools

Related Tools

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/cablate/mcp-google-map'

If you have feedback or need assistance with the MCP directory API, please join our Discord server