Skip to main content
Glama
johnoconnor0

Google Ads MCP Server

by johnoconnor0

google_ads_search_terms

View actual search queries that triggered your ads to identify new keyword opportunities and negative keyword candidates.

Instructions

View actual search queries that triggered your ads.

Shows the search terms report with performance metrics to identify new keyword opportunities and negative keyword candidates.

Args: customer_id: Customer ID without hyphens campaign_id: Optional campaign ID to filter date_range: Date range for the report limit: Maximum number of search terms to return response_format: Output format: 'markdown' or 'json'

Returns: Search terms with performance metrics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
customer_idYes
campaign_idNo
date_rangeNoLAST_30_DAYS
limitNo
response_formatNomarkdown

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'google_ads_search_terms' tool. Executes a GAQL query on 'search_term_view' to retrieve actual search queries that triggered ads, with optional campaign_id filtering, and returns results as markdown or JSON.
    def google_ads_search_terms(
        customer_id: str,
        campaign_id: Optional[str] = None,
        date_range: str = "LAST_30_DAYS",
        limit: int = 100,
        response_format: str = "markdown",
    ) -> str:
        """
        View actual search queries that triggered your ads.
    
        Shows the search terms report with performance metrics to identify
        new keyword opportunities and negative keyword candidates.
    
        Args:
            customer_id: Customer ID without hyphens
            campaign_id: Optional campaign ID to filter
            date_range: Date range for the report
            limit: Maximum number of search terms to return
            response_format: Output format: 'markdown' or 'json'
    
        Returns:
            Search terms with performance metrics
        """
        try:
            client = get_auth_manager().get_client()
            ga_service = client.get_service("GoogleAdsService")
            clean_id = customer_id.replace("-", "")
    
            query = (
                "SELECT campaign.name, ad_group.name, "
                "search_term_view.search_term, search_term_view.status, "
                "metrics.impressions, metrics.clicks, metrics.cost_micros, "
                "metrics.conversions "
                f"FROM search_term_view WHERE segments.date DURING {date_range}"
            )
    
            if campaign_id:
                query += f" AND campaign.id = {campaign_id}"
    
            query += f" ORDER BY metrics.impressions DESC LIMIT {min(limit, 200)}"
    
            response = ga_service.search(customer_id=clean_id, query=query)
    
            terms = []
            for row in response:
                cost = row.metrics.cost_micros / 1_000_000
                imps = row.metrics.impressions
                clicks = row.metrics.clicks
                ctr = (clicks / imps * 100) if imps > 0 else 0
    
                terms.append({
                    "search_term": row.search_term_view.search_term,
                    "campaign": row.campaign.name,
                    "ad_group": row.ad_group.name,
                    "status": row.search_term_view.status.name,
                    "impressions": imps,
                    "clicks": clicks,
                    "ctr": round(ctr, 2),
                    "cost": round(cost, 2),
                    "conversions": round(row.metrics.conversions, 2),
                })
    
            if response_format == "json":
                return json.dumps(terms, indent=2)
    
            out = f"# Search Terms Report ({date_range})\n\n"
            out += f"**Total terms**: {len(terms)}\n\n"
            out += "| Search Term | Campaign | Impr | Clicks | CTR | Cost | Conv | Status |\n"
            out += "|-------------|----------|------|--------|-----|------|------|--------|\n"
            for t in terms:
                out += (
                    f"| {t['search_term'][:40]} | {t['campaign'][:20]} "
                    f"| {t['impressions']:,} | {t['clicks']:,} | {t['ctr']}% "
                    f"| ${t['cost']:.2f} | {t['conversions']:.1f} | {t['status']} |\n"
                )
            return out
    
        except Exception as exc:
            return f"❌ Search terms query failed: {exc}"
  • Function signature and docstring defining the input parameters/schema: customer_id (str), campaign_id (Optional[str]), date_range (str, default LAST_30_DAYS), limit (int, default 100), response_format (str, default markdown).
    def google_ads_search_terms(
        customer_id: str,
        campaign_id: Optional[str] = None,
        date_range: str = "LAST_30_DAYS",
        limit: int = 100,
        response_format: str = "markdown",
    ) -> str:
  • The tool is registered via the @mcp.tool() decorator on line 328, which is part of the FastMCP framework.
    @mcp.tool()
Behavior2/5

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

With no annotations provided, the description carries the full burden of disclosing behavioral traits. While 'view' implies a read-only operation, there is no explicit statement about safety, required permissions, or rate limits. The description does not mention potential side effects or authorization needs, which is a significant gap.

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 concise and well-structured, with a clear purpose statement followed by an easy-to-scan Args section and a Returns note. Every sentence contributes meaning, and there is no redundancy or fluff.

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

Completeness3/5

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

Given the tool's complexity (5 parameters, output schema present) and the abundance of sibling tools, the description covers the basics but lacks details on the specific performance metrics returned. The output schema exists, so the return values are partially covered, but the description does not mention query scope (e.g., account-level vs campaign-level) or historical limitations, leaving some gaps for a well-informed agent.

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 description coverage is 0%, so the description must compensate. It provides brief explanations for each parameter (e.g., 'Customer ID without hyphens' for customer_id, 'Optional campaign ID to filter' for campaign_id). These add value beyond the schema titles, but lack details like valid date range formats or allowable values. Overall, it offers moderate additional meaning.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'View actual search queries that triggered your ads' and explains it shows the search terms report with performance metrics for identifying keyword opportunities and negatives. The verb 'view' and specific resource are well-defined, though it does not differentiate from similar sibling tools like google_ads_get_search_terms_for_keyword.

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

Usage Guidelines2/5

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

The description mentions identifying keyword opportunities and negative keyword candidates as use cases, but provides no guidance on when to use this tool versus alternatives (e.g., google_ads_get_keyword_performance, google_ads_campaign_performance). There is no comparison or exclusion criteria, leaving the agent to infer usage context.

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/johnoconnor0/google-ads-mcp'

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