update_adset
Update specified mutable fields on a Meta Ads ad set, such as status, bid amount, daily budget, targeting, or name. Pass only the fields to change.
Instructions
WRITE: Update any mutable field on an ad set (status, bid_amount, daily_budget, targeting, name, etc.). Pass only the fields you want to change.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| adset_id | Yes | ||
| name | No | ||
| status | No | ||
| bid_amount | No | ||
| daily_budget | No | ||
| lifetime_budget | No | ||
| targeting | No | ||
| optimization_goal | No | ||
| billing_event | No | ||
| start_time | No | ||
| end_time | No |
Implementation Reference
- src/tools/adsets.ts:181-184 (handler)The handler function for update_adset. It destructures adset_id from args, and POSTs the remaining fields to `/{adset_id}` via metaPost, sending only the fields to be updated.
handler: async (args) => { const { adset_id, ...rest } = args; return metaPost(`/${String(adset_id)}`, rest as Record<string, unknown>); }, - src/tools/adsets.ts:168-180 (schema)Input schema for update_adset: requires adset_id (string), and accepts optional fields: name, status (enum ACTIVE/PAUSED/DELETED/ARCHIVED), bid_amount, daily_budget, lifetime_budget, targeting, optimization_goal, billing_event, start_time, end_time.
inputSchema: { adset_id: z.string(), name: z.string().optional(), status: STATUS.optional(), bid_amount: z.number().int().positive().optional(), daily_budget: z.number().int().positive().optional(), lifetime_budget: z.number().int().positive().optional(), targeting: z.record(z.unknown()).optional(), optimization_goal: OPTIMIZATION_GOAL.optional(), billing_event: BILLING_EVENT.optional(), start_time: z.string().optional(), end_time: z.string().optional(), }, - src/tools/adsets.ts:163-185 (registration)The tool definition object for update_adset within the adsetTools array, with name 'update_adset', description, inputSchema, and handler.
{ name: "update_adset", description: "WRITE: Update any mutable field on an ad set (status, bid_amount, daily_budget, " + "targeting, name, etc.). Pass only the fields you want to change.", inputSchema: { adset_id: z.string(), name: z.string().optional(), status: STATUS.optional(), bid_amount: z.number().int().positive().optional(), daily_budget: z.number().int().positive().optional(), lifetime_budget: z.number().int().positive().optional(), targeting: z.record(z.unknown()).optional(), optimization_goal: OPTIMIZATION_GOAL.optional(), billing_event: BILLING_EVENT.optional(), start_time: z.string().optional(), end_time: z.string().optional(), }, handler: async (args) => { const { adset_id, ...rest } = args; return metaPost(`/${String(adset_id)}`, rest as Record<string, unknown>); }, }, - src/index.ts:65-90 (registration)Where all tools (including adsetTools which contains update_adset) are registered on the MCP server via server.registerTool().
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, }; } }, ); } - src/client.ts:168-188 (helper)The metaPost helper used by the update_adset handler to POST data 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; }