update_ad_account
Modify ad account name, timezone, or spend cap by providing only the fields to change.
Instructions
Update the configured ad account settings. Only provided fields will be modified.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | New account name | |
| timezone_name | No | New timezone (e.g. 'America/New_York') | |
| spend_cap | No | Account spend cap in currency cents (e.g. '100000' = $1000.00) |
Implementation Reference
- src/tools/account.ts:57-69 (handler)The async handler function that executes the update_ad_account tool logic. It collects optional parameters (name, timezone_name, spend_cap) and sends a POST request to the Meta Ads API using client.accountPath.
async ({ name, timezone_name, spend_cap }) => { try { const params: Record<string, unknown> = {}; if (name) params.name = name; if (timezone_name) params.timezone_name = timezone_name; if (spend_cap) params.spend_cap = spend_cap; const { data, rateLimit } = await client.post(`${client.accountPath}`, 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 }; } } ); - src/tools/account.ts:52-56 (schema)Input schema for update_ad_account using Zod: name (optional string), timezone_name (optional string), spend_cap (optional string).
{ name: z.string().optional().describe("New account name"), timezone_name: z.string().optional().describe("New timezone (e.g. 'America/New_York')"), spend_cap: z.string().optional().describe("Account spend cap in currency cents (e.g. '100000' = $1000.00)"), }, - src/tools/account.ts:49-69 (registration)Registration of the 'update_ad_account' tool on the MCP server via server.tool(), including its description and schema.
server.tool( "update_ad_account", "Update the configured ad account settings. Only provided fields will be modified.", { name: z.string().optional().describe("New account name"), timezone_name: z.string().optional().describe("New timezone (e.g. 'America/New_York')"), spend_cap: z.string().optional().describe("Account spend cap in currency cents (e.g. '100000' = $1000.00)"), }, async ({ name, timezone_name, spend_cap }) => { try { const params: Record<string, unknown> = {}; if (name) params.name = name; if (timezone_name) params.timezone_name = timezone_name; if (spend_cap) params.spend_cap = spend_cap; const { data, rateLimit } = await client.post(`${client.accountPath}`, 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 }; } } ); - src/services/ads-client.ts:187-192 (helper)The AdsClient.post() method used by the handler to send the POST request to the Meta API.
async post( path: string, params?: Record<string, unknown> ): Promise<ClientResponse> { return this.request("POST", path, params); } - src/services/ads-client.ts:213-215 (helper)The accountPath getter that constructs the API path as /act_{accountId}, used by the handler for the POST request.
get accountPath(): string { return `/act_${this.accountId}`; }