google_ads_update_ad_group_bid
Update the maximum cost-per-click (CPC) bid for a specific ad group in Google Ads to adjust ad spend.
Instructions
Update ad group CPC bid.
Args: customer_id: Customer ID (without hyphens) ad_group_id: Ad group ID cpc_bid: New CPC bid in currency units (e.g., 1.50 for $1.50)
Returns: Success message with bid details
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| customer_id | Yes | ||
| ad_group_id | Yes | ||
| cpc_bid | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- MCP tool handler for google_ads_update_ad_group_bid. Accepts customer_id, ad_group_id, and cpc_bid (float), converts to micros, calls AdGroupManager.update_ad_group_cpc_bid(), logs to audit, invalidates cache, and returns a success message with the new bid.
def google_ads_update_ad_group_bid( customer_id: str, ad_group_id: str, cpc_bid: float ) -> str: """ Update ad group CPC bid. Args: customer_id: Customer ID (without hyphens) ad_group_id: Ad group ID cpc_bid: New CPC bid in currency units (e.g., 1.50 for $1.50) Returns: Success message with bid details """ with performance_logger.track_operation('update_ad_group_bid', customer_id=customer_id): try: client = get_auth_manager().get_client() ad_group_manager = AdGroupManager(client) cpc_bid_micros = int(cpc_bid * 1_000_000) result = ad_group_manager.update_ad_group_cpc_bid( customer_id, ad_group_id, cpc_bid_micros ) # Audit log audit_logger.log_api_call( customer_id=customer_id, operation="update_ad_group_bid", resource_type="ad_group", resource_id=ad_group_id, action="update", result="success", details={'new_cpc_bid': cpc_bid} ) # Invalidate cache get_cache_manager().invalidate(customer_id, ResourceType.AD_GROUP) return ( f"✅ Ad group {ad_group_id} bid updated successfully!\n\n" f"**New CPC Bid**: ${result['new_cpc_bid']:.2f}\n\n" f"The new bid will take effect immediately. " f"Monitor performance closely to see the impact on impressions and clicks." ) except Exception as e: error_msg = ErrorHandler.handle_error(e, context="update_ad_group_bid") return f"❌ Failed to update ad group bid: {error_msg}" - managers/ad_group_manager.py:246-271 (handler)AdGroupManager.update_ad_group_cpc_bid() - the actual manager method that delegates to update_ad_group() with cpc_bid_micros, then converts micros back to currency units for the result.
def update_ad_group_cpc_bid( self, customer_id: str, ad_group_id: str, cpc_bid_micros: int ) -> Dict[str, Any]: """ Update ad group CPC bid. Args: customer_id: Customer ID ad_group_id: Ad group ID cpc_bid_micros: New CPC bid in micros Returns: Operation result with bid amount """ result = self.update_ad_group( customer_id, ad_group_id, {"cpc_bid_micros": cpc_bid_micros} ) result["new_cpc_bid"] = cpc_bid_micros / 1_000_000 return result - tools/ad_groups/mcp_tools_ad_groups.py:24-25 (registration)Registration: The @mcp.tool() decorator on line 252 registers google_ads_update_ad_group_bid as an MCP tool. The parent function register_ad_group_tools(mcp) is the registration entry point.
def register_ad_group_tools(mcp: FastMCP): """Register ad group management tools with MCP server.""" - managers/ad_group_manager.py:146-221 (helper)AdGroupManager.update_ad_group() - the generic update method that builds the AdGroupOperation with a field mask, supporting cpc_bid_micros updates among other fields.
def update_ad_group( self, customer_id: str, ad_group_id: str, updates: Dict[str, Any] ) -> Dict[str, Any]: """ Update ad group settings. Args: customer_id: Customer ID ad_group_id: Ad group ID updates: Dictionary of fields to update (name, status, cpc_bid_micros, etc.) Returns: Operation result """ ad_group_service = self.client.get_service("AdGroupService") ad_group_operation = self.client.get_type("AdGroupOperation") ad_group = ad_group_operation.update ad_group.resource_name = ad_group_service.ad_group_path(customer_id, ad_group_id) # Track updated fields for field mask update_mask_paths = [] # Update name if "name" in updates: ad_group.name = updates["name"] update_mask_paths.append("name") # Update status if "status" in updates: ad_group.status = self.client.enums.AdGroupStatusEnum[updates["status"]] update_mask_paths.append("status") # Update CPC bid if "cpc_bid_micros" in updates: ad_group.cpc_bid_micros = updates["cpc_bid_micros"] update_mask_paths.append("cpc_bid_micros") # Update CPM bid if "cpm_bid_micros" in updates: ad_group.cpm_bid_micros = updates["cpm_bid_micros"] update_mask_paths.append("cpm_bid_micros") # Update CPV bid if "cpv_bid_micros" in updates: ad_group.cpv_bid_micros = updates["cpv_bid_micros"] update_mask_paths.append("cpv_bid_micros") # Update Final URL suffix if "final_url_suffix" in updates: ad_group.final_url_suffix = updates["final_url_suffix"] update_mask_paths.append("final_url_suffix") # Set field mask self.client.copy_from( ad_group_operation.update_mask, field_mask_pb2.FieldMask(paths=update_mask_paths) ) # Update ad group response = ad_group_service.mutate_ad_groups( customer_id=customer_id, operations=[ad_group_operation] ) logger.info(f"Updated ad group {ad_group_id}: {', '.join(update_mask_paths)}") return { "ad_group_id": ad_group_id, "updated_fields": update_mask_paths, "message": f"Ad group updated successfully" }