google_ads_set_campaign_schedule
Define ad schedules for a campaign to control when ads show, including day of week, start/end time, and optional bid adjustments.
Instructions
Set ad scheduling (dayparting) for a campaign.
Args: customer_id: Customer ID (without hyphens) campaign_id: Campaign ID schedules: List of schedule dictionaries with: - day_of_week: Day name (MONDAY, TUESDAY, etc.) or numeric (0=Sunday, 6=Saturday) - start_hour: Hour to start (0-23) - start_minute: Minute to start (0, 15, 30, 45) - end_hour: Hour to end (0-24) - end_minute: Minute to end (0, 15, 30, 45) - bid_modifier: Optional bid adjustment (1.2 = +20%, 0.8 = -20%)
Returns: Success message with schedule summary
Example: schedules = [ { "day_of_week": "MONDAY", "start_hour": 9, "start_minute": 0, "end_hour": 17, "end_minute": 0, "bid_modifier": 1.2 } ]
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| customer_id | Yes | ||
| campaign_id | Yes | ||
| schedules | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- The MCP tool handler function that sets campaign ad scheduling (dayparting). Receives customer_id, campaign_id, and schedules list, delegates to CampaignManager.set_ad_schedule(), logs the operation, invalidates cache, and formats the response.
@mcp.tool() def google_ads_set_campaign_schedule( customer_id: str, campaign_id: str, schedules: List[Dict[str, Any]] ) -> str: """ Set ad scheduling (dayparting) for a campaign. Args: customer_id: Customer ID (without hyphens) campaign_id: Campaign ID schedules: List of schedule dictionaries with: - day_of_week: Day name (MONDAY, TUESDAY, etc.) or numeric (0=Sunday, 6=Saturday) - start_hour: Hour to start (0-23) - start_minute: Minute to start (0, 15, 30, 45) - end_hour: Hour to end (0-24) - end_minute: Minute to end (0, 15, 30, 45) - bid_modifier: Optional bid adjustment (1.2 = +20%, 0.8 = -20%) Returns: Success message with schedule summary Example: schedules = [ { "day_of_week": "MONDAY", "start_hour": 9, "start_minute": 0, "end_hour": 17, "end_minute": 0, "bid_modifier": 1.2 } ] """ with performance_logger.track_operation('set_campaign_schedule', customer_id=customer_id): try: client = get_auth_manager().get_client() campaign_manager = CampaignManager(client) if not schedules: return "⚠️ No schedules provided. Provide at least one schedule." result = campaign_manager.set_ad_schedule( customer_id, campaign_id, schedules ) # Audit log audit_logger.log_api_call( customer_id=customer_id, operation="set_campaign_schedule", resource_type="campaign", resource_id=campaign_id, action="update", result="success", details={'schedule_count': len(schedules)} ) # Invalidate cache get_cache_manager().invalidate(customer_id, ResourceType.CAMPAIGN) output = f"✅ Ad schedule set for campaign {campaign_id}\n\n" output += f"**Schedules Added**: {len(schedules)}\n\n" for schedule in schedules[:5]: # Show first 5 day = schedule.get('day_of_week', 'Unknown') start_h = schedule.get('start_hour', 0) start_m = schedule.get('start_minute', 0) end_h = schedule.get('end_hour', 24) end_m = schedule.get('end_minute', 0) modifier = schedule.get('bid_modifier', 1.0) output += f"- {day}: {start_h:02d}:{start_m:02d} - {end_h:02d}:{end_m:02d}" if modifier != 1.0: pct = (modifier - 1.0) * 100 output += f" (Bid: {pct:+.0f}%)" output += "\n" if len(schedules) > 5: output += f"... and {len(schedules) - 5} more\n" output += f"\n{result['message']}" return output except Exception as e: error_msg = ErrorHandler.handle_error(e, context="set_campaign_schedule") return f"❌ Failed to set campaign schedule: {error_msg}" - Input schema/type hints for the tool: customer_id (str), campaign_id (str), schedules (List[Dict[str,Any]]) with day_of_week, start_hour, start_minute, end_hour, end_minute, bid_modifier.
def google_ads_set_campaign_schedule( customer_id: str, campaign_id: str, schedules: List[Dict[str, Any]] ) -> str: """ Set ad scheduling (dayparting) for a campaign. Args: customer_id: Customer ID (without hyphens) campaign_id: Campaign ID schedules: List of schedule dictionaries with: - day_of_week: Day name (MONDAY, TUESDAY, etc.) or numeric (0=Sunday, 6=Saturday) - start_hour: Hour to start (0-23) - start_minute: Minute to start (0, 15, 30, 45) - end_hour: Hour to end (0-24) - end_minute: Minute to end (0, 15, 30, 45) - bid_modifier: Optional bid adjustment (1.2 = +20%, 0.8 = -20%) Returns: Success message with schedule summary Example: schedules = [ { "day_of_week": "MONDAY", "start_hour": 9, "start_minute": 0, "end_hour": 17, "end_minute": 0, "bid_modifier": 1.2 } ] """ - tools/campaigns/mcp_tools_campaigns.py:534-568 (registration)Tool is registered via the @mcp.tool() decorator on the function inside register_campaign_tools(), which is called from google_ads_mcp.py via _TOOL_MODULES registration.
@mcp.tool() def google_ads_set_campaign_schedule( customer_id: str, campaign_id: str, schedules: List[Dict[str, Any]] ) -> str: """ Set ad scheduling (dayparting) for a campaign. Args: customer_id: Customer ID (without hyphens) campaign_id: Campaign ID schedules: List of schedule dictionaries with: - day_of_week: Day name (MONDAY, TUESDAY, etc.) or numeric (0=Sunday, 6=Saturday) - start_hour: Hour to start (0-23) - start_minute: Minute to start (0, 15, 30, 45) - end_hour: Hour to end (0-24) - end_minute: Minute to end (0, 15, 30, 45) - bid_modifier: Optional bid adjustment (1.2 = +20%, 0.8 = -20%) Returns: Success message with schedule summary Example: schedules = [ { "day_of_week": "MONDAY", "start_hour": 9, "start_minute": 0, "end_hour": 17, "end_minute": 0, "bid_modifier": 1.2 } ] """ - managers/campaign_manager.py:713-780 (helper)CampaignManager.set_ad_schedule() helper that builds CampaignCriterionOperation objects with AdScheduleInfo (day_of_week, start/end hour/minute, bid_modifier) and calls mutate_campaign_criteria on the CampaignCriterionService.
def set_ad_schedule( self, customer_id: str, campaign_id: str, schedules: List[Dict[str, Any]] ) -> Dict[str, Any]: """ Set ad scheduling (dayparting) for a campaign. Args: customer_id: Customer ID campaign_id: Campaign ID schedules: List of schedule dicts with: - day_of_week: Day name (MONDAY, TUESDAY, etc.) - start_hour: Start hour (0-23) - start_minute: Start minute (0, 15, 30, 45) - end_hour: End hour (0-24) - end_minute: End minute (0, 15, 30, 45) - bid_modifier: Optional bid adjustment (default 1.0) Returns: Operation result """ campaign_criterion_service = self.client.get_service("CampaignCriterionService") operations = [] for schedule in schedules: operation = self.client.get_type("CampaignCriterionOperation") criterion = operation.create criterion.campaign = campaign_criterion_service.campaign_path( customer_id, campaign_id ) # Set ad schedule ad_schedule = criterion.ad_schedule ad_schedule.day_of_week = self.client.enums.DayOfWeekEnum[ schedule['day_of_week'].upper() ] ad_schedule.start_hour = schedule['start_hour'] ad_schedule.start_minute = self.client.enums.MinuteOfHourEnum[ f"MINUTE_{schedule.get('start_minute', 0)}" ] ad_schedule.end_hour = schedule['end_hour'] ad_schedule.end_minute = self.client.enums.MinuteOfHourEnum[ f"MINUTE_{schedule.get('end_minute', 0)}" ] # Set bid modifier if provided if 'bid_modifier' in schedule: criterion.bid_modifier = schedule['bid_modifier'] operations.append(operation) # Add criteria response = campaign_criterion_service.mutate_campaign_criteria( customer_id=customer_id, operations=operations ) logger.info(f"Set {len(operations)} ad schedules for campaign {campaign_id}") return { "campaign_id": campaign_id, "schedules_added": len(operations), "resource_names": [result.resource_name for result in response.results] } - google_ads_mcp.py:481-481 (registration)Top-level registration entry: 'campaigns' module mapped to tools.campaigns.mcp_tools_campaigns.register_campaign_tools in _TOOL_MODULES list.
("campaigns", "tools.campaigns.mcp_tools_campaigns", "register_campaign_tools"),