update_adset
Modify Meta Ads ad sets by updating frequency caps, budgets, targeting, bid strategy, and status to optimize campaign performance and align with advertising goals.
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
access_token: Meta API access token (optional - will use cached token if not provided)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| access_token | No | ||
| adset_id | Yes | ||
| bid_amount | No | ||
| bid_strategy | No | ||
| daily_budget | No | ||
| frequency_control_specs | No | ||
| lifetime_budget | No | ||
| optimization_goal | No | ||
| status | No | ||
| targeting | No |
Input Schema (JSON Schema)
{
"properties": {
"access_token": {
"default": null,
"title": "Access Token",
"type": "string"
},
"adset_id": {
"title": "Adset Id",
"type": "string"
},
"bid_amount": {
"default": null,
"title": "Bid Amount",
"type": "integer"
},
"bid_strategy": {
"default": null,
"title": "Bid Strategy",
"type": "string"
},
"daily_budget": {
"default": null,
"title": "daily_budget",
"type": "string"
},
"frequency_control_specs": {
"default": null,
"items": {
"additionalProperties": true,
"type": "object"
},
"title": "Frequency Control Specs",
"type": "array"
},
"lifetime_budget": {
"default": null,
"title": "lifetime_budget",
"type": "string"
},
"optimization_goal": {
"default": null,
"title": "Optimization Goal",
"type": "string"
},
"status": {
"default": null,
"title": "Status",
"type": "string"
},
"targeting": {
"additionalProperties": true,
"default": null,
"title": "Targeting",
"type": "object"
}
},
"required": [
"adset_id"
],
"title": "update_adsetArguments",
"type": "object"
}
Implementation Reference
- meta_ads_mcp/core/adsets.py:294-372 (handler)The core handler function for the 'update_adset' MCP tool. It is decorated with @mcp_server.tool() for registration and @meta_api_tool for API handling. This async function updates ad set parameters such as frequency controls, budgets, targeting, status, etc., via POST request to the Meta Ads API endpoint.@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)