Skip to main content
Glama
ricleedo

Google Services MCP Server

by ricleedo

places-search

Search for places using text queries with location and radius parameters to find relevant results from Google Maps data.

Instructions

Search for places using text query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe search query
locationNoBias results around this location (e.g., 'lat,lng')
radiusNoSearch radius in meters

Implementation Reference

  • The main handler function for the 'places-search' tool. It uses Google Maps Text Search API to find places matching the query, optionally biased by location and radius. Formats up to 5 results using formatPlacesToMarkdown and returns as MCP content.
    export async function placesSearch(
      params: z.infer<typeof placesSearchSchema>,
      extra?: any
    ) {
      const apiKey = process.env.GOOGLE_MAPS_API_KEY;
      if (!apiKey) {
        throw new Error("GOOGLE_MAPS_API_KEY is required");
      }
    
      try {
        const requestParams: any = {
          query: params.query,
          key: apiKey,
        };
    
        if (params.location) {
          requestParams.location = params.location;
        }
        if (params.radius) {
          requestParams.radius = params.radius;
        }
    
        const response = await googleMapsClient.textSearch({
          params: requestParams,
        });
    
        const results = response.data.results;
        if (results.length === 0) {
          return {
            content: [
              {
                type: "text" as const,
                text: "No places found for the given query.",
              },
            ],
          };
        }
    
        const places = results.slice(0, 5).map((place) => ({
          name: place.name,
          formatted_address: place.formatted_address,
          latitude: place.geometry?.location.lat,
          longitude: place.geometry?.location.lng,
          place_id: place.place_id,
          rating: place.rating,
          types: place.types,
        }));
    
        return {
          content: [
            {
              type: "text" as const,
              text: formatPlacesToMarkdown(places),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Error searching places: ${
                error instanceof Error ? error.message : String(error)
              }`,
            },
          ],
        };
      }
    }
  • Zod schema for input validation of the places-search tool: required 'query' string, optional 'location' string (lat,lng), and 'radius' number.
    export const placesSearchSchema = z.object({
      query: z.string().describe("The search query"),
      location: z
        .string()
        .optional()
        .describe("Bias results around this location (e.g., 'lat,lng')"),
      radius: z.number().optional().describe("Search radius in meters"),
    });
  • src/index.ts:80-87 (registration)
    Tool registration in the MCP server, using the placesSearch handler and placesSearchSchema from maps.ts.
    server.tool(
      "places-search",
      "Search for places using text query",
      placesSearchSchema.shape,
      async (params) => {
        return await placesSearch(params);
      }
    );
  • Helper function used by placesSearch to format search results into a Markdown list with details like name, address, rating, location, and place ID.
    function formatPlacesToMarkdown(places: any[]): string {
      if (!places.length) return "No places found.";
      
      let markdown = `# Places Search Results (${places.length})\n\n`;
      
      places.forEach((place, index) => {
        markdown += `## ${index + 1}. ${place.name}\n`;
        markdown += `Address: ${place.formatted_address}  \n`;
        if (place.rating) {
          markdown += `Rating: ${place.rating}⭐  \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.place_id) {
          markdown += `Place ID: \`${place.place_id}\`  \n`;
        }
        markdown += `\n`;
      });
      
      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?

No annotations are provided, so the description carries full burden for behavioral disclosure. 'Search for places' implies a read-only operation, but the description doesn't disclose rate limits, authentication requirements, result format, pagination behavior, or any other behavioral traits. It provides minimal context beyond the basic operation.

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 extremely concise at just 6 words, front-loaded with the core purpose, and contains zero wasted words. Every element ('Search', 'places', 'using text query') contributes essential information about the tool's function.

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?

For a search tool with 3 parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what constitutes a 'place', what fields are returned, how results are ranked, or any limitations. The agent would need to guess about the tool's behavior and output format.

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%, so the schema already documents all three parameters thoroughly. The description doesn't add any parameter semantics beyond what's in the schema - it mentions 'text query' which aligns with the 'query' parameter but provides no additional context about parameter interactions or usage patterns.

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 tool's purpose as 'Search for places using text query', which specifies the verb ('search'), resource ('places'), and method ('text query'). It distinguishes from some siblings like 'geocode' or 'place-details', but doesn't explicitly differentiate from 'airports-search' which is also a places search tool.

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. There's no mention of when to use 'places-search' versus 'airports-search', 'geocode', 'place-details', or other location-related tools. The agent must infer usage from the tool name alone.

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