Skip to main content
Glama

places-search

Search for locations using text queries, with optional geographic filtering by location and radius parameters.

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

  • Main handler function that performs text search using Google Maps API, formats results into markdown using formatPlacesToMarkdown, and returns structured 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 defining input parameters for the places-search tool: query (required), location and radius (optional).
    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)
    Registration of the 'places-search' tool on the MCP server, linking to the handler and schema.
    server.tool(
      "places-search",
      "Search for places using text query",
      placesSearchSchema.shape,
      async (params) => {
        return await placesSearch(params);
      }
    );
  • Helper function to format the places search results into a markdown string for output.
    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;
    }
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.

Install Server

Other 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/CaptainCrouton89/maps-mcp'

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