get_ad_account
Retrieve detailed configuration of a Meta Ads account, including status, spend cap, balance, funding source, business, timezone, and disable reason. Allows deep inspection of a single account via its ID.
Instructions
Get detailed info for a single Ad Account: status, spend cap, balance, funding source, business, timezone, disable_reason. Returns the full configuration record — use this for deep inspection of one account.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ad_account_id | Yes | Ad Account ID — accepts 'act_123456' or just '123456' | |
| fields | No | Comma-separated Meta API field list (overrides default field set) |
Implementation Reference
- src/tools/accounts.ts:61-64 (handler)The handler function that executes the 'get_ad_account' tool logic. It calls metaGet with the ad account ID path and optional/comma-separated fields (defaults to DEFAULT_ACCOUNT_FIELDS).
handler: async (args) => metaGet(`/${toAdAccountPath(String(args.ad_account_id))}`, { fields: args.fields ?? DEFAULT_ACCOUNT_FIELDS, }), - src/tools/accounts.ts:52-60 (schema)Input schema for the 'get_ad_account' tool, defining 'ad_account_id' (required string) and 'fields' (optional string) parameters using Zod.
inputSchema: { ad_account_id: z .string() .describe("Ad Account ID — accepts 'act_123456' or just '123456'"), fields: z .string() .optional() .describe("Comma-separated Meta API field list (overrides default field set)"), }, - src/tools/accounts.ts:14-15 (helper)Default Meta API field set used when no custom fields are provided: id, name, account_status, currency, business_name, business, spend_cap, amount_spent, balance, timezone_name, timezone_offset_hours_utc, disable_reason, funding_source_details.
const DEFAULT_ACCOUNT_FIELDS = "id,name,account_status,currency,business_name,business,spend_cap,amount_spent,balance,timezone_name,timezone_offset_hours_utc,disable_reason,funding_source_details"; - src/tools/accounts.ts:10-11 (helper)Utility function that normalizes ad account IDs by prepending 'act_' if not already present.
function toAdAccountPath(idOrActId: string): string { return idOrActId.startsWith("act_") ? idOrActId : `act_${idOrActId}`; - src/index.ts:65-90 (registration)Registration loop where all tools (including 'get_ad_account' from accountTools) are registered with 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, }; } }, ); }