get_ad_account
Retrieve ad account details such as status, balance, currency, timezone, and spend info for the configured account.
Instructions
Get details of the configured ad account including status, balance, currency, timezone, and spend info.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fields | No | Comma-separated fields to return | id,name,account_status,balance,currency,timezone_name,amount_spent,business_name,business_city,business_country_code,owner,min_campaign_group_spend_cap |
Implementation Reference
- src/tools/account.ts:7-23 (handler)Handler function for the 'get_ad_account' tool. Makes a GET request to the Meta Ads API (configured ad account path) with optional fields parameter, and returns the account details along with rate limit info.
server.tool( "get_ad_account", "Get details of the configured ad account including status, balance, currency, timezone, and spend info.", { fields: z.string().optional().default("id,name,account_status,balance,currency,timezone_name,amount_spent,business_name,business_city,business_country_code,owner,min_campaign_group_spend_cap").describe("Comma-separated fields to return"), }, async ({ fields }) => { try { const params: Record<string, unknown> = {}; if (fields) params.fields = fields; const { data, rateLimit } = await client.get(`${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:10-12 (schema)Input schema for 'get_ad_account' tool using Zod. The only parameter is 'fields' (optional string with defaults) describing which comma-separated fields to return.
{ fields: z.string().optional().default("id,name,account_status,balance,currency,timezone_name,amount_spent,business_name,business_city,business_country_code,owner,min_campaign_group_spend_cap").describe("Comma-separated fields to return"), }, - src/tools/account.ts:5-23 (registration)Registration via server.tool() inside registerAccountTools(). Called from src/index.ts line 89 with the MCP server and AdsClient instance.
export function registerAccountTools(server: McpServer, client: AdsClient): void { // ─── get_ad_account ─────────────────────────────────────────── server.tool( "get_ad_account", "Get details of the configured ad account including status, balance, currency, timezone, and spend info.", { fields: z.string().optional().default("id,name,account_status,balance,currency,timezone_name,amount_spent,business_name,business_city,business_country_code,owner,min_campaign_group_spend_cap").describe("Comma-separated fields to return"), }, async ({ fields }) => { try { const params: Record<string, unknown> = {}; if (fields) params.fields = fields; const { data, rateLimit } = await client.get(`${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:213-225 (helper)The accountPath getter (returns `/act_{accountId}`) used by the handler as the API endpoint path, and accountId getter which reads from config.
get accountPath(): string { return `/act_${this.accountId}`; } get accountId(): string { if (!this.config.adAccountId) { throw new Error( "META_AD_ACCOUNT_ID is not configured. Set it as an environment variable." ); } return this.config.adAccountId; } - src/services/ads-client.ts:180-185 (helper)The AdsClient.get() method used by the handler to make the GET request to the Meta Ads API.
async get( path: string, params?: Record<string, unknown> ): Promise<ClientResponse> { return this.request("GET", path, params); }