Skip to main content
Glama
johnoconnor0

Google Ads MCP Server

by johnoconnor0

google_ads_search_impression_share

Get search impression share metrics to measure ad visibility in auctions. Filter by campaign and date range to analyze competitive performance.

Instructions

Get search impression share metrics showing visibility in auctions.

Args: customer_id: Customer ID (without hyphens) campaign_id: Optional campaign ID filter date_range: Date range

Returns: Impression share data

Example: google_ads_search_impression_share( customer_id="1234567890", date_range="LAST_30_DAYS" )

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
customer_idYes
campaign_idNo
date_rangeNoLAST_30_DAYS

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool handler for 'google_ads_search_impression_share'. This is the @mcp.tool()-decorated function that receives a customer_id, campaign_id (optional), and date_range, calls the ReportingManager to get impression share data, formats the output as a markdown report, and returns it as a string.
    @mcp.tool()
    def google_ads_search_impression_share(
        customer_id: str,
        campaign_id: Optional[str] = None,
        date_range: str = "LAST_30_DAYS"
    ) -> str:
        """
        Get search impression share metrics showing visibility in auctions.
    
        Args:
            customer_id: Customer ID (without hyphens)
            campaign_id: Optional campaign ID filter
            date_range: Date range
    
        Returns:
            Impression share data
    
        Example:
            google_ads_search_impression_share(
                customer_id="1234567890",
                date_range="LAST_30_DAYS"
            )
        """
        with performance_logger.track_operation('search_impression_share', customer_id=customer_id):
            try:
                client = get_auth_manager().get_client()
                reporting_manager = ReportingManager(client)
    
                result = reporting_manager.get_search_impression_share(
                    customer_id, campaign_id, date_range
                )
    
                # Audit log
                audit_logger.log_api_call(
                    customer_id=customer_id,
                    operation="search_impression_share",
                    resource_type="campaign",
                    action="read",
                    result="success"
                )
    
                output = f"# Search Impression Share Report\n\n"
                output += f"**Period**: {date_range}\n\n"
    
                for camp in result['campaigns']:
                    output += f"## {camp['campaign_name']}\n\n"
                    output += f"**Campaign ID**: {camp['campaign_id']}\n\n"
    
                    output += f"### Impression Share Metrics\n\n"
                    output += f"- **Overall IS**: {camp['impression_share'] * 100:.1f}%\n"
                    output += f"- **Exact Match IS**: {camp['exact_match_is'] * 100:.1f}%\n"
                    output += f"- **Top of Page IS**: {camp['top_is'] * 100:.1f}%\n"
                    output += f"- **Absolute Top IS**: {camp['absolute_top_is'] * 100:.1f}%\n\n"
    
                    output += f"### Lost Impression Share\n\n"
                    output += f"- **Lost to Rank**: {camp['rank_lost_is'] * 100:.1f}%\n"
                    output += f"- **Lost to Budget**: {camp['budget_lost_is'] * 100:.1f}%\n\n"
    
                    total_lost = camp['rank_lost_is'] + camp['budget_lost_is']
                    if total_lost > 0.3:
                        output += f"⚠️ **Missing {total_lost * 100:.0f}% of eligible impressions**\n\n"
                        if camp['budget_lost_is'] > camp['rank_lost_is']:
                            output += f"**Primary Issue**: Budget - Increase daily budget to capture more traffic\n\n"
                        else:
                            output += f"**Primary Issue**: Rank - Increase bids or improve Quality Score\n\n"
    
                return output
    
            except Exception as e:
                error_msg = ErrorHandler.handle_error(e, context="search_impression_share")
                return f"❌ Failed to get impression share: {error_msg}"
  • The registration function 'register_reporting_tools(mcp)' that uses @mcp.tool() decorator to register 'google_ads_search_impression_share' as an MCP tool.
    def register_reporting_tools(mcp):
        """Register all reporting tools with the MCP server.
    
        Args:
            mcp: FastMCP server instance
        """
    
        @mcp.tool()
  • The 'get_search_impression_share' method in ReportingManager that executes the GAQL query to fetch impression share metrics (search_impression_share, search_rank_lost_impression_share, search_budget_lost_impression_share, search_exact_match_impression_share, search_top_impression_share, search_absolute_top_impression_share) from the Google Ads API and returns campaign-level data.
    def get_search_impression_share(
        self,
        customer_id: str,
        campaign_id: Optional[str] = None,
        date_range: str = "LAST_30_DAYS"
    ) -> Dict[str, Any]:
        """Get search impression share metrics.
    
        Args:
            customer_id: Customer ID (without hyphens)
            campaign_id: Optional campaign ID filter
            date_range: Date range
    
        Returns:
            Impression share data
        """
        ga_service = self.client.get_service("GoogleAdsService")
    
        query = f"""
            SELECT
                campaign.id,
                campaign.name,
                metrics.impressions,
                metrics.search_impression_share,
                metrics.search_rank_lost_impression_share,
                metrics.search_budget_lost_impression_share,
                metrics.search_exact_match_impression_share,
                metrics.search_top_impression_share,
                metrics.search_absolute_top_impression_share
            FROM campaign
            WHERE segments.date DURING {date_range}
        """
    
        if campaign_id:
            query += f" AND campaign.id = {campaign_id}"
    
        response = ga_service.search(customer_id=customer_id, query=query)
    
        campaigns = []
        for row in response:
            campaigns.append({
                'campaign_id': str(row.campaign.id),
                'campaign_name': row.campaign.name,
                'impressions': row.metrics.impressions,
                'impression_share': row.metrics.search_impression_share,
                'rank_lost_is': row.metrics.search_rank_lost_impression_share,
                'budget_lost_is': row.metrics.search_budget_lost_impression_share,
                'exact_match_is': row.metrics.search_exact_match_impression_share,
                'top_is': row.metrics.search_top_impression_share,
                'absolute_top_is': row.metrics.search_absolute_top_impression_share
            })
    
        return {'campaigns': campaigns}
  • The function signature with parameter types: customer_id (str), campaign_id (Optional[str]), date_range (str). These serve as the input schema for the tool.
    def google_ads_search_impression_share(
        customer_id: str,
        campaign_id: Optional[str] = None,
        date_range: str = "LAST_30_DAYS"
    ) -> str:
Behavior3/5

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

No annotations are provided, so the description must convey behavior. It states it retrieves impression share metrics but lacks details on side effects, permissions, or specific return format. The presence of output schema partially compensates.

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 with a clear structure: brief intro, Args, Returns, Example. Every section is necessary and well-organized.

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 read tool with an output schema (though not shown), the description covers the key aspects. It could specify the exact metrics, but the output schema likely handles that.

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

Parameters4/5

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

Schema coverage is 0%, so the description compensates by explaining parameters: customer_id (without hyphens), campaign_id (optional filter), date_range (date range). This adds meaningful context beyond the schema titles.

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 uses a specific verb 'Get' and resource 'search impression share metrics' clearly stating the tool's function. It is distinct from siblings like google_ads_campaign_performance which focus on other metrics.

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 does not explicitly state when to use this tool versus alternatives. While the example implies usage, it lacks guidance on when not to use or mention of other tools for similar purposes.

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