list_ad_accounts
Discover Meta Ad Accounts accessible with your access token. Returns account IDs, names, status, currency, and spend cap. Use to identify which accounts you can manage.
Instructions
List Meta Ad Accounts accessible to the current access token. Returns id (act_XXX), name, account_status, currency, business_name, spend_cap, timezone_name. Use this first to discover what you can work with.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Max accounts per page (Meta caps ~500, default 100) | |
| after | No | Cursor for next page (from previous response's paging.cursors.after) |
Implementation Reference
- src/tools/accounts.ts:17-44 (handler)The full ToolDef array entry for 'list_ad_accounts' including the handler function that calls metaGet('/me/adaccounts', {...}) to list Meta Ad Accounts accessible to the current access token.
export const accountTools: ToolDef[] = [ { name: "list_ad_accounts", description: "List Meta Ad Accounts accessible to the current access token. Returns id (act_XXX), " + "name, account_status, currency, business_name, spend_cap, timezone_name. " + "Use this first to discover what you can work with.", inputSchema: { limit: z .number() .int() .positive() .max(500) .optional() .describe("Max accounts per page (Meta caps ~500, default 100)"), after: z .string() .optional() .describe("Cursor for next page (from previous response's paging.cursors.after)"), }, handler: async (args) => metaGet("/me/adaccounts", { fields: "id,name,account_status,currency,business_name,spend_cap,timezone_name", limit: args.limit ?? 100, after: args.after, }), }, - src/tools/accounts.ts:24-35 (schema)Input schema for 'list_ad_accounts' defining optional 'limit' (number, max 500) and 'after' (cursor string for pagination) parameters via Zod.
inputSchema: { limit: z .number() .int() .positive() .max(500) .optional() .describe("Max accounts per page (Meta caps ~500, default 100)"), after: z .string() .optional() .describe("Cursor for next page (from previous response's paging.cursors.after)"), - src/index.ts:47-58 (registration)Tools are collected from all modules (including accountTools) into allTools, then registered via server.registerTool() in the loop at lines 65-90.
const allTools: ToolDef[] = [ ...accountTools, ...campaignTools, ...adsetTools, ...adTools, ...creativeTools, ...mediaTools, ...insightsTools, ...bulkTools, ...pageTools, ...adsLibraryTools, ]; - src/client.ts:144-160 (helper)The metaGet helper function that builds the URL, appends the access token, executes the GET request to the Meta Graph API, and parses the JSON response.
export async function metaGet<T = unknown>( path: string, params: Record<string, unknown> = {}, ): Promise<T> { const qs = buildQuery(params); qs.append("access_token", getCurrentToken()); const url = `${META_API_BASE}${normalizePath(path)}?${qs.toString()}`; const res = await fetch(url, { method: "GET" }); 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/accounts.ts:37-43 (helper)The actual handler implementation: calls metaGet('/me/adaccounts') with fields, limit (default 100), and optional after cursor for pagination.
handler: async (args) => metaGet("/me/adaccounts", { fields: "id,name,account_status,currency,business_name,spend_cap,timezone_name", limit: args.limit ?? 100, after: args.after, }),