Skip to main content
Glama

list_campaigns

Retrieve ad campaigns from your Meta ad account with optional filters for status and objective. Supports pagination for large result sets.

Instructions

List campaigns in the ad account. Supports filtering by status and objective. Returns paginated results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
statusNoFilter by status: ACTIVE, PAUSED, DELETED, ARCHIVED
objectiveNoFilter by objective: OUTCOME_AWARENESS, OUTCOME_ENGAGEMENT, OUTCOME_LEADS, OUTCOME_SALES, OUTCOME_TRAFFIC, OUTCOME_APP_PROMOTION
fieldsNoComma-separated fields to return
limitNoNumber of results (default 25)
afterNoPagination cursor for next page
beforeNoPagination cursor for previous page

Implementation Reference

  • The handler/function that executes the 'list_campaigns' tool logic. It calls the Facebook Marketing API GET /act_{accountId}/campaigns with optional filters (status, objective, fields, limit, pagination cursors) and returns the paginated response.
    // ─── list_campaigns ────────────────────────────────────────
    server.tool(
      "list_campaigns",
      "List campaigns in the ad account. Supports filtering by status and objective. Returns paginated results.",
      {
        status: z.string().optional().describe("Filter by status: ACTIVE, PAUSED, DELETED, ARCHIVED"),
        objective: z.string().optional().describe("Filter by objective: OUTCOME_AWARENESS, OUTCOME_ENGAGEMENT, OUTCOME_LEADS, OUTCOME_SALES, OUTCOME_TRAFFIC, OUTCOME_APP_PROMOTION"),
        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"),
        before: z.string().optional().describe("Pagination cursor for previous page"),
      },
      async ({ status, objective, fields, limit, after, before }) => {
        try {
          const params: Record<string, unknown> = {};
          if (fields) params.fields = fields;
          if (limit) params.limit = limit;
          if (after) params.after = after;
          if (before) params.before = before;
          if (status) params.effective_status = `["${status}"]`;
          if (objective) params.objective = objective;
          const { data, rateLimit } = await client.get(`${client.accountPath}/campaigns`, 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 for the 'list_campaigns' tool, defined using Zod. Parameters: status (optional string), objective (optional string), fields (optional string), limit (optional number, default 25), after (optional string for pagination cursor), before (optional string for pagination cursor).
    "List campaigns in the ad account. Supports filtering by status and objective. Returns paginated results.",
    {
      status: z.string().optional().describe("Filter by status: ACTIVE, PAUSED, DELETED, ARCHIVED"),
      objective: z.string().optional().describe("Filter by objective: OUTCOME_AWARENESS, OUTCOME_ENGAGEMENT, OUTCOME_LEADS, OUTCOME_SALES, OUTCOME_TRAFFIC, OUTCOME_APP_PROMOTION"),
      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"),
      before: z.string().optional().describe("Pagination cursor for previous page"),
    },
  • src/index.ts:49-50 (registration)
    Registration of the campaign tools (including 'list_campaigns') via the registerCampaignTools(server, client) call.
    // --- Campaign Management ---
    registerCampaignTools(server, client);
  • The tool is registered on the MCP server via server.tool('list_campaigns', ...) in the registerCampaignTools function.
    server.tool(
      "list_campaigns",
      "List campaigns in the ad account. Supports filtering by status and objective. Returns paginated results.",
      {
        status: z.string().optional().describe("Filter by status: ACTIVE, PAUSED, DELETED, ARCHIVED"),
        objective: z.string().optional().describe("Filter by objective: OUTCOME_AWARENESS, OUTCOME_ENGAGEMENT, OUTCOME_LEADS, OUTCOME_SALES, OUTCOME_TRAFFIC, OUTCOME_APP_PROMOTION"),
        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"),
        before: z.string().optional().describe("Pagination cursor for previous page"),
      },
      async ({ status, objective, fields, limit, after, before }) => {
        try {
          const params: Record<string, unknown> = {};
          if (fields) params.fields = fields;
          if (limit) params.limit = limit;
          if (after) params.after = after;
          if (before) params.before = before;
          if (status) params.effective_status = `["${status}"]`;
          if (objective) params.objective = objective;
          const { data, rateLimit } = await client.get(`${client.accountPath}/campaigns`, 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 accountPath getter in AdsClient returns '/act_{accountId}', used to construct the API endpoint URL for listing campaigns.
    get accountPath(): string {
      return `/act_${this.accountId}`;
    }
    
    get accountId(): string {
      if (!this.config.adAccountId) {
        throw new Error(
          "META_AD_ACCOUNT_ID is not configured. Set it as an environment variable."
        );
      }
      return this.config.adAccountId;
    }
Behavior3/5

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

No annotations are provided, so the description must bear the burden. It discloses that results are paginated, which is useful. However, it does not mention other behavioral traits such as read-only nature or rate limits.

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?

Two sentences, no redundant words. The first sentence identifies the main action, and the second adds key features. Extremely concise yet informative.

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?

Given the lack of annotations and output schema, the description covers the essential aspects: listing, filtering, pagination. It is reasonably complete for a list tool, though default fields and ordering are not mentioned.

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 description adds little beyond what the schema already provides. Filtering by status and objective is mentioned, but the schema descriptions already convey those choices.

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 lists campaigns in the ad account, using a specific verb and resource. It distinguishes from siblings like get_campaign or create_campaign without needing to name them explicitly.

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?

The description mentions filtering capabilities (status, objective) and pagination, implying when to use filters. However, it does not explicitly state when not to use this tool or provide alternatives like get_campaign or get_campaign_insights.

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