Skip to main content
Glama

add_users_to_audience

Add hashed user data to a Meta custom audience. Provide audience ID and JSON payload with schema array and data rows of SHA-256 hashed values.

Instructions

Add users to a custom audience. Payload must be a JSON string containing hashed user data with a schema array defining the data types (e.g. EMAIL, PHONE, FN, LN).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
audience_idYesAudience ID
payloadYesJSON string: {schema: ['EMAIL','PHONE',...], data: [['hash1','hash2',...], ...]}. All PII must be SHA-256 hashed.

Implementation Reference

  • The 'add_users_to_audience' tool handler: registers an MCP tool that accepts audience_id and a JSON payload, then POSTs to /{audience_id}/users to add users to a custom audience.
    // ─── add_users_to_audience ─────────────────────────────────
    server.tool(
      "add_users_to_audience",
      "Add users to a custom audience. Payload must be a JSON string containing hashed user data with a schema array defining the data types (e.g. EMAIL, PHONE, FN, LN).",
      {
        audience_id: z.string().describe("Audience ID"),
        payload: z.string().describe("JSON string: {schema: ['EMAIL','PHONE',...], data: [['hash1','hash2',...], ...]}. All PII must be SHA-256 hashed."),
      },
      async ({ audience_id, payload }) => {
        try {
          const { data, rateLimit } = await client.post(`/${audience_id}/users`, { payload });
          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 add_users_to_audience: audience_id (string) and payload (JSON string with schema + data).
    {
      audience_id: z.string().describe("Audience ID"),
      payload: z.string().describe("JSON string: {schema: ['EMAIL','PHONE',...], data: [['hash1','hash2',...], ...]}. All PII must be SHA-256 hashed."),
  • Tool registration via server.tool() call within the registerAudienceTools function.
    // ─── add_users_to_audience ─────────────────────────────────
    server.tool(
      "add_users_to_audience",
      "Add users to a custom audience. Payload must be a JSON string containing hashed user data with a schema array defining the data types (e.g. EMAIL, PHONE, FN, LN).",
      {
        audience_id: z.string().describe("Audience ID"),
        payload: z.string().describe("JSON string: {schema: ['EMAIL','PHONE',...], data: [['hash1','hash2',...], ...]}. All PII must be SHA-256 hashed."),
      },
      async ({ audience_id, payload }) => {
        try {
          const { data, rateLimit } = await client.post(`/${audience_id}/users`, { payload });
          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 };
        }
      }
    );
  • src/index.ts:60-61 (registration)
    Registration of all audience tools (including add_users_to_audience) in the main server setup.
    // --- Audience & Targeting ---
    registerAudienceTools(server, client);
  • The registerAudienceTools helper function that encapsulates all audience tool registrations.
    export function registerAudienceTools(server: McpServer, client: AdsClient): void {
      // ─── list_custom_audiences ─────────────────────────────────
Behavior3/5

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

With no annotations, the description must disclose behavioral traits. It mentions the payload must be a JSON string and that all PII must be SHA-256 hashed, which is helpful. However, it does not specify whether users are appended or replaced, any rate limits, or the response format.

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 concise, consisting of two sentences with no redundant words. It front-loads the action and then specifies the payload requirement. Could be slightly more structured but is efficient.

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 tool's simplicity (2 parameters, no output schema), the description covers the essential usage but lacks details on behavioral aspects like batch limits, duplicate handling, or confirmation. It is minimally complete but not comprehensive.

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?

The input schema provides descriptions for both parameters (100% coverage). The description adds that the payload must be a JSON string and that PII must be hashed, but this information is already in the schema's description field. Thus, the description adds minimal value 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 action ('Add users') and the target resource ('a custom audience'). It distinguishes the tool from siblings like 'remove_users_from_audience' and 'create_custom_audience' by specifying the operation.

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 for adding users to an existing custom audience. It does not explicitly state prerequisites (e.g., audience must exist) or when not to use it, but the context is fairly clear given the tool name.

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