Skip to main content
Glama

create_budget_schedule

Schedule budget increases for Meta Ads campaigns during anticipated high-demand periods using Unix timestamps to optimize ad spending.

Instructions

Create a budget schedule for a Meta Ads campaign.

Allows scheduling budget increases based on anticipated high-demand periods.
The times should be provided as Unix timestamps.

Args:
    campaign_id: Meta Ads campaign ID.
    budget_value: Amount of budget increase. Interpreted based on budget_value_type.
    budget_value_type: Type of budget value - "ABSOLUTE" or "MULTIPLIER".
    time_start: Unix timestamp for when the high demand period should start.
    time_end: Unix timestamp for when the high demand period should end.
    access_token: Meta API access token (optional - will use cached token if not provided).
    
Returns:
    A JSON string containing the ID of the created budget schedule or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
campaign_idYes
budget_valueYes
budget_value_typeYes
time_startYes
time_endYes
access_tokenNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'create_budget_schedule' tool. It is decorated with @mcp_server.tool() for MCP registration and @meta_api_tool for API handling. Performs input validation, constructs the API endpoint, and makes a POST request to create a budget schedule for the given campaign.
    @mcp_server.tool()
    @meta_api_tool
    async def create_budget_schedule(
        campaign_id: str,
        budget_value: int,
        budget_value_type: str,
        time_start: int,
        time_end: int,
        access_token: Optional[str] = None
    ) -> str:
        """
        Create a budget schedule for a Meta Ads campaign.
    
        Allows scheduling budget increases based on anticipated high-demand periods.
        The times should be provided as Unix timestamps.
        
        Args:
            campaign_id: Meta Ads campaign ID.
            budget_value: Amount of budget increase. Interpreted based on budget_value_type.
            budget_value_type: Type of budget value - "ABSOLUTE" or "MULTIPLIER".
            time_start: Unix timestamp for when the high demand period should start.
            time_end: Unix timestamp for when the high demand period should end.
            access_token: Meta API access token (optional - will use cached token if not provided).
            
        Returns:
            A JSON string containing the ID of the created budget schedule or an error message.
        """
        if not campaign_id:
            return json.dumps({"error": "Campaign ID is required"}, indent=2)
        if budget_value is None: # Check for None explicitly
            return json.dumps({"error": "Budget value is required"}, indent=2)
        if not budget_value_type:
            return json.dumps({"error": "Budget value type is required"}, indent=2)
        if budget_value_type not in ["ABSOLUTE", "MULTIPLIER"]:
            return json.dumps({"error": "Invalid budget_value_type. Must be ABSOLUTE or MULTIPLIER"}, indent=2)
        if time_start is None: # Check for None explicitly to allow 0
            return json.dumps({"error": "Time start is required"}, indent=2)
        if time_end is None: # Check for None explicitly to allow 0
            return json.dumps({"error": "Time end is required"}, indent=2)
    
        endpoint = f"{campaign_id}/budget_schedules"
    
        params = {
            "budget_value": budget_value,
            "budget_value_type": budget_value_type,
            "time_start": time_start,
            "time_end": time_end,
        }
    
        try:
            data = await make_api_request(endpoint, access_token, params, method="POST")
            return json.dumps(data, indent=2)
        except Exception as e:
            error_msg = str(e)
            # Include details about the error and the parameters sent for easier debugging
            return json.dumps({
                "error": "Failed to create budget schedule",
                "details": error_msg,
                "campaign_id": campaign_id,
                "params_sent": params
            }, indent=2) 
  • Import statement that loads the create_budget_schedule function, triggering its registration via the decorator when the core module is imported.
    from .budget_schedules import create_budget_schedule
  • The tool name listed in __all__, exporting it from the core package.
    'create_budget_schedule',
Behavior2/5

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

With no annotations provided, the description carries full burden. It states the tool creates a budget schedule (implying a write operation) and mentions optional token caching, but lacks critical behavioral details: whether this requires specific permissions, if schedules are reversible, rate limits, error handling beyond the return statement, or how it interacts with existing campaign budgets. The return format is mentioned but without specifics on success/error structure.

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-structured with a purpose statement, usage context, parameter explanations, and return information in a logical flow. It's appropriately sized for a 6-parameter tool. Minor improvement could be front-loading the return format earlier, but overall it's efficient with minimal waste.

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?

Given complexity (write operation with 6 parameters, no annotations, but has output schema), the description covers purpose and parameters well but has gaps. The output schema exists (mentioned in context signals), so describing returns is less critical, but behavioral aspects like permissions, idempotency, and error scenarios are missing. For a creation tool with no annotations, more operational context would be beneficial.

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?

Schema description coverage is 0%, so the description must compensate fully. It provides clear semantic explanations for all 6 parameters: campaign_id identifies the target, budget_value and budget_value_type explain the increase mechanism, time_start/time_end define the period with format (Unix timestamps), and access_token explains optional authentication with caching behavior. This adds significant value beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool creates a budget schedule for Meta Ads campaigns with specific functionality (scheduling budget increases for high-demand periods). It distinguishes from siblings like create_campaign or update_campaign by focusing on budget scheduling rather than campaign creation or general updates. However, it doesn't explicitly differentiate from all budget-related tools if they existed.

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 during anticipated high-demand periods and mentions Unix timestamps, providing some context. However, it doesn't explicitly state when to use this tool versus alternatives like update_campaign for budget changes, nor does it mention prerequisites like campaign existence or authentication requirements beyond the optional token.

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/pipeboard-co/meta-ads-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server