Skip to main content
Glama
Mike25app

scaleforge-mcp-meta-ads

activate_campaigns_batch

Batch activate multiple campaigns with a pre-flight ads volume check per ad account to warn if a Page is over capacity. Requires user confirmation before activation begins spending.

Instructions

WRITE (BULK): Activate many campaigns in one Batch API call. BEFORE activation we run a per-Page ads_volume pre-flight for every distinct ad account — warnings are returned in the response so the agent / user can abort if a Page is over capacity. Agents MUST confirm with the user before calling this (activation starts spend immediately).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
campaign_idsYes
skip_preflightNoSkip the ads_volume check (not recommended)

Implementation Reference

  • The handler function for activate_campaigns_batch. It deduplicates campaign IDs, runs a pre-flight ads_volume check (unless skip_preflight is true) grouped by ad account, then sends batch POST requests to set status=ACTIVE. Returns {requested, preflight, results}.
      handler: async (args) => {
        const ids = Array.from(new Set(args.campaign_ids as string[]));
    
        const preflight: Array<{
          ad_account_id: string;
          campaigns: number;
          warnings: string[];
        }> = [];
    
        if (!args.skip_preflight) {
          const groups = await groupCampaignsByAccount(ids);
          for (const [accountId, campaigns] of groups.entries()) {
            try {
              const { warnings } = await checkAdsVolume(accountId, campaigns.length);
              preflight.push({
                ad_account_id: accountId,
                campaigns: campaigns.length,
                warnings,
              });
            } catch (err) {
              preflight.push({
                ad_account_id: accountId,
                campaigns: campaigns.length,
                warnings: [
                  `Could not fetch ads_volume: ${
                    err instanceof Error ? err.message : String(err)
                  }`,
                ],
              });
            }
          }
        }
    
        const requests: MetaBatchRequest[] = ids.map((id) => ({
          method: "POST",
          relative_url: id,
          body: encodeBatchBody({ status: "ACTIVE" }),
        }));
        const results = await metaBatch(requests);
        return { requested: ids.length, preflight, results };
      },
    },
  • Input schema for activate_campaigns_batch: campaign_ids (array of strings, min 1) and optional skip_preflight boolean.
    inputSchema: {
      campaign_ids: z.array(z.string()).min(1),
      skip_preflight: z
        .boolean()
        .optional()
        .describe("Skip the ads_volume check (not recommended)"),
    },
  • Tool definition object registered in the bulkTools array with name 'activate_campaigns_batch', description, inputSchema, and handler.
    {
      name: "activate_campaigns_batch",
      description:
        "WRITE (BULK): Activate many campaigns in one Batch API call. BEFORE activation we run " +
        "a per-Page ads_volume pre-flight for every distinct ad account — warnings are returned " +
        "in the response so the agent / user can abort if a Page is over capacity. Agents MUST " +
        "confirm with the user before calling this (activation starts spend immediately).",
      inputSchema: {
        campaign_ids: z.array(z.string()).min(1),
        skip_preflight: z
          .boolean()
          .optional()
          .describe("Skip the ads_volume check (not recommended)"),
      },
      handler: async (args) => {
        const ids = Array.from(new Set(args.campaign_ids as string[]));
    
        const preflight: Array<{
          ad_account_id: string;
          campaigns: number;
          warnings: string[];
        }> = [];
    
        if (!args.skip_preflight) {
          const groups = await groupCampaignsByAccount(ids);
          for (const [accountId, campaigns] of groups.entries()) {
            try {
              const { warnings } = await checkAdsVolume(accountId, campaigns.length);
              preflight.push({
                ad_account_id: accountId,
                campaigns: campaigns.length,
                warnings,
              });
            } catch (err) {
              preflight.push({
                ad_account_id: accountId,
                campaigns: campaigns.length,
                warnings: [
                  `Could not fetch ads_volume: ${
                    err instanceof Error ? err.message : String(err)
                  }`,
                ],
              });
            }
          }
        }
    
        const requests: MetaBatchRequest[] = ids.map((id) => ({
          method: "POST",
          relative_url: id,
          body: encodeBatchBody({ status: "ACTIVE" }),
        }));
        const results = await metaBatch(requests);
        return { requested: ids.length, preflight, results };
      },
    },
  • src/index.ts:65-90 (registration)
    The tool is registered on the MCP server via server.registerTool() in the registration loop that iterates allToolDefs (which includes bulkTools).
    for (const tool of allTools) {
      server.registerTool(
        tool.name,
        {
          description: tool.description,
          inputSchema: tool.inputSchema,
        },
        // The SDK's ToolCallback type infers the arg shape from inputSchema, but
        // our shared ToolDef uses a generic Record<string, unknown> signature for
        // portability. The cast here is intentional and isolated to the bridge.
        async (args: unknown) => {
          try {
            const result = await tool.handler(args as Record<string, unknown>);
            return {
              content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }],
            };
          } catch (err) {
            const message = err instanceof Error ? err.message : String(err);
            return {
              content: [{ type: "text" as const, text: `Error: ${message}` }],
              isError: true,
            };
          }
        },
      );
    }
  • groupCampaignsByAccount helper fetches each campaign's account_id in parallel to group campaigns by ad account for pre-flight ads_volume checks.
    async function groupCampaignsByAccount(
      campaign_ids: string[],
    ): Promise<Map<string, string[]>> {
      const groups = new Map<string, string[]>();
      const lookups = await Promise.all(
        campaign_ids.map(async (id) => {
          try {
            const camp = await metaGet<{ account_id?: string }>(`/${id}`, {
              fields: "account_id",
            });
            return { id, account_id: camp.account_id };
          } catch {
            return { id, account_id: undefined };
          }
        }),
      );
      for (const { id, account_id } of lookups) {
        if (!account_id) continue;
        const key = account_id.startsWith("act_") ? account_id : `act_${account_id}`;
        const list = groups.get(key) ?? [];
        list.push(id);
        groups.set(key, list);
      }
      return groups;
    }
Behavior4/5

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

With no annotations provided, the description fully discloses behavior: it is a WRITE (BULK) operation, runs a pre-flight ads_volume check, returns warnings, and starts spend immediately. This is adequate transparency for safe usage.

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 three sentences, each serving a purpose: purpose, behavioral detail, and usage guideline. No unnecessary words, and the most important information is front-loaded.

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 no output schema and no annotations, the description covers the key aspects: what it does, the pre-flight check, warnings, and user confirmation. It could mention response format or error handling, but it is sufficient for a batch tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description explains the skip_preflight parameter and the pre-flight process, adding context beyond the schema. The campaign_ids parameter is implied to be the list of campaigns to activate. Schema description coverage is 50%, but the description compensates well.

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 starts with 'Activate many campaigns in one Batch API call,' which is a specific verb+resource+mode. It clearly distinguishes from siblings like 'pause_campaigns_batch' and individual 'update_campaign'.

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?

It explicitly states 'Agents MUST confirm with the user before calling this (activation starts spend immediately).' This provides clear when-to-use guidance. However, it does not mention when not to use or suggest alternative tools like individual activation.

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