gads_list_budgets
List all Google Ads campaign budgets, showing daily/total amount, delivery method (STANDARD/ACCELERATED), period, and whether a recommended budget exists.
Instructions
All campaign budgets with daily/total amount, delivery method (STANDARD/ACCELERATED), period, and whether a recommended budget exists.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| customer_id | No | Override GOOGLE_ADS_CUSTOMER_ID for this call |
Implementation Reference
- src/tools/budget.ts:13-42 (handler)The main handler function for gads_list_budgets. It queries Google Ads API for enabled campaign budgets, enriches the results with dollar amounts (converted from micros), and returns the row count and rows.
export async function listBudgets(args: z.infer<z.ZodObject<typeof listBudgetsSchema>>) { const customer = getCustomer(args.customer_id); const rows = await customer.query(` SELECT campaign_budget.id, campaign_budget.name, campaign_budget.amount_micros, campaign_budget.delivery_method, campaign_budget.period, campaign_budget.status, campaign_budget.type, campaign_budget.total_amount_micros, campaign_budget.reference_count, campaign_budget.has_recommended_budget, campaign_budget.recommended_budget_amount_micros FROM campaign_budget WHERE campaign_budget.status = 'ENABLED' ORDER BY campaign_budget.amount_micros DESC LIMIT 200 `); const enriched = rows.map((r: any) => ({ ...r, campaign_budget: { ...r.campaign_budget, amount_dollars: microsToDollars(r.campaign_budget?.amount_micros), recommended_budget_dollars: microsToDollars(r.campaign_budget?.recommended_budget_amount_micros), }, })); return { rowCount: enriched.length, rows: enriched }; } - src/tools/budget.ts:9-11 (schema)Input schema for gads_list_budgets. Accepts an optional customer_id to override the default GOOGLE_ADS_CUSTOMER_ID.
export const listBudgetsSchema = { customer_id: z.string().optional().describe("Override GOOGLE_ADS_CUSTOMER_ID for this call"), }; - src/tools/budget.ts:4-7 (helper)Helper function microsToDollars converts micro-amounts (integer/string) to dollar amounts (divided by 1,000,000).
function microsToDollars(micros: number | string | undefined): number { const n = Number(micros ?? 0); return Number.isFinite(n) ? n / 1_000_000 : 0; } - src/index.ts:213-218 (registration)Registration of the gads_list_budgets tool with the MCP server, binding the name, description, schema, and handler.
server.tool( "gads_list_budgets", "All campaign budgets with daily/total amount, delivery method (STANDARD/ACCELERATED), period, and whether a recommended budget exists.", listBudgetsSchema, async (args) => { try { return ok(await listBudgets(args)); } catch (e) { return err(e); } } );