Skip to main content
Glama
johnoconnor0

Google Ads MCP Server

by johnoconnor0

google_ads_apply_recommendation

Automatically implement a single Google Ads optimization recommendation, including keyword additions, budget adjustments, or bidding strategy changes.

Instructions

Apply a single optimization recommendation.

This will automatically implement the suggested optimization. For example:

  • KEYWORD recommendations will add the keyword to your account

  • CAMPAIGN_BUDGET recommendations will increase the budget

  • Bidding strategy recommendations will change the bidding strategy

Args: customer_id: Customer ID (without hyphens) recommendation_resource_name: Resource name of the recommendation to apply (obtained from google_ads_get_recommendations)

Returns: Success message confirming application

Example: google_ads_apply_recommendation( customer_id="1234567890", recommendation_resource_name="customers/1234567890/recommendations/12345" )

Warning: This will make changes to your account. Review the recommendation details carefully before applying.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
customer_idYes
recommendation_resource_nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool handler function for google_ads_apply_recommendation. It receives customer_id and recommendation_resource_name, calls AutomationManager.apply_recommendation(), logs the operation, invalidates caches, and returns a success/failure message.
    def google_ads_apply_recommendation(
        customer_id: str,
        recommendation_resource_name: str
    ) -> str:
        """
        Apply a single optimization recommendation.
    
        This will automatically implement the suggested optimization. For example:
        - KEYWORD recommendations will add the keyword to your account
        - CAMPAIGN_BUDGET recommendations will increase the budget
        - Bidding strategy recommendations will change the bidding strategy
    
        Args:
            customer_id: Customer ID (without hyphens)
            recommendation_resource_name: Resource name of the recommendation to apply
                (obtained from google_ads_get_recommendations)
    
        Returns:
            Success message confirming application
    
        Example:
            google_ads_apply_recommendation(
                customer_id="1234567890",
                recommendation_resource_name="customers/1234567890/recommendations/12345"
            )
    
        Warning: This will make changes to your account. Review the recommendation
        details carefully before applying.
        """
        with performance_logger.track_operation('apply_recommendation', customer_id=customer_id):
            try:
                client = get_auth_manager().get_client()
                automation_manager = AutomationManager(client)
    
                result = automation_manager.apply_recommendation(
                    customer_id,
                    recommendation_resource_name
                )
    
                # Audit log
                audit_logger.log_api_call(
                    customer_id=customer_id,
                    operation="apply_recommendation",
                    resource_type="recommendation",
                    action="update",
                    result="success",
                    details={'resource_name': recommendation_resource_name}
                )
    
                # Invalidate all caches (recommendation could affect any resource)
                get_cache_manager().invalidate(customer_id, ResourceType.CAMPAIGN)
                get_cache_manager().invalidate(customer_id, ResourceType.AD_GROUP)
                get_cache_manager().invalidate(customer_id, ResourceType.KEYWORD)
    
                output = f"✅ Recommendation applied successfully!\n\n"
                output += f"**Resource Name**: {result['resource_name']}\n"
                output += f"**Status**: {result['status']}\n\n"
                output += f"The optimization has been implemented in your account.\n"
                output += f"Monitor performance over the next few days to see the impact.\n"
    
                return output
    
            except Exception as e:
                error_msg = ErrorHandler.handle_error(e, context="apply_recommendation")
                return f"❌ Failed to apply recommendation: {error_msg}"
  • The AutomationManager.apply_recommendation() method that actually calls the Google Ads API RecommendationService.apply_recommendation() with the recommendation resource name and returns the result.
    def apply_recommendation(
        self,
        customer_id: str,
        recommendation_resource_name: str
    ) -> Dict[str, Any]:
        """Apply a single optimization recommendation.
    
        Args:
            customer_id: Customer ID (without hyphens)
            recommendation_resource_name: Resource name of the recommendation
    
        Returns:
            Dictionary with application result
        """
        recommendation_service = self.client.get_service("RecommendationService")
    
        apply_operation = self.client.get_type("ApplyRecommendationOperation")
        apply_operation.resource_name = recommendation_resource_name
    
        response = recommendation_service.apply_recommendation(
            customer_id=customer_id,
            operations=[apply_operation]
        )
    
        result = response.results[0]
    
        return {
            'resource_name': result.resource_name,
            'status': 'applied'
        }
  • The RecommendationType enum used to define valid recommendation types. Though not directly used in the apply function, it's part of the recommendation schema used across the automation module.
    class RecommendationType(str, Enum):
        """Google Ads recommendation types."""
  • The register_automation_tools() function that registers all automation tools with the MCP server via @mcp.tool() decorators.
    def register_automation_tools(mcp):
        """Register all automation and optimization tools with the MCP server.
    
        Args:
            mcp: FastMCP server instance
        """
  • The _register_all_modular_tools() function that imports and calls register_automation_tools (among others) to register the tool on the MCP server.
    def _register_all_modular_tools():
        """Import and register every modular tool module."""
        import importlib
    
        registered = 0
        for label, module_path, func_name in _TOOL_MODULES:
            try:
                mod = importlib.import_module(module_path)
                register_fn = getattr(mod, func_name)
                register_fn(mcp)
                logger.info(f"  ✓ {label}")
                registered += 1
            except Exception as exc:
                logger.error(f"  ✗ {label}: {exc}")
    
        logger.info(f"Registered {registered}/{len(_TOOL_MODULES)} modular tool modules")
Behavior3/5

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

With no annotations, the description must fully convey behavioral traits. It warns that changes will be made, but does not disclose if changes are reversible, whether the operation is idempotent, or what permissions are required. It does describe the effect for various recommendation types, which adds value.

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

Conciseness4/5

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

The description is well-organized with clear sections (main purpose, args, returns, example, warning). It is slightly verbose but each part serves a purpose. The structure aids readability.

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 tool has 2 required parameters, no annotations, and an output schema exists (but not shown), the description is fairly complete. It explains how to get the resource name, what the tool does, and includes a warning. It could add details about return format or error cases, but the output schema likely covers that.

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

Parameters5/5

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

The schema has 0% description coverage, so the description fully compensates. It explains customer_id format (no hyphens) and recommendation_resource_name as obtained from google_ads_get_recommendations. It provides a concrete example, making parameter usage clear.

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 applies a single optimization recommendation, with examples of recommendation types (keyword, budget, bidding). It distinguishes from sibling tools like google_ads_apply_recommendations_by_type, which applies multiple recommendations of the same type.

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 explains that the tool automatically implements recommendations and includes a warning to review carefully. However, it does not explicitly state when to use this tool versus alternatives like google_ads_bulk_apply_recommendations, nor does it mention any prerequisites (e.g., need to fetch recommendation details first).

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