Skip to main content
Glama
johnoconnor0

Google Ads MCP Server

by johnoconnor0

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

TableJSON Schema
NameRequiredDescriptionDefault
customer_idYes
campaign_idYes
schedulesYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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
                }
            ]
        """
  • 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
                }
            ]
        """
  • 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]
        }
  • 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"),
Behavior2/5

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

No annotations are present, so the description must fully cover behavioral traits. It only states 'Set ad scheduling' without indicating whether existing schedules are overwritten or merged, what permissions are needed, or any side effects. The return value is mentioned but lacks depth.

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 well-structured with a clear one-liner, formal args documentation, return value, and example. Every sentence serves a purpose, and the length is appropriate for the complexity of the schedules parameter.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers purpose, parameters, example, and return. However, it lacks details on overwrite behavior, constraints (e.g., max schedules), and differentiation from a sibling tool. Given the output schema exists, the return description is sufficient, but behavioral gaps remain.

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 input schema has 0% description coverage, but the description comprehensively documents all three parameters. It specifies customer_id format, campaign_id usage, and the detailed structure of schedules (day_of_week options, hour/minute ranges, optional bid modifier). This adds significant meaning beyond the schema.

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 'Set ad scheduling (dayparting) for a campaign,' with a specific verb and resource. The title and description align, and the tool's role is well-defined among siblings (e.g., google_ads_set_ad_schedule_bid_adjustments is different).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No usage guidelines are provided. The description does not specify when to use this tool versus alternatives like google_ads_set_ad_schedule_bid_adjustments, nor does it mention prerequisites, context, or when not to use it.

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