gads_list_campaigns
List Google Ads campaigns with name, status, channel type, bidding strategy, and date range. Filter by status (default ENABLED) and limit results.
Instructions
List campaigns in the account with name, status, channel type, bidding strategy, and date range. Filter by status (default ENABLED).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| status | No | Filter by campaign status | ENABLED |
| customer_id | No | ||
| limit | No |
Implementation Reference
- src/index.ts:80-85 (registration)Registration of the gads_list_campaigns tool on the MCP server, linking the name to its schema and handler.
server.tool( "gads_list_campaigns", "List campaigns in the account with name, status, channel type, bidding strategy, and date range. Filter by status (default ENABLED).", listCampaignsSchema, async (args) => { try { return ok(await listCampaigns(args)); } catch (e) { return err(e); } } ); - src/tools/campaigns.ts:16-20 (schema)Zod schema for listCampaigns: status filter (default ENABLED), optional customer_id override, and limit (default 100).
export const listCampaignsSchema = { status: z.enum(["ENABLED", "PAUSED", "REMOVED", "ALL"]).default("ENABLED").describe("Filter by campaign status"), customer_id: z.string().optional(), limit: z.number().int().positive().max(10000).default(100), }; - src/tools/campaigns.ts:22-41 (handler)Handler that executes a GAQL query against the Google Ads API to list campaigns with their id, name, status, channel type, bidding strategy, and dates.
export async function listCampaigns(args: z.infer<z.ZodObject<typeof listCampaignsSchema>>) { const customer = getCustomer(args.customer_id); const statusClause = args.status === "ALL" ? "" : `WHERE campaign.status = '${args.status}'`; const rows = await customer.query(` SELECT campaign.id, campaign.name, campaign.status, campaign.advertising_channel_type, campaign.advertising_channel_sub_type, campaign.bidding_strategy_type, campaign.start_date, campaign.end_date FROM campaign ${statusClause} ORDER BY campaign.name LIMIT ${args.limit} `); return { rowCount: rows.length, rows }; } - src/client.ts:24-31 (helper)getCustomer helper that initializes the Google Ads API client with credentials and returns a Customer instance used by the handler to run queries.
export function getCustomer(override?: string): Customer { const refresh_token = process.env.GOOGLE_ADS_REFRESH_TOKEN; if (!refresh_token) throw new GoogleAdsError("GOOGLE_ADS_REFRESH_TOKEN is not set"); const customer_id = (override ?? process.env.GOOGLE_ADS_CUSTOMER_ID ?? "").replace(/-/g, ""); if (!customer_id) throw new GoogleAdsError("GOOGLE_ADS_CUSTOMER_ID is not set and no customer_id was passed"); const login_customer_id = process.env.GOOGLE_ADS_LOGIN_CUSTOMER_ID?.replace(/-/g, "") || undefined; return getApi().Customer({ customer_id, login_customer_id, refresh_token }); }