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
| Name | Required | Description | Default |
|---|---|---|---|
| adset_id | Yes | ||
| frequency_control_specs | No | ||
| bid_strategy | No | ||
| bid_amount | No | ||
| status | No | ||
| targeting | No | ||
| optimization_goal | No | ||
| daily_budget | No | ||
| lifetime_budget | No | ||
| is_dynamic_creative | No | ||
| access_token | No |
Implementation Reference
- meta_ads_mcp/core/adsets.py:294-372 (handler)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)
- meta_ads_mcp/core/__init__.py:6-28 (registration)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',
- meta_ads_mcp/__init__.py:38-46 (registration)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,