Skip to main content
Glama

get_place_details

Retrieve comprehensive information about a specific location using its Google Maps Place ID to access details like address, contact, and business data.

Instructions

Get detailed information about a specific place

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
placeIdYesGoogle Maps Place ID

Implementation Reference

  • Core handler function that fetches and processes place details from Google Places API using the google-maps-services-js client.
    async getPlaceDetails(
        placeId: string
    ): Promise<ServiceResponse<PlaceDetails>> {
        try {
            validateRequiredString(placeId, "Place ID");
    
            const response = await this.client.placeDetails({
                params: {
                    key: config.googleMapsApiKey,
                    place_id: placeId,
                    language: config.defaultLanguage as Language,
                    fields: [
                        "name",
                        "formatted_address",
                        "geometry",
                        "googleMapsLinks",
                        "rating",
                        "reviews",
                        "reviewSummary",
                        "user_ratings_total",
                        "opening_hours",
                        "photos",
                        "price_level",
                        "types",
                        "website",
                        "formatted_phone_number",
                    ],
                },
            });
    
            const place = response.data.result;
    
            // First check if the API call was successful
            if (response.data.status !== "OK") {
                throw new Error(
                    `Google Places API error: ${response.data.status} - ${response.data.error_message || "Unknown error"}`
                );
            }
    
            // Check if we have a result
            if (!place) {
                throw new Error(
                    "No place data returned from Google Places API"
                );
            }
    
            // Check for required fields with detailed error message
            if (!place.place_id || !place.name) {
                throw new Error(
                    `Missing required place data - place_id: ${place.place_id || "undefined"}, name: ${place.name || "undefined"}, API status: ${response.data.status}`
                );
            }
            return {
                success: true,
                data: {
                    placeId: place.place_id,
                    name: place.name,
                    formattedAddress: place.formatted_address,
                    location: place.geometry?.location,
                    rating: place.rating,
                    userRatingsTotal: place.user_ratings_total,
                    openingHours: place.opening_hours
                        ? {
                              openNow: place.opening_hours.open_now,
                              periods: place.opening_hours.periods?.map(
                                  (period) => ({
                                      open: {
                                          day: period.open.day,
                                          time: period.open.time || "",
                                      },
                                      close: period.close
                                          ? {
                                                day: period.close.day,
                                                time: period.close.time || "",
                                            }
                                          : { day: 0, time: "" },
                                  })
                              ),
                          }
                        : undefined,
                    photos: place.photos?.map((photo) => ({
                        photoReference: photo.photo_reference,
                        height: photo.height,
                        width: photo.width,
                    })),
                    priceLevel: place.price_level,
                    types: place.types,
                    website: place.website,
                    phoneNumber: place.formatted_phone_number,
                },
            };
        } catch (error) {
            return handleError(error);
        }
    }
  • Registers the get_place_details tool with the MCP server, providing schema, title, description, and a thin wrapper handler that delegates to the PlacesSearcher service.
    server.registerTool(
        "get_place_details",
        {
            title: "Get Place Details",
            description: "Get detailed information about a specific place",
            inputSchema: PlaceDetailsSchema,
        },
        async (args) => {
            try {
                const result = await placesSearcher.getPlaceDetails(
                    args.placeId
                );
                return {
                    content: [
                        { type: "text", text: JSON.stringify(result, null, 2) },
                    ],
                    isError: !result.success,
                };
            } catch (error) {
                const errorResponse = handleError(error);
                return {
                    content: [
                        {
                            type: "text",
                            text:
                                errorResponse.error ||
                                "An unknown error occurred",
                        },
                    ],
                    isError: true,
                };
            }
        }
    );
  • Zod schema defining the input for the tool: a required placeId string.
    export const PlaceDetailsSchema = {
      placeId: z.string().describe("Google Maps Place ID")
    };

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/BACH-AI-Tools/MCP-Google-Maps'

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