Skip to main content
Glama

update_adset

Modify ad set parameters including frequency caps, budgets, targeting, and bid strategies to optimize campaign performance on Meta platforms.

Instructions

Update an ad set with new settings including frequency caps and budgets.

Args:
    adset_id: Meta Ads ad set ID
    frequency_control_specs: List of frequency control specifications 
                             (e.g. [{"event": "IMPRESSIONS", "interval_days": 7, "max_frequency": 3}])
    bid_strategy: Bid strategy (e.g., 'LOWEST_COST_WITH_BID_CAP')
    bid_amount: Bid amount in account currency (in cents for USD)
    status: Update ad set status (ACTIVE, PAUSED, etc.)
    targeting: Complete targeting specifications (will replace existing targeting)
              (e.g. {"targeting_automation":{"advantage_audience":1}, "geo_locations": {"countries": ["US"]}})
    optimization_goal: Conversion optimization goal (e.g., 'LINK_CLICKS', 'CONVERSIONS', 'APP_INSTALLS', etc.)
    daily_budget: Daily budget in account currency (in cents) as a string
    lifetime_budget: Lifetime budget in account currency (in cents) as a string
    is_dynamic_creative: Enable/disable Dynamic Creative for this ad set.
    access_token: Meta API access token (optional - will use cached token if not provided)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
