Skip to main content
Glama
ricleedo

Google Services MCP Server

by ricleedo

place-details

Retrieve comprehensive information about a specific location using its Google Place ID, including address, contact details, and operational data.

Instructions

Get detailed information about a specific place

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
place_idYesThe Google Place ID

Implementation Reference

  • The main handler function for the 'place-details' tool. It fetches detailed information about a place using the Google Maps Place Details API, formats the response using formatPlaceDetailsToMarkdown, and returns it as MCP content.
    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)
              }`,
            },
          ],
        };
      }
    }
  • Zod schema defining the input for the 'place-details' tool, requiring a 'place_id' string.
    export const placeDetailsSchema = z.object({
      place_id: z.string().describe("The Google Place ID"),
    });
  • src/index.ts:110-117 (registration)
    Registration of the 'place-details' tool on the MCP server, linking the name, description, schema, and handler function.
    server.tool(
      "place-details",
      "Get detailed information about a specific place",
      placeDetailsSchema.shape,
      async (params) => {
        return await placeDetails(params);
      }
    );
  • Helper function to format place details into Markdown for the tool response.
    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;
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv1.0.0
    • addedInput schema / $schema
      Added value: +"http://json-schema.org/draft-07/schema#"
    • addedInput schema / additionalProperties
      Added value: +false
  2. First observed

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It implies a read-only operation ('Get'), but doesn't disclose rate limits, authentication needs, data freshness, error conditions, or what 'detailed information' entails (e.g., address, hours, reviews). This leaves significant gaps for agent decision-making.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose ('Get detailed information') without unnecessary words. Every part earns its place, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (retrieving detailed place data), lack of annotations, and no output schema, the description is insufficient. It doesn't explain what 'detailed information' includes, potential costs/limits, or how results differ from sibling tools like 'places-search', leaving the agent under-informed for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% (the single parameter 'place_id' is documented as 'The Google Place ID'), so the baseline is 3. The description adds no additional parameter context beyond what the schema provides, such as where to obtain place_ids or format examples, but doesn't need to compensate for gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('detailed information about a specific place'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'places-search' or 'geocode', which also retrieve place-related data but with different approaches.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a place_id), contrast with 'places-search' (which likely finds places by query), or specify use cases like retrieving comprehensive details versus basic info.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.