Skip to main content
Glama

get_targeting_suggestions

Generates targeting suggestions such as interests, behaviors, and demographics based on your current ad targeting criteria to expand your audience reach.

Instructions

Get targeting suggestions based on existing targeting criteria. Meta suggests related interests, behaviors, and demographics.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targeting_listYesJSON string of current targeting criteria to get suggestions for

Implementation Reference

  • The handler function for get_targeting_suggestions tool. Sends a GET request to the Meta API's targetingsuggestions endpoint with the provided targeting_list, then returns the response data (with rate limit info) as formatted JSON. On failure, returns an error message.
    // ─── get_targeting_suggestions ─────────────────────────────
    server.tool(
      "get_targeting_suggestions",
      "Get targeting suggestions based on existing targeting criteria. Meta suggests related interests, behaviors, and demographics.",
      {
        targeting_list: z.string().describe("JSON string of current targeting criteria to get suggestions for"),
      },
      async ({ targeting_list }) => {
        try {
          const { data, rateLimit } = await client.get(`${client.accountPath}/targetingsuggestions`, { targeting_list });
          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 };
        }
      }
    );
  • Input schema for get_targeting_suggestions. Expects a single required parameter: targeting_list (string) - a JSON string of current targeting criteria.
    {
      targeting_list: z.string().describe("JSON string of current targeting criteria to get suggestions for"),
  • src/index.ts:61-62 (registration)
    Registration of the registerTargetingTools function which registers all targeting tools (including get_targeting_suggestions) on the MCP server.
    registerAudienceTools(server, client);
    registerTargetingTools(server, client);
  • The registerTargetingTools function wraps all targeting tool registrations, including get_targeting_suggestions, onto the MCP server.
    export function registerTargetingTools(server: McpServer, client: AdsClient): void {
      // ─── search_targeting ──────────────────────────────────────
      server.tool(
        "search_targeting",
        "Search for targeting options (interests, behaviors, demographics, etc.) by keyword. Use this to find valid targeting IDs for ad set targeting specs.",
        {
          q: z.string().describe("Search query (e.g. 'fitness', 'technology', 'cooking')"),
          type: z.string().optional().describe("Targeting type filter: adinterest, adgeolocation, adeducationschool, adeducationmajor, adworkemployer, adworkposition, adlocale, etc."),
          limit: z.number().optional().default(25).describe("Number of results (default 25)"),
        },
        async ({ q, type, limit }) => {
          try {
            const params: Record<string, unknown> = { q };
            if (type) params.type = type;
            if (limit) params.limit = limit;
            const { data, rateLimit } = await client.get(`${client.accountPath}/targetingsearch`, 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 };
          }
        }
      );
    
      // ─── search_locations ──────────────────────────────────────
      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 };
          }
        }
      );
    
      // ─── search_targeting_map ──────────────────────────────────
      server.tool(
        "search_targeting_map",
        "Map targeting IDs to their full details (names, types, paths). Useful for resolving IDs obtained from other endpoints.",
        {
          targeting_list: z.string().describe("JSON array of targeting IDs to look up"),
        },
        async ({ targeting_list }) => {
          try {
            const { data, rateLimit } = await client.get(`${client.accountPath}/targetingsearchmap`, { targeting_list });
            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 };
          }
        }
      );
    
      // ─── get_reach_estimate ────────────────────────────────────
      server.tool(
        "get_reach_estimate",
        "Get estimated audience reach for a given targeting specification. Useful for planning campaigns before creating them.",
        {
          targeting_spec: z.string().describe("JSON string of targeting spec (same format as ad set targeting)"),
        },
        async ({ targeting_spec }) => {
          try {
            const { data, rateLimit } = await client.get(`${client.accountPath}/reachestimate`, { targeting_spec });
            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 };
          }
        }
      );
    
      // ─── get_targeting_suggestions ─────────────────────────────
      server.tool(
        "get_targeting_suggestions",
        "Get targeting suggestions based on existing targeting criteria. Meta suggests related interests, behaviors, and demographics.",
        {
          targeting_list: z.string().describe("JSON string of current targeting criteria to get suggestions for"),
        },
        async ({ targeting_list }) => {
          try {
            const { data, rateLimit } = await client.get(`${client.accountPath}/targetingsuggestions`, { targeting_list });
            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 };
          }
        }
      );
    }
  • Reference to get_targeting_suggestions in the audience_builder prompt, instructing the AI to use it to discover related targeting options.
    "2. Use get_targeting_suggestions to discover related targeting options I might have missed",
    "3. Use get_reach_estimate to check the audience size for the combined targeting",

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.2.0

TDQS

A4/5.0
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses that the tool returns related interests, behaviors, and demographics, but does not mention whether the operation is read-only, any error handling, or rate limits. This is adequate but leaves gaps.

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 two short sentences with no extraneous information. It front-loads the action and adds one clarifying detail about the output.

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

Completeness4/5

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

With no output schema and no annotations, the description gives a reasonable overview but does not specify return format or limitations. However, for a single-parameter tool, it covers the essentials.

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 the baseline is 3. The description's phrase 'based on existing targeting criteria' reinforces the targeting_list parameter's purpose but adds no new detail beyond the schema description.

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 a specific action ('Get') with a specific resource ('targeting suggestions') and clarifies the basis ('existing targeting criteria'). It mentions the types of suggestions (interests, behaviors, demographics), distinguishing it from general search tools like search_targeting.

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

Usage Guidelines4/5

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

The description implies usage when you have existing targeting criteria and want related suggestions. It does not explicitly exclude alternatives or mention when not to use, but the context is clear.

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

Deploy Server

Other Tools