place-details
Retrieve comprehensive details for any location using its Google Place ID, including address, contact information, hours, and ratings.
Instructions
Get detailed information about a specific place
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| place_id | Yes | The Google Place ID |
Input Schema (JSON Schema)
{
"properties": {
"place_id": {
"description": "The Google Place ID",
"type": "string"
}
},
"required": [
"place_id"
],
"type": "object"
}
Implementation Reference
- src/maps.ts:456-509 (handler)The asynchronous handler function that calls the Google Maps placeDetails API with the provided place_id, processes the response into structured data, and returns it formatted as Markdown using the helper function.export async function placeDetails( params: z.infer<typeof placeDetailsSchema>, extra?: any ) { const apiKey = process.env.GOOGLE_MAPS_API_KEY; if (!apiKey) { throw new Error("GOOGLE_MAPS_API_KEY is required"); } try { const response = await googleMapsClient.placeDetails({ params: { place_id: params.place_id, key: apiKey, }, }); const place = response.data.result; const placeData = { name: place.name, formatted_address: place.formatted_address, phone_number: place.formatted_phone_number, website: place.website, rating: place.rating, user_ratings_total: place.user_ratings_total, price_level: place.price_level, opening_hours: place.opening_hours?.weekday_text, types: place.types, latitude: place.geometry?.location.lat, longitude: place.geometry?.location.lng, }; return { content: [ { type: "text" as const, text: formatPlaceDetailsToMarkdown(placeData), }, ], }; } catch (error) { return { content: [ { type: "text" as const, text: `Error getting place details: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } }
- src/maps.ts:141-143 (schema)Zod schema defining the single required input parameter 'place_id' (string) for the tool.export const placeDetailsSchema = z.object({ place_id: z.string().describe("The Google Place ID"), });
- src/index.ts:110-117 (registration)Registers the 'place-details' tool with the MCP server, providing name, description, input schema from placeDetailsSchema, and wrapper around the placeDetails handler.server.tool( "place-details", "Get detailed information about a specific place", placeDetailsSchema.shape, async (params) => { return await placeDetails(params); } );
- src/maps.ts:68-103 (helper)Utility function to format the raw place details data into a rich Markdown string, including name, address, phone, website, rating, price, location, hours, and types.function formatPlaceDetailsToMarkdown(place: any): string { let markdown = `# ${place.name}\n\n`; if (place.formatted_address) markdown += `Address: ${place.formatted_address} \n`; if (place.phone_number) markdown += `Phone: ${place.phone_number} \n`; if (place.website) markdown += `Website: [Visit](${place.website}) \n`; if (place.rating) { markdown += `Rating: ${place.rating}β`; if (place.user_ratings_total) markdown += ` (${place.user_ratings_total} reviews)`; markdown += ` \n`; } if (place.price_level !== undefined) { const priceSymbols = '$'.repeat(place.price_level + 1); markdown += `Price Level: ${priceSymbols} \n`; } if (place.latitude && place.longitude) { markdown += `Location: ${place.latitude}, ${place.longitude} \n`; markdown += `Maps: [View](https://maps.google.com/?q=${place.latitude},${place.longitude}) \n`; } if (place.opening_hours && place.opening_hours.length) { markdown += `\n## Hours\n`; place.opening_hours.forEach((hours: string) => { markdown += `- ${hours}\n`; }); } if (place.types && place.types.length) { markdown += `\nCategories: ${place.types.join(', ')}`; } return markdown; }