adset_idYes
frequency_control_specsNo
bid_strategyNo
bid_amountNo
statusNo
targetingNo
optimization_goalNo
daily_budgetNo
lifetime_budgetNo
is_dynamic_creativeNo
access_tokenNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary handler function for the 'update_adset' tool. Decorated with @mcp_server.tool() which registers it as an MCP tool. Implements the logic to update a Meta Ads adset via API call with various parameters like budgets, targeting, frequency controls, etc.
    @mcp_server.tool()
    @meta_api_tool
    async def update_adset(adset_id: str, frequency_control_specs: Optional[List[Dict[str, Any]]] = None, bid_strategy: Optional[str] = None, 
                            bid_amount: Optional[int] = None, status: Optional[str] = None, targeting: Optional[Dict[str, Any]] = None, 
                            optimization_goal: Optional[str] = None, daily_budget: Optional[int] = None, lifetime_budget: Optional[int] = None, 
                            is_dynamic_creative: Optional[bool] = None,
                            access_token: Optional[str] = None) -> str:
        """
        Update an ad set with new settings including frequency caps and budgets.
        
        Args:
            adset_id: Meta Ads ad set ID
            frequency_control_specs: List of frequency control specifications 
                                     (e.g. [{"event": "IMPRESSIONS", "interval_days": 7, "max_frequency": 3}])
            bid_strategy: Bid strategy (e.g., 'LOWEST_COST_WITH_BID_CAP')
            bid_amount: Bid amount in account currency (in cents for USD)
            status: Update ad set status (ACTIVE, PAUSED, etc.)
            targeting: Complete targeting specifications (will replace existing targeting)
                      (e.g. {"targeting_automation":{"advantage_audience":1}, "geo_locations": {"countries": ["US"]}})
            optimization_goal: Conversion optimization goal (e.g., 'LINK_CLICKS', 'CONVERSIONS', 'APP_INSTALLS', etc.)
            daily_budget: Daily budget in account currency (in cents) as a string
            lifetime_budget: Lifetime budget in account currency (in cents) as a string
            is_dynamic_creative: Enable/disable Dynamic Creative for this ad set.
            access_token: Meta API access token (optional - will use cached token if not provided)
        """
        if not adset_id:
            return json.dumps({"error": "No ad set ID provided"}, indent=2)
        
        params = {}
        
        if frequency_control_specs is not None:
            params['frequency_control_specs'] = frequency_control_specs
        
        if bid_strategy is not None:
            params['bid_strategy'] = bid_strategy
            
        if bid_amount is not None:
            params['bid_amount'] = str(bid_amount)
            
        if status is not None:
            params['status'] = status
            
        if optimization_goal is not None:
            params['optimization_goal'] = optimization_goal
            
        if targeting is not None:
            # Ensure proper JSON encoding for targeting
            if isinstance(targeting, dict):
                params['targeting'] = json.dumps(targeting)
            else:
                params['targeting'] = targeting  # Already a string
        
        # Add budget parameters if provided
        if daily_budget is not None:
            params['daily_budget'] = str(daily_budget)
        
        if lifetime_budget is not None:
            params['lifetime_budget'] = str(lifetime_budget)
        
        if is_dynamic_creative is not None:
            params['is_dynamic_creative'] = "true" if bool(is_dynamic_creative) else "false"
        
        if not params:
            return json.dumps({"error": "No update parameters provided"}, indent=2)
    
        endpoint = f"{adset_id}"
        
        try:
            # Use POST method for updates as per Meta API documentation
            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 adset_id in error for better context
            return json.dumps({
                "error": f"Failed to update ad set {adset_id}",
                "details": error_msg,
                "params_sent": params
            }, indent=2) 
  • Imports and exports the update_adset function in the core package __init__.py, making it available for use.
    from .adsets import get_adsets, get_adset_details, update_adset
    from .ads import get_ads, get_ad_details, get_ad_creatives, get_ad_image, update_ad
    from .insights import get_insights
    from . import authentication  # Import module to register conditional auth tools
    from .server import login_cli, main
    from .auth import login
    from . import ads_library  # Import module to register conditional tools
    from .budget_schedules import create_budget_schedule
    from .targeting import search_interests, get_interest_suggestions, estimate_audience_size, search_behaviors, search_demographics, search_geo_locations
    from . import reports  # Import module to register conditional tools
    from . import duplication  # Import module to register conditional duplication tools
    from .openai_deep_research import search, fetch  # OpenAI MCP Deep Research tools
    
    __all__ = [
        'mcp_server',
        'get_ad_accounts',
        'get_account_info',
        'get_campaigns',
        'get_campaign_details',
        'create_campaign',
        'get_adsets',
        'get_adset_details',
        'update_adset',
  • Re-exports update_adset from core at the package level.
    from .core import (
        get_ad_accounts,
        get_account_info,
        get_campaigns,
        get_campaign_details,
        create_campaign,
        get_adsets,
        get_adset_details,
        update_adset,
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 this is an update operation which implies mutation, but doesn't disclose behavioral aspects like: whether changes are reversible, what permissions are required, rate limits, whether partial updates are allowed (vs full replacement), or how the targeting parameter 'will replace existing targeting' affects the operation. The description provides some behavioral hints but misses critical mutation context.

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

Conciseness3/5

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

The description is appropriately front-loaded with the core purpose, but the parameter documentation section is lengthy (though necessary given schema coverage). While each parameter explanation earns its place, the overall structure could be more concise by grouping related parameters or using bullet points. It's functional but not optimally streamlined.

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 complexity (11 parameters, mutation operation, no annotations) and the existence of an output schema, the description does substantial work. The parameter documentation is comprehensive, and the output schema will handle return values. However, for a mutation tool with no annotations, it could better address behavioral aspects like error conditions, idempotency, or side effects.

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 description provides extensive parameter documentation with 11 parameters, adding significant semantic value beyond the schema which has 0% description coverage. Each parameter gets clear explanations, examples, and important details like currency units (cents), replacement behavior for targeting, and optional token usage. This fully compensates for the schema's lack of descriptions.

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 verb 'update' and resource 'ad set' with specific settings mentioned (frequency caps and budgets). It distinguishes from siblings like 'create_adset' by focusing on updates, but doesn't explicitly contrast with other update tools like 'update_ad' or 'update_campaign' beyond the resource type.

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 guidance on when to use this tool versus alternatives like 'update_ad' or 'update_campaign'. The description mentions what parameters can be updated but provides no context about prerequisites, dependencies, or when this specific update operation is appropriate versus other update operations in the sibling set.

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