Skip to main content
Glama
ZLeventer

google-ads-mcp

gads_run_gaql

Run raw GAQL queries to fetch Google Ads data when preset tools lack the required report shape, enabling custom campaign and metric analysis.

Instructions

Escape hatch: run any raw GAQL query against Google Ads. Use when preset tools don't cover the report shape you need. Docs: developers.google.com/google-ads/api/docs/query/overview

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesRaw GAQL query. Example: SELECT campaign.id, campaign.name, metrics.impressions, metrics.clicks, metrics.cost_micros FROM campaign WHERE segments.date DURING LAST_30_DAYS ORDER BY metrics.cost_micros DESC LIMIT 50
customer_idNoOverride GOOGLE_ADS_CUSTOMER_ID for this call (no dashes)

Implementation Reference

  • The core handler function that executes the GAQL query using the Google Ads client and returns rows.
    export async function runGaql(args: z.infer<z.ZodObject<typeof runGaqlSchema>>) {
      const customer = getCustomer(args.customer_id);
      const rows = await customer.query(args.query);
      return { rowCount: rows.length, rows };
    }
  • Zod schema defining the input parameters: 'query' (required string) and 'customer_id' (optional string override).
    export const runGaqlSchema = {
      query: z.string().describe(
        "Raw GAQL query. Example: SELECT campaign.id, campaign.name, metrics.impressions, metrics.clicks, metrics.cost_micros FROM campaign WHERE segments.date DURING LAST_30_DAYS ORDER BY metrics.cost_micros DESC LIMIT 50"
      ),
      customer_id: z.string().optional().describe("Override GOOGLE_ADS_CUSTOMER_ID for this call (no dashes)"),
    };
  • src/index.ts:57-62 (registration)
    Registration of the 'gads_run_gaql' tool on the MCP server with description, schema, and handler callback.
    server.tool(
      "gads_run_gaql",
      "Escape hatch: run any raw GAQL query against Google Ads. Use when preset tools don't cover the report shape you need. Docs: developers.google.com/google-ads/api/docs/query/overview",
      runGaqlSchema,
      async (args) => { try { return ok(await runGaql(args)); } catch (e) { return err(e); } }
    );
  • Imports: zod for validation and getCustomer helper from client to create the Google Ads service.
    import { z } from "zod";
    import { getCustomer } from "../client.js";
Behavior2/5

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

No annotations are provided, so the description carries full burden. It only labels the tool as an 'escape hatch' and includes a link to documentation, but does not disclose behavioral traits like error handling, rate limits, or potential complexity. This is insufficient for a raw query tool.

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?

Extremely concise: two sentences plus a link. Every part is essential. Front-loaded with 'Escape hatch' and purpose, immediately followed by usage guidance and a reference to external documentation.

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

Completeness2/5

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

Given no output schema and no annotations, the description should provide more behavioral and result context. It lacks details on query constraints, output format, or error handling. The brief description is insufficient for an unannotated tool of this nature.

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?

Input schema covers both parameters (query and customer_id) with descriptions, achieving 100% schema coverage. The description adds no additional semantic information beyond what the schema provides, so baseline score of 3 is appropriate.

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?

Explicitly states it runs any raw GAQL query against Google Ads, with clear verb and resource. Differentiates from sibling tools by calling it an 'escape hatch' for when preset tools don't cover the report shape, making its unique purpose clear.

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

Usage Guidelines4/5

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

Provides explicit context: 'Use when preset tools don't cover the report shape you need.' This tells when to use it, but does not specify when not to or list alternative tools by name. The sibling list implies alternatives, but the description could be more explicit.

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