Skip to main content
Glama
Mike25app

scaleforge-mcp-meta-ads

pause_campaigns_batch

Pause multiple Meta ad campaigns in bulk using a single Batch API call. Supports up to 50 campaign IDs per request; larger arrays are automatically chunked with a 2-second delay to avoid rate limits.

Instructions

WRITE (BULK): Pause many campaigns in a single Meta Batch API call (up to 50/request; arrays bigger than 50 are chunked automatically with a 2s delay between chunks to sidestep rate-limit code 17). Returns {results: Array<{code, body}>} — one entry per campaign. code: 200 = success.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
campaign_idsYesMeta Campaign IDs to pause

Implementation Reference

  • Handler function that pauses campaigns via Meta Batch API. It deduplicates campaign IDs, builds POST requests with status=PAUSED, sends them via metaBatch(), and returns the count + results.
      handler: async (args) => {
        const ids = Array.from(new Set(args.campaign_ids as string[]));
        const requests: MetaBatchRequest[] = ids.map((id) => ({
          method: "POST",
          relative_url: id,
          body: encodeBatchBody({ status: "PAUSED" }),
        }));
        const results = await metaBatch(requests);
        return { requested: ids.length, results };
      },
    },
  • Input schema for pause_campaigns_batch: requires a non-empty array of campaign ID strings.
    inputSchema: {
      campaign_ids: z
        .array(z.string())
        .min(1)
        .describe("Meta Campaign IDs to pause"),
    },
  • Tool definition entry with name 'pause_campaigns_batch' exported in the bulkTools array, which is imported and registered in both src/index.ts (line 55) and src/http.ts (line 38).
    {
      name: "pause_campaigns_batch",
  • Helper function that encodes the {status: 'PAUSED'} body into URL-encoded format for Meta's Batch API.
    function encodeBatchBody(obj: Record<string, unknown>): string {
      const p = new URLSearchParams();
      for (const [k, v] of Object.entries(obj)) {
        if (v === undefined || v === null) continue;
        if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") {
          p.append(k, String(v));
        } else {
          p.append(k, JSON.stringify(v));
        }
      }
      return p.toString();
    }
  • The metaBatch() function that executes batch requests in chunks of 50 with a 2s delay between chunks (rate-limit sidestep). This is the actual API caller used by the handler.
    export async function metaBatch(
      requests: MetaBatchRequest[],
    ): Promise<MetaBatchResponse[]> {
      const CHUNK = 50;
      const results: MetaBatchResponse[] = [];
      for (let i = 0; i < requests.length; i += CHUNK) {
        const slice = requests.slice(i, i + CHUNK);
        const form = new URLSearchParams();
        form.append("access_token", getCurrentToken());
        form.append("batch", JSON.stringify(slice));
    
        const res = await fetch(META_API_BASE + "/", {
          method: "POST",
          headers: { "Content-Type": "application/x-www-form-urlencoded" },
          body: form.toString(),
        });
        if (!res.ok) {
          const text = await res.text().catch(() => "");
          throw new Error(enhanceMetaError(res.status, text));
        }
        const chunkResults = (await res.json()) as MetaBatchResponse[];
        results.push(...chunkResults);
    
        // Space chunks out a bit to stay under per-account call-volume thresholds.
        if (i + CHUNK < requests.length) {
          await new Promise((r) => setTimeout(r, 2000));
        }
      }
      return results;
    }
Behavior4/5

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

Discloses key behaviors: WRITE operation, batch API usage, chunking, rate-limit handling, and specific return format. With no annotations, this is strong, though could mention partial failure behavior.

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 dense sentences, front-loaded with primary action and limits. Every word adds value, no filler.

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

Completeness5/5

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

With only one parameter and no output schema, the description covers purpose, behavior, limits, and response structure thoroughly, leaving no obvious gaps.

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?

Parameter 'campaign_ids' is fully described in schema (100% coverage) as 'Meta Campaign IDs to pause'. Description adds no extra meaning beyond what the schema provides, so baseline 3 applies.

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?

Description clearly states the action (pause), resource (campaigns), and scope (bulk batch). The WRITE label and specific verb 'pause' distinguish it from siblings like 'activate_campaigns_batch' and individual update tools.

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?

Provides explicit limits (50/request), automatic chunking, and 2s delay to avoid rate limits. While it doesn't directly compare to alternatives, the batch context and sibling names imply when to use this vs. individual updates.

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/Mike25app/scaleforge-mcp-meta-ads'

If you have feedback or need assistance with the MCP directory API, please join our Discord server