Skip to main content
Glama

maps_search

Search Google Maps for businesses by type and location. Returns each business with a Lead Quality Score (0–100) and outreach hints to prioritize prospects.

Instructions

Search Google Maps businesses by type and location. Returns each business with a Lead Quality Score (0–100) and outreach hints.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesBusiness type or search query, e.g. 'coffee shops'
locationYesCity or area, e.g. 'Austin TX'
maxNoMax results, up to 60 (default: 20)
google_keyYesYour Google Places API key

Implementation Reference

  • MCP tool registration for 'maps_search' in the ListToolsRequestSchema handler. Defines name, description, and inputSchema (query, location, max, google_key).
    {
      name: "maps_search",
      description:
        "Search Google Maps businesses by type and location. Returns each business with a Lead Quality Score (0–100) and outreach hints.",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "Business type or search query, e.g. 'coffee shops'",
          },
          location: {
            type: "string",
            description: "City or area, e.g. 'Austin TX'",
          },
          max: {
            type: "number",
            description: "Max results, up to 60 (default: 20)",
          },
          google_key: {
            type: "string",
            description: "Your Google Places API key",
          },
        },
        required: ["query", "location", "google_key"],
      },
    },
    {
      name: "maps_leads",
      description:
  • MCP call handler that dispatches 'maps_search' to searchMapsBusinesses function, extracting query, location, max, google_key args.
    case "maps_search": {
      const { query, location, max, google_key } = args as {
        query: string;
        location: string;
        max?: number;
        google_key: string;
      };
      result = await searchMapsBusinesses(query, location, google_key, max);
      break;
  • Type definitions: PlaceBusiness interface and MapsSearchResult interface used as the return type for searchMapsBusinesses.
    export interface PlaceBusiness {
      place_id: string;
      name: string;
      address: string;
      phone: string | null;
      website: string | null;
      rating: number | null;
      user_ratings_total: number | null;
      types: string[];
      lat: number;
      lng: number;
      business_status: string;
      price_level: number | null;
      lead_quality_score: number;
      outreach_hints: string[];
    }
    
    export interface MapsSearchResult {
      query: string;
      location: string;
      total_results: number;
      businesses: PlaceBusiness[];
      searched_at: string;
    }
  • Core handler function 'searchMapsBusinesses' — calls Google Places Text Search API paginated, normalizes results, enriches via Place Details, scores leads, and returns sorted MapsSearchResult.
    export async function searchMapsBusinesses(
      query: string,
      location: string,
      apiKey: string,
      max = 20
    ): Promise<MapsSearchResult> {
      const fullQuery = `${query} ${location}`.trim();
      const clampedMax = Math.min(Math.max(1, max), 60);
    
      const businesses: PlaceBusiness[] = [];
      let pageToken: string | undefined;
    
      while (businesses.length < clampedMax) {
        const { results, next_page_token } = await textSearch(
          fullQuery,
          apiKey,
          pageToken
        );
    
        for (const r of results) {
          if (businesses.length >= clampedMax) break;
          businesses.push(normalizeBusiness(r));
        }
    
        if (!next_page_token || results.length === 0) break;
        pageToken = next_page_token;
    
        // Google requires a short delay before using page token
        await new Promise((r) => setTimeout(r, 2000));
      }
    
      // Enrich top results with place details (phone, website)
      const enrichLimit = Math.min(businesses.length, 10);
      await Promise.allSettled(
        businesses.slice(0, enrichLimit).map(async (b, i) => {
          try {
            const details = await getPlaceDetails(b.place_id, apiKey);
            businesses[i] = normalizeBusiness({ ...b, ...details });
          } catch {
            // Keep partial data on details failure
          }
        })
      );
    
      businesses.sort((a, b) => b.lead_quality_score - a.lead_quality_score);
    
      return {
        query,
        location,
        total_results: businesses.length,
        businesses,
        searched_at: new Date().toISOString(),
      };
    }
  • Helper functions: textSearch (Google Places API), getPlaceDetails (enrichment), calculateLeadQualityScore (0-100 scoring), generateOutreachHints, and normalizeBusiness.
    async function textSearch(
      query: string,
      apiKey: string,
      pageToken?: string
    ): Promise<{ results: unknown[]; next_page_token?: string }> {
      const params = new URLSearchParams({
        query,
        key: apiKey,
        ...(pageToken && { pagetoken: pageToken }),
      });
    
      const res = await fetch(`${PLACES_BASE}/textsearch/json?${params}`);
      if (!res.ok) {
        throw new Error(`Google Places API error: HTTP ${res.status}`);
      }
    
      const data = (await res.json()) as {
        status: string;
        error_message?: string;
        results: unknown[];
        next_page_token?: string;
      };
    
      if (data.status !== "OK" && data.status !== "ZERO_RESULTS") {
        throw new Error(
          `Google Places API status: ${data.status}${data.error_message ? ` — ${data.error_message}` : ""}`
        );
      }
    
      return { results: data.results ?? [], next_page_token: data.next_page_token };
    }
    
    async function getPlaceDetails(
      placeId: string,
      apiKey: string
    ): Promise<Record<string, unknown>> {
      const params = new URLSearchParams({
        place_id: placeId,
        fields:
          "name,formatted_address,formatted_phone_number,website,rating,user_ratings_total,types,geometry,business_status,price_level",
        key: apiKey,
      });
    
      const res = await fetch(`${PLACES_BASE}/details/json?${params}`);
      if (!res.ok) {
        throw new Error(`Google Places Details API error: HTTP ${res.status}`);
      }
    
      const data = (await res.json()) as {
        status: string;
        result?: Record<string, unknown>;
      };
    
      if (data.status !== "OK") {
        throw new Error(`Google Places Details API status: ${data.status}`);
      }
    
      return data.result ?? {};
    }
Behavior2/5

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

With no annotations, the description should disclose behavioral traits, but it only mentions output features (Lead Quality Score, outreach hints) and not side effects, rate limits, or authentication requirements beyond what is in the schema.

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

Conciseness4/5

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

The description is a single, direct sentence with no fluff. However, it could be slightly more structured by separating the action from the output description.

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

Completeness3/5

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

The description covers the basic purpose and output, but lacks details on pagination, errors, or the full structure of returned data. Given no output schema, more context on the response format would be helpful.

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 coverage is 100%, so parameters are documented. The description adds value by explaining the output, which aids understanding of why parameters matter, but does not add new parameter-level meaning beyond the schema.

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

Purpose5/5

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

The description clearly states the tool searches Google Maps businesses by type and location and returns a Lead Quality Score and outreach hints, making the purpose very specific and distinguishable from siblings like maps_leads.

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?

No guidance on when to use this tool versus alternatives (e.g., maps_leads) is provided. The description lacks any context about appropriate use cases or when not to use it.

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/samrothschild23/intelligence-api'

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