Skip to main content
Glama
ZLeventer

google-ads-mcp

gads_campaign_performance

Get campaign performance data: impressions, clicks, CTR, cost, conversions, CPA, ROAS. Filter by date range and status, sort by metrics. Defaults to last 28 days for enabled campaigns.

Instructions

Campaign-level performance: impressions, clicks, CTR, avg CPC, cost, conversions, conv value, CPA, ROAS. Defaults to last 28 days, enabled campaigns, sorted by cost desc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateNoStart date: YYYY-MM-DD, NdaysAgo, yesterday, or today28daysAgo
end_dateNoEnd date: YYYY-MM-DD, NdaysAgo, yesterday, or todayyesterday
customer_idNoOverride GOOGLE_ADS_CUSTOMER_ID for this call
limitNoMax rows to return
statusNoENABLED
order_byNoMetric to sort by desc: cost_micros, clicks, impressions, conversions, ctrcost_micros

Implementation Reference

  • src/index.ts:87-92 (registration)
    Registration of the 'gads_campaign_performance' tool with MCP server, linking the schema and handler function.
    server.tool(
      "gads_campaign_performance",
      "Campaign-level performance: impressions, clicks, CTR, avg CPC, cost, conversions, conv value, CPA, ROAS. Defaults to last 28 days, enabled campaigns, sorted by cost desc.",
      campaignPerformanceSchema,
      async (args) => { try { return ok(await campaignPerformance(args)); } catch (e) { return err(e); } }
    );
  • Schema definition for campaignPerformance inputs: dateRange (start_date, end_date, customer_id, limit), status filter, and order_by.
    export const campaignPerformanceSchema = {
      ...dateRange,
      status: z.enum(["ENABLED", "PAUSED", "REMOVED", "ALL"]).default("ENABLED"),
      order_by: z.string().default("cost_micros").describe("Metric to sort by desc: cost_micros, clicks, impressions, conversions, ctr"),
    };
  • Handler function that executes the GAQL query to fetch campaign performance metrics (impressions, clicks, CTR, avg CPC, cost, conversions, conv value, cost per conversion) and enriches results with computed cost in dollars and ROAS.
    export async function campaignPerformance(args: z.infer<z.ZodObject<typeof campaignPerformanceSchema>>) {
      const customer = getCustomer(args.customer_id);
      const start = resolveDate(args.start_date);
      const end = resolveDate(args.end_date);
      const statusClause = args.status === "ALL" ? "" : `AND campaign.status = '${args.status}'`;
      const rows = await customer.query(`
        SELECT
          campaign.id,
          campaign.name,
          campaign.status,
          campaign.advertising_channel_type,
          metrics.impressions,
          metrics.clicks,
          metrics.ctr,
          metrics.average_cpc,
          metrics.cost_micros,
          metrics.conversions,
          metrics.conversions_value,
          metrics.cost_per_conversion
        FROM campaign
        WHERE segments.date BETWEEN '${start}' AND '${end}'
          ${statusClause}
        ORDER BY metrics.${args.order_by} DESC
        LIMIT ${args.limit}
      `);
      const enriched = rows.map((r: any) => ({
        ...r,
        metrics: {
          ...r.metrics,
          cost: microsToDollars(r.metrics?.cost_micros),
          average_cpc_dollars: microsToDollars(r.metrics?.average_cpc),
          roas: r.metrics?.cost_micros
            ? Number(r.metrics.conversions_value ?? 0) / microsToDollars(r.metrics.cost_micros)
            : 0,
        },
      }));
      return { rowCount: enriched.length, rows: enriched };
    }
  • Helper function to convert micros (micro-amounts) to dollars by dividing 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;
    }
  • getCustomer helper that initializes the Google Ads API customer object used by the handler to run GAQL 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 });
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Discloses default filters and sorting but does not mention behavioral traits like pagination, rate limits, or error handling. No annotations are provided, so the description bears full burden but covers only defaults.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is short and front-loaded with the purpose, then lists metrics and defaults. Every sentence earns its place without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 6 parameters and no output schema, the description covers core functionality and defaults adequately. However, it lacks details on return format and potential limitations, leaving some gaps in completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is high (83%), so the description adds minimal value beyond schema. It repeats defaults already in schema but does not explain metric semantics in more depth.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it provides 'Campaign-level performance' and lists specific metrics (impressions, clicks, CTR, avg CPC, cost, conversions, conv value, CPA, ROAS), differentiating it from sibling tools like ad_group_performance or keyword_performance.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions default settings (last 28 days, enabled campaigns, sorted by cost desc) but does not explicitly guide when to use this tool vs alternatives like gads_conversions_by_campaign. Usage is implied but lacks exclusion criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ZLeventer/google-ads-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server