Skip to main content
Glama

get_adset_leads

Fetch leads generated by a specific ad set using its ID. Supports pagination and custom field selection.

Instructions

Get leads generated by a specific ad set. Requires leads_retrieval permission.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
adset_idYesAd set ID
fieldsNoComma-separated fields to return
limitNoNumber of results (default 25)
afterNoPagination cursor for next page

Implementation Reference

  • The async handler function that executes the 'get_adset_leads' tool logic. It receives adset_id, optional fields, limit (default 25), and pagination cursor 'after', then calls client.get('/{adset_id}/leads') to fetch leads for the ad set.
    async ({ adset_id, fields, limit, after }) => {
      try {
        const params: Record<string, unknown> = {};
        if (fields) params.fields = fields;
        if (limit) params.limit = limit;
        if (after) params.after = after;
        const { data, rateLimit } = await client.get(`/${adset_id}/leads`, 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/type definitions for the 'get_adset_leads' tool, defining parameters: adset_id (required string), fields (optional string), limit (optional number, default 25), after (optional string for pagination).
    {
      adset_id: z.string().describe("Ad set ID"),
      fields: z.string().optional().describe("Comma-separated fields to return"),
      limit: z.number().optional().default(25).describe("Number of results (default 25)"),
      after: z.string().optional().describe("Pagination cursor for next page"),
    },
  • Registration of the 'get_adset_leads' tool via server.tool() call inside registerAdsetTools(), with description 'Get leads generated by a specific ad set. Requires leads_retrieval permission.'
    // ─── get_adset_leads ───────────────────────────────────────
    server.tool(
      "get_adset_leads",
      "Get leads generated by a specific ad set. Requires leads_retrieval permission.",
      {
        adset_id: z.string().describe("Ad set ID"),
        fields: z.string().optional().describe("Comma-separated fields to return"),
        limit: z.number().optional().default(25).describe("Number of results (default 25)"),
        after: z.string().optional().describe("Pagination cursor for next page"),
      },
      async ({ adset_id, fields, limit, after }) => {
        try {
          const params: Record<string, unknown> = {};
          if (fields) params.fields = fields;
          if (limit) params.limit = limit;
          if (after) params.after = after;
          const { data, rateLimit } = await client.get(`/${adset_id}/leads`, 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 };
        }
      }
    );
  • The function signature that wraps all adset tool registrations: export function registerAdsetTools(server: McpServer, client: AdsClient).
    export function registerAdsetTools(server: McpServer, client: AdsClient): void {
  • src/index.ts:51-51 (registration)
    Top-level registration call invoking registerAdsetTools(server, client) to register all adset tools including 'get_adset_leads'.
    registerAdsetTools(server, client);
Behavior2/5

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

With no annotations, the description carries full burden. It discloses the permission requirement, but does not mention that the tool is read-only, the return structure, pagination behavior, or any side effects. Minimal behavioral context.

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 extremely concise: two sentences, no fluff. First sentence defines purpose, second provides permission requirement. Every word earns its place.

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

Completeness2/5

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

No output schema is provided, so the description should explain what is returned. It does not describe the output format, fields, or pagination details. The permission note is helpful but insufficient for a complete understanding.

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 baseline is 3. The description adds no additional meaning beyond the schema (e.g., does not explain adset_id format or pagination cursor usage).

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 'Get' and the resource 'leads generated by a specific ad set'. It distinguishes from sibling tools like get_campaign_leads and get_form_leads by specifying 'ad set'.

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?

The description only mentions the permission requirement but provides no guidance on when to use this tool versus alternatives (e.g., get_campaign_leads or get_form_leads). No explicit when-to-use or when-not-to-use.

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