gads_list_accounts
List all accessible Google Ads customer accounts and retrieve customer IDs for account management and reporting.
Instructions
List all Google Ads customer accounts the authenticated user has access to. Useful for finding customer IDs.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/accounts.ts:6-15 (handler)Main handler for gads_list_accounts. Calls listAccessibleCustomers() to get resource names, then returns them mapped to customer IDs.
export async function listAccounts(_args: Record<string, never>) { const resourceNames = await listAccessibleCustomers(); return { count: resourceNames.length, accounts: resourceNames.map((rn) => ({ resource_name: rn, customer_id: rn.replace("customers/", ""), })), }; } - src/tools/accounts.ts:4-4 (schema)Schema for listAccounts — empty object since the tool takes no arguments.
export const listAccountsSchema = {}; - src/index.ts:64-69 (registration)Registration of gads_list_accounts tool on the MCP server with description, schema, and handler.
server.tool( "gads_list_accounts", "List all Google Ads customer accounts the authenticated user has access to. Useful for finding customer IDs.", listAccountsSchema, async (args) => { try { return ok(await listAccounts(args)); } catch (e) { return err(e); } } ); - src/client.ts:33-37 (helper)Helper function listAccessibleCustomers() that calls the Google Ads API to list all accessible customer accounts.
export function listAccessibleCustomers(): Promise<string[]> { const refresh_token = process.env.GOOGLE_ADS_REFRESH_TOKEN; if (!refresh_token) throw new GoogleAdsError("GOOGLE_ADS_REFRESH_TOKEN is not set"); return getApi().listAccessibleCustomers(refresh_token).then((r) => r.resource_names ?? []); }