Skip to main content
Glama

search_locations

Search for countries, regions, cities, and zip codes to use as ad targeting locations. Filter results by location type and limit the number of returns.

Instructions

Search for geographic locations (countries, regions, cities, zip codes) for ad targeting.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYesSearch query (e.g. 'New York', 'California', 'United States')
location_typesNoComma-separated location types: country, region, city, zip, geo_market, electoral_district
limitNoNumber of results (default 25)

Implementation Reference

  • The handler function for the 'search_locations' tool. It accepts 'q' (search query), optional 'location_types', and optional 'limit', then calls the Meta API endpoint '/search' with type 'adgeolocation' to find geographic locations for ad targeting. Returns the results with rate limit info.
    server.tool(
      "search_locations",
      "Search for geographic locations (countries, regions, cities, zip codes) for ad targeting.",
      {
        q: z.string().describe("Search query (e.g. 'New York', 'California', 'United States')"),
        location_types: z.string().optional().describe("Comma-separated location types: country, region, city, zip, geo_market, electoral_district"),
        limit: z.number().optional().default(25).describe("Number of results (default 25)"),
      },
      async ({ q, location_types, limit }) => {
        try {
          const params: Record<string, unknown> = { q, type: "adgeolocation" };
          if (location_types) params.location_types = location_types;
          if (limit) params.limit = limit;
          const { data, rateLimit } = await client.get(`/search`, params);
          return { content: [{ type: "text" as const, text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] };
        } catch (error) {
          return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
        }
      }
    );
  • Zod schema definitions for the 'search_locations' tool inputs: 'q' (string, required), 'location_types' (string, optional, comma-separated types), 'limit' (number, optional, default 25).
    {
      q: z.string().describe("Search query (e.g. 'New York', 'California', 'United States')"),
      location_types: z.string().optional().describe("Comma-separated location types: country, region, city, zip, geo_market, electoral_district"),
      limit: z.number().optional().default(25).describe("Number of results (default 25)"),
    },
  • Registration of the 'search_locations' tool via server.tool() inside registerTargetingTools(). Also the function registerTargetingTools is exported and called from src/index.ts at line 62.
    server.tool(
      "search_locations",
      "Search for geographic locations (countries, regions, cities, zip codes) for ad targeting.",
      {
        q: z.string().describe("Search query (e.g. 'New York', 'California', 'United States')"),
        location_types: z.string().optional().describe("Comma-separated location types: country, region, city, zip, geo_market, electoral_district"),
Behavior2/5

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

No annotations are provided, and the description does not disclose behavioral traits such as read-only nature, rate limits, authentication requirements, or result handling. This leaves the agent without sufficient safety information.

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 short sentence, efficient and front-loaded. However, it could include more detail without becoming verbose. No waste, but room for improvement.

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?

Given no output schema and no behavioral info, the description is adequate for a simple search tool. It covers basic purpose and parameters, but lacks guidance on pagination, result format, or typical use cases. Missing elements for full context.

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%, and the input schema already describes all parameters clearly. The description adds minimal value, merely listing some location types, but omits 'geo_market' and 'electoral_district' present in the schema. Baseline of 3 is appropriate.

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 verb 'Search', the resource 'geographic locations', and the context 'for ad targeting'. It effectively distinguishes from sibling tools like 'search_targeting' by specifying location types.

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

Usage Guidelines3/5

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

The description implies usage for ad targeting but does not provide explicit guidance on when to use this tool versus alternatives like 'search_targeting' or 'search_targeting_map'. No exclusions or prerequisites are mentioned.

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/mikusnuz/meta-ads-mcp'

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