Skip to main content
Glama

list_adsets

Retrieve ad sets from your ad account with optional filters by campaign ID or status. Use pagination to control results.

Instructions

List ad sets in the ad account. Optionally filter by campaign or status.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
campaign_idNoFilter by campaign ID
statusNoFilter by status: ACTIVE, PAUSED, DELETED, ARCHIVED
fieldsNoComma-separated fields to return
limitNoNumber of results (default 25)
afterNoPagination cursor for next page

Implementation Reference

  • The async handler function for the list_adsets tool. It builds query params (campaign_id, status, fields, limit, after), calls client.get() on the /adsets endpoint, and returns the data as JSON text content.
    async ({ campaign_id, status, fields, limit, after }) => {
      try {
        const params: Record<string, unknown> = {};
        if (fields) params.fields = fields;
        if (limit) params.limit = limit;
        if (after) params.after = after;
        if (campaign_id) params.campaign_id = campaign_id;
        if (status) params.effective_status = `["${status}"]`;
        const { data, rateLimit } = await client.get(`${client.accountPath}/adsets`, 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 list_adsets input parameters: campaign_id (optional string), status (optional string), fields (optional string), limit (optional number, default 25), after (optional string for pagination).
    {
      campaign_id: z.string().optional().describe("Filter by campaign ID"),
      status: z.string().optional().describe("Filter by status: ACTIVE, PAUSED, DELETED, ARCHIVED"),
      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"),
    },
  • src/index.ts:51-51 (registration)
    Registration call: registerAdsetTools(server, client) which registers the list_adsets tool on the MCP server.
    registerAdsetTools(server, client);
  • The registerAdsetTools function that calls server.tool() with name 'list_adsets', description, schema, and handler.
    export function registerAdsetTools(server: McpServer, client: AdsClient): void {
      // ─── list_adsets ───────────────────────────────────────────
      server.tool(
        "list_adsets",
        "List ad sets in the ad account. Optionally filter by campaign or status.",
        {
          campaign_id: z.string().optional().describe("Filter by campaign ID"),
          status: z.string().optional().describe("Filter by status: ACTIVE, PAUSED, DELETED, ARCHIVED"),
          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 ({ campaign_id, status, fields, limit, after }) => {
          try {
            const params: Record<string, unknown> = {};
            if (fields) params.fields = fields;
            if (limit) params.limit = limit;
            if (after) params.after = after;
            if (campaign_id) params.campaign_id = campaign_id;
            if (status) params.effective_status = `["${status}"]`;
            const { data, rateLimit } = await client.get(`${client.accountPath}/adsets`, 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 AdsClient.get() method used by the handler to make the GET request to the Meta Ads API.
    async get(
      path: string,
      params?: Record<string, unknown>
    ): Promise<ClientResponse> {
      return this.request("GET", path, params);
    }
Behavior2/5

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

No annotations provided. Description lacks mention of pagination behavior (even though 'after' param exists), default limit, or output format. Minimal disclosure beyond basic listing.

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?

A single, clear sentence that efficiently conveys purpose and optional filters. No waste, but could be slightly more structured.

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?

Adequate for a simple list operation with no required parameters, but lacks details on pagination, result structure, and error handling which would be helpful for an AI agent.

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?

Input schema has 100% coverage with descriptions. Description adds that filtering by campaign or status is optional, but adds little extra meaning beyond the schema itself.

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?

Clearly states the action 'List' and the resource 'ad sets', and mentions optional filters. Distinguishes from sibling tools like get_adset or list_campaigns by specifying the resource.

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?

Description implies use for listing ad sets with optional filters, but does not specify when to use this vs alternatives like get_adset for a single ad set, or provide exclusions or prerequisites.

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