Skip to main content
Glama
johnoconnor0

Google Ads MCP Server

by johnoconnor0

google_ads_get_recommendation_history

Retrieve history of applied and dismissed Google Ads recommendations, including who made each change, over a specified date range.

Instructions

Get history of applied and dismissed recommendations.

This shows what recommendations were applied or dismissed in a given time period, along with who made the changes.

Args: customer_id: Customer ID (without hyphens) start_date: Start date (YYYY-MM-DD) end_date: End date (YYYY-MM-DD)

Returns: Recommendation change history

Example: google_ads_get_recommendation_history( customer_id="1234567890", start_date="2025-11-01", end_date="2025-12-16" )

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
customer_idYes
start_dateYes
end_dateYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The @mcp.tool() decorated handler function for google_ads_get_recommendation_history. Calls AutomationManager.get_recommendation_history() and formats the response with change event details (date, user, client, resource, action).
    @mcp.tool()
    def google_ads_get_recommendation_history(
        customer_id: str,
        start_date: str,
        end_date: str
    ) -> str:
        """
        Get history of applied and dismissed recommendations.
    
        This shows what recommendations were applied or dismissed in a given time period,
        along with who made the changes.
    
        Args:
            customer_id: Customer ID (without hyphens)
            start_date: Start date (YYYY-MM-DD)
            end_date: End date (YYYY-MM-DD)
    
        Returns:
            Recommendation change history
    
        Example:
            google_ads_get_recommendation_history(
                customer_id="1234567890",
                start_date="2025-11-01",
                end_date="2025-12-16"
            )
        """
        with performance_logger.track_operation('get_recommendation_history', customer_id=customer_id):
            try:
                client = get_auth_manager().get_client()
                automation_manager = AutomationManager(client)
    
                history = automation_manager.get_recommendation_history(
                    customer_id,
                    start_date,
                    end_date
                )
    
                # Audit log
                audit_logger.log_api_call(
                    customer_id=customer_id,
                    operation="get_recommendation_history",
                    resource_type="recommendation",
                    action="read",
                    result="success",
                    details={'count': len(history)}
                )
    
                if not history:
                    return f"No recommendation changes found between {start_date} and {end_date}."
    
                # Format response
                output = f"# Recommendation Change History\n\n"
                output += f"**Period**: {start_date} to {end_date}\n"
                output += f"**Total Changes**: {len(history)}\n\n"
    
                for i, event in enumerate(history, 1):
                    output += f"## {i}. {event['date_time']}\n\n"
                    output += f"- **User**: {event['user_email']}\n"
                    output += f"- **Client**: {event['client_type']}\n"
                    output += f"- **Resource**: {event['resource_name']}\n"
    
                    if event['old_type']:
                        output += f"- **Action**: Removed {event['old_type']} recommendation\n"
                    elif event['new_type']:
                        output += f"- **Action**: Applied {event['new_type']} recommendation\n"
    
                    output += "\n"
    
                return output
    
            except Exception as e:
                error_msg = ErrorHandler.handle_error(e, context="get_recommendation_history")
                return f"❌ Failed to get recommendation history: {error_msg}"
  • The AutomationManager.get_recommendation_history() helper method. Executes a GAQL query against the Google Ads API's change_event resource filtered by RECOMMENDATION type and date range, returning a list of history entries with details like user_email, client_type, old_type, and new_type.
    def get_recommendation_history(
        self,
        customer_id: str,
        start_date: str,
        end_date: str
    ) -> List[Dict[str, Any]]:
        """Get history of applied/dismissed recommendations.
    
        Args:
            customer_id: Customer ID (without hyphens)
            start_date: Start date (YYYY-MM-DD)
            end_date: End date (YYYY-MM-DD)
    
        Returns:
            List of recommendation history entries
        """
        ga_service = self.client.get_service("GoogleAdsService")
    
        query = f"""
            SELECT
                change_event.resource_name,
                change_event.change_date_time,
                change_event.change_resource_name,
                change_event.change_resource_type,
                change_event.user_email,
                change_event.client_type,
                change_event.old_resource.recommendation.type,
                change_event.new_resource.recommendation.type
            FROM change_event
            WHERE change_event.change_resource_type = 'RECOMMENDATION'
            AND change_event.change_date_time >= '{start_date}'
            AND change_event.change_date_time <= '{end_date}'
            ORDER BY change_event.change_date_time DESC
        """
    
        response = ga_service.search(customer_id=customer_id, query=query)
    
        history = []
        for row in response:
            event = row.change_event
    
            history.append({
                'date_time': event.change_date_time,
                'resource_name': event.change_resource_name,
                'resource_type': event.change_resource_type.name,
                'user_email': event.user_email,
                'client_type': event.client_type.name,
                'old_type': event.old_resource.recommendation.type.name if event.old_resource.recommendation else None,
                'new_type': event.new_resource.recommendation.type.name if event.new_resource.recommendation else None
            })
    
        return history
  • The registration entry for the automation module. The tuple ("automation", "tools.automation.mcp_tools_automation", "register_automation_tools") causes the tool to be loaded and registered with the MCP server.
    _TOOL_MODULES = [
        ("campaigns",     "tools.campaigns.mcp_tools_campaigns",         "register_campaign_tools"),
        ("ad_groups",     "tools.ad_groups.mcp_tools_ad_groups",         "register_ad_group_tools"),
        ("keywords",      "tools.keywords.mcp_tools_keywords",           "register_keyword_tools"),
        ("ads",           "tools.ads.mcp_tools_ads",                     "register_ad_tools"),
        ("bidding",       "tools.bidding.mcp_tools_bidding",             "register_bidding_tools"),
        ("automation",    "tools.automation.mcp_tools_automation",       "register_automation_tools"),
        ("audiences",     "tools.audiences.mcp_tools_audiences",         "register_audience_tools"),
        ("conversions",   "tools.conversions.mcp_tools_conversions",     "register_conversion_tools"),
        ("reporting",     "tools.reporting.mcp_tools_reporting",         "register_reporting_tools"),
        ("insights",      "tools.insights.mcp_tools_insights",           "register_insights_tools"),
        ("batch",         "tools.batch.mcp_tools_batch",                 "register_batch_tools"),
        ("shopping_pmax", "tools.shopping_pmax.mcp_tools_shopping_pmax", "register_shopping_pmax_tools"),
        ("extensions",    "tools.extensions.mcp_tools_extensions",       "register_extension_tools"),
        ("local_app",     "tools.local_app.mcp_tools_local_app",         "register_local_app_tools"),
    ]
  • The register_automation_tools() function that is called to register all automation tools, including google_ads_get_recommendation_history via the @mcp.tool() decorator.
    def register_automation_tools(mcp):
        """Register all automation and optimization tools with the MCP server.
    
        Args:
            mcp: FastMCP server instance
        """
Behavior3/5

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

With no annotations, the description must cover behavioral traits. It mentions the output includes who made changes, which is helpful, but does not disclose permissions required, data retention, or potential pagination. It is adequate but not comprehensive.

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: a clear purpose sentence, parameter details in docstring style, and an example. Every sentence is relevant and there is no wasted text.

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?

Given the presence of an output schema, the description adequately explains inputs and mentions the output includes who made changes. It does not cover limitations like time range or data freshness, but overall it is sufficiently complete for a simple retrieval tool.

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 must compensate. It provides explicit format instructions (customer_id without hyphens, dates in YYYY-MM-DD) and an example, adding significant value 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 clearly states the tool retrieves the history of applied and dismissed recommendations. It specifies the resource (recommendation history) and the verb (get), distinguishing it from siblings like apply_recommendation or dismiss_recommendation.

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 implies usage for viewing history but does not explicitly state when to use this tool versus alternatives such as get_recommendations or apply_recommendation. No when-not or alternative guidance is provided.

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