update_campaign
Update a Meta Ads campaign's mutable fields including name, status, daily/lifetime budget, and bid strategy. Pass only the fields you need to change.
Instructions
WRITE: Update any mutable field on a campaign (name, status, daily_budget, lifetime_budget, bid_strategy). Pass only the fields you want to change.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| campaign_id | Yes | ||
| name | No | ||
| status | No | ||
| daily_budget | No | ||
| lifetime_budget | No | ||
| bid_strategy | No | ||
| special_ad_categories | No |
Implementation Reference
- src/tools/campaigns.ts:144-147 (handler)The handler destructures campaign_id from args and sends a POST request to the Meta Graph API with the remaining fields as the body, updating the campaign.
handler: async (args) => { const { campaign_id, ...rest } = args; return metaPost(`/${String(campaign_id)}`, rest as Record<string, unknown>); }, - src/tools/campaigns.ts:135-143 (schema)Zod schema for the input: campaign_id (required string), and optional fields: name, status, daily_budget, lifetime_budget, bid_strategy, special_ad_categories.
inputSchema: { campaign_id: z.string(), name: z.string().optional(), status: STATUS.optional(), daily_budget: z.number().int().positive().optional(), lifetime_budget: z.number().int().positive().optional(), bid_strategy: BID_STRATEGY.optional(), special_ad_categories: z.array(z.string()).optional(), }, - src/index.ts:47-49 (registration)All tool arrays (including campaignTools containing update_campaign) are merged and registered via server.registerTool() in a loop.
const allTools: ToolDef[] = [ ...accountTools, ...campaignTools, - src/client.ts:168-188 (helper)metaPost is the HTTP helper used by update_campaign's handler to POST to the Meta Graph API.
export async function metaPost<T = unknown>( path: string, body: Record<string, unknown> = {}, ): Promise<T> { const form = buildQuery(body); form.append("access_token", getCurrentToken()); const url = `${META_API_BASE}${normalizePath(path)}`; const res = await fetch(url, { 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 raw = await res.text(); if (!raw) return {} as T; return JSON.parse(raw) as T; } - src/tools/types.ts:9-14 (helper)ToolDef type used to define the update_campaign tool object structure.
export interface ToolDef { name: string; description: string; inputSchema: Record<string, ZodTypeAny>; handler: (args: Record<string, unknown>) => Promise<unknown>; }