Skip to main content
Glama

create_custom_audience

Create a custom audience from various sources like website, app, engagement, or customer file. Define audience subtype to specify the data origin.

Instructions

Create a new custom audience. Subtype determines the audience source (CUSTOM, WEBSITE, APP, OFFLINE_CONVERSION, LOOKALIKE, ENGAGEMENT, etc.).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesAudience name
subtypeYesAudience subtype
descriptionNoAudience description
customer_file_sourceNoSource of customer file: USER_PROVIDED_ONLY, PARTNER_PROVIDED_ONLY, BOTH_USER_AND_PARTNER_PROVIDED

Implementation Reference

  • The async handler function that executes the tool logic: builds params from name/subtype/description/customer_file_source, calls POST to /customaudiences, and returns the result.
      async ({ name, subtype, description, customer_file_source }) => {
        try {
          const params: Record<string, unknown> = { name, subtype };
          if (description) params.description = description;
          if (customer_file_source) params.customer_file_source = customer_file_source;
          const { data, rateLimit } = await client.post(`${client.accountPath}/customaudiences`, 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 };
        }
      }
    );
  • Input schema definitions using Zod: name (string, required), subtype (enum of 12 audience subtypes), description (optional string), customer_file_source (optional string).
    {
      name: z.string().describe("Audience name"),
      subtype: z.enum([
        "CUSTOM",
        "WEBSITE",
        "APP",
        "OFFLINE_CONVERSION",
        "CLAIM",
        "PARTNER",
        "MANAGED",
        "VIDEO",
        "LOOKALIKE",
        "ENGAGEMENT",
        "BAG_OF_ACCOUNTS",
        "STUDY_RULE_AUDIENCE",
        "FOX",
      ]).describe("Audience subtype"),
      description: z.string().optional().describe("Audience description"),
      customer_file_source: z.string().optional().describe("Source of customer file: USER_PROVIDED_ONLY, PARTNER_PROVIDED_ONLY, BOTH_USER_AND_PARTNER_PROVIDED"),
    },
  • Registration of the tool on the MCP server using server.tool() with name 'create_custom_audience', description, schema, and handler.
    server.tool(
      "create_custom_audience",
      "Create a new custom audience. Subtype determines the audience source (CUSTOM, WEBSITE, APP, OFFLINE_CONVERSION, LOOKALIKE, ENGAGEMENT, etc.).",
      {
        name: z.string().describe("Audience name"),
        subtype: z.enum([
          "CUSTOM",
          "WEBSITE",
          "APP",
          "OFFLINE_CONVERSION",
          "CLAIM",
          "PARTNER",
          "MANAGED",
          "VIDEO",
          "LOOKALIKE",
          "ENGAGEMENT",
          "BAG_OF_ACCOUNTS",
          "STUDY_RULE_AUDIENCE",
          "FOX",
        ]).describe("Audience subtype"),
        description: z.string().optional().describe("Audience description"),
        customer_file_source: z.string().optional().describe("Source of customer file: USER_PROVIDED_ONLY, PARTNER_PROVIDED_ONLY, BOTH_USER_AND_PARTNER_PROVIDED"),
      },
      async ({ name, subtype, description, customer_file_source }) => {
        try {
          const params: Record<string, unknown> = { name, subtype };
          if (description) params.description = description;
          if (customer_file_source) params.customer_file_source = customer_file_source;
          const { data, rateLimit } = await client.post(`${client.accountPath}/customaudiences`, 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 };
        }
      }
    );
  • Imports and function wrapper: imports zod, McpServer, AdsClient. The registerAudienceTools function registers all audience tools including create_custom_audience.
    import { z } from "zod";
    import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
    import { AdsClient } from "../services/ads-client.js";
    
    export function registerAudienceTools(server: McpServer, client: AdsClient): void {
      // ─── list_custom_audiences ─────────────────────────────────
Behavior2/5

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

No annotations provided, so the description must disclose behavioral traits. It only states the action and mentions subtype, without details on permissions, destructiveness, rate limits, or return values.

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?

Single sentence conveying purpose and a key parameter relationship. Concise, but could benefit from bullet points or structured hints for usage.

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 the complexity of audience types and sibling tools, the description is minimally adequate. It doesn't explain return values or when to use specific subtypes versus dedicated tools like create_lookalike_audience.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema provides complete parameter descriptions (100% coverage). The description adds context that 'subtype determines the audience source', which gives extra meaning beyond the enum list. This adds value.

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 creates a new custom audience and mentions that subtype determines the audience source, which differentiates it from sibling tools like create_lookalike_audience.

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?

No explicit guidance on when to use this tool versus alternatives like create_lookalike_audience or create_offline_event_set. The subtype hint implies some differentiation, but it's not explicit.

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