Skip to main content
Glama
EfrainTorres

ArmaVita Meta Ads MCP

create_ad_set

Create targeted ad sets within Meta campaigns by defining budgets, bidding strategies, and audience parameters to organize and optimize advertising delivery.

Instructions

Create an ad set under a campaign.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ad_account_idYes
campaign_idYes
nameYes
optimization_goalYes
billing_eventYes
statusNoPAUSED
daily_budgetNo
lifetime_budgetNo
targetingNo
bid_amountNo
bid_strategyNo
bid_constraintsNo
start_timeNo
end_timeNo
dsa_beneficiaryNo
promoted_objectNo
destination_typeNo
is_dynamic_creativeNo
meta_access_tokenNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The `create_ad_set` handler function performs validation and makes a POST request to the Meta Ads API to create a new ad set.
    async def create_ad_set(
        ad_account_id: str,
        campaign_id: str,
        name: str,
        optimization_goal: str,
        billing_event: str,
        status: str = "PAUSED",
        daily_budget: Optional[int] = None,
        lifetime_budget: Optional[int] = None,
        targeting: Optional[Dict[str, Any]] = None,
        bid_amount: Optional[int] = None,
        bid_strategy: Optional[str] = None,
        bid_constraints: Optional[Dict[str, Any]] = None,
        start_time: Optional[str] = None,
        end_time: Optional[str] = None,
        dsa_beneficiary: Optional[str] = None,
        promoted_object: Optional[Dict[str, Any]] = None,
        destination_type: Optional[str] = None,
        is_dynamic_creative: Optional[bool] = None,
        meta_access_token: Optional[str] = None,
    ) -> str:
        """Create an ad set under a campaign."""
        if not ad_account_id:
            return _json({"error": "No account ID provided"})
        if not campaign_id:
            return _json({"error": "No campaign ID provided"})
        if not name:
            return _json({"error": "No ad set name provided"})
        if not optimization_goal:
            return _json({"error": "No optimization goal provided"})
        if not billing_event:
            return _json({"error": "No billing event provided"})
    
        app_error = _validate_promoted_object_for_app_installs(optimization_goal, promoted_object)
        if app_error:
            return _json(app_error)
    
        bid_error = _validate_bid_controls(bid_strategy, bid_amount, bid_constraints)
        if bid_error:
            return _json(bid_error)
    
        normalized_bid_strategy = _normalize_bid_strategy(bid_strategy)
    
        if bid_amount is None:
            try:
                parent_strategy = await _parent_campaign_bid_strategy(campaign_id, meta_access_token)
            except Exception:  # noqa: BLE001
                parent_strategy = None
    
            if parent_strategy in (_BID_STRATEGIES_REQUIRING_BID_AMOUNT | {"TARGET_COST"}):
                return _json(
                    {
                        "error": (
                            f"bid_amount is required because the parent campaign uses bid_strategy "
                            f"'{parent_strategy}'"
                        ),
                        "details": "Provide bid_amount in cents or update parent campaign strategy.",
                        "example_with_bid_amount": {"bid_amount": 500},
                    }
                )
    
        payload: Dict[str, Any] = {
            "name": name,
            "campaign_id": campaign_id,
            "status": status,
            "optimization_goal": optimization_goal,
            "billing_event": billing_event,
            "targeting": json.dumps(_normalize_targeting(targeting)),
        }
    
        if daily_budget is not None:
            payload["daily_budget"] = str(daily_budget)
        if lifetime_budget is not None:
            payload["lifetime_budget"] = str(lifetime_budget)
        if bid_amount is not None:
            payload["bid_amount"] = str(bid_amount)
        if normalized_bid_strategy is not None:
            payload["bid_strategy"] = normalized_bid_strategy
        if bid_constraints is not None:
            payload["bid_constraints"] = json.dumps(bid_constraints)
        if start_time:
            payload["start_time"] = start_time
        if end_time:
            payload["end_time"] = end_time
        if dsa_beneficiary:
            payload["dsa_beneficiary"] = dsa_beneficiary
        if promoted_object is not None:
            payload["promoted_object"] = json.dumps(promoted_object)
        if destination_type is not None:
            payload["destination_type"] = destination_type
        if is_dynamic_creative is not None:
            payload["is_dynamic_creative"] = "true" if bool(is_dynamic_creative) else "false"
    
        result = await make_api_request(f"{ad_account_id}/adsets", meta_access_token, payload, method="POST")
    
        if isinstance(result, dict) and result.get("error"):
            rendered_error = json.dumps(result.get("error", {}), default=str).lower()
            if "permission" in rendered_error or "insufficient" in rendered_error:
                return _json(
                    {
                        "error": "Insufficient permissions to set DSA beneficiary. Please ensure business_management permissions.",
                        "details": result,
                        "permission_required": True,
                    }
                )
            if "dsa_beneficiary" in rendered_error and ("not supported" in rendered_error or "parameter" in rendered_error):
                return _json(
                    {
                        "error": "DSA beneficiary parameter not supported in this API version.",
                        "details": result,
                        "manual_setup_required": True,
                    }
                )
            if "benefits from ads" in rendered_error or "dsa beneficiary" in rendered_error:
                return _json(
                    {
                        "error": "DSA beneficiary required for European compliance.",
                        "details": result,
                        "dsa_required": True,
                    }
                )
    
        return _json(result)
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states this is a creation operation but doesn't mention required permissions, whether it's idempotent, what happens on failure, rate limits, or what the output contains. For a complex mutation tool with 19 parameters, this leaves critical behavioral aspects undocumented.

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 a single, focused sentence with no wasted words. It's appropriately sized for a basic purpose statement, though it lacks the additional context needed for such a complex tool.

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

Completeness2/5

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

For a creation tool with 19 parameters, 0% schema description coverage, no annotations, and complex advertising domain context, the description is severely incomplete. While an output schema exists (which helps with return values), the description doesn't address critical aspects like parameter meanings, usage context, behavioral expectations, or how this tool relates to siblings in the advertising hierarchy.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, meaning none of the 19 parameters have descriptions in the schema. The tool description provides no information about any parameters—not even the required ones like 'ad_account_id', 'campaign_id', or 'name'. This leaves the agent with no semantic understanding of what values to provide for any parameter.

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 action ('Create') and resource ('an ad set under a campaign'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'create_ad' or 'create_campaign', which would require specifying what distinguishes an ad set from those other entities.

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?

The description provides no guidance on when to use this tool versus alternatives like 'clone_ad_set' or 'update_ad_set'. It mentions the parent relationship ('under a campaign') but doesn't specify prerequisites, constraints, or typical use cases for creating an ad set versus other advertising entities.

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/EfrainTorres/armavita-meta-ads-mcp'

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