Skip to main content
Glama

create_campaign

Create a new Meta ad campaign by selecting an objective, budget type (CBO/ABO), and bid strategy to control spending and delivery.

Instructions

Create a new Facebook or Instagram ad campaign in a Meta Ads account. Use this to start
a new campaign with an ODAX objective (OUTCOME_LEADS, OUTCOME_SALES, OUTCOME_AWARENESS,
OUTCOME_TRAFFIC, OUTCOME_ENGAGEMENT, OUTCOME_APP_PROMOTION), pick CBO (campaign budget
optimization) or ABO (ad-set-level budgets), and set bid strategy, spend cap, and special
ad categories. This is the first step of the campaign group → ad set → ad hierarchy on
Meta. Returns the new campaign id. Also known as: create campaign, new campaign, make
campaign, campaign group, ABO campaign, CBO campaign.

Note: Campaigns do not support start_time for scheduling — set start_time on the ad set instead.

Args:
    account_id: Meta Ads account ID (format: act_XXXXXXXXX)
    name: Campaign name
    objective: Campaign objective (ODAX, outcome-based). Must be one of:
               OUTCOME_AWARENESS, OUTCOME_TRAFFIC, OUTCOME_ENGAGEMENT,
               OUTCOME_LEADS, OUTCOME_SALES, OUTCOME_APP_PROMOTION.
               Note: Legacy objectives like BRAND_AWARENESS, LINK_CLICKS,
               CONVERSIONS, APP_INSTALLS, etc. are not valid for new
               campaigns and will cause a 400 error. Use the outcome-based
               values above (e.g., BRAND_AWARENESS → OUTCOME_AWARENESS).
    access_token: Meta API access token (optional - will use cached token if not provided)
    status: Initial campaign status (default: PAUSED)
    special_ad_categories: List of special ad categories if applicable
    daily_budget: Daily budget in account currency (in cents) as a string (only used if use_adset_level_budgets=False)
    lifetime_budget: Lifetime budget in account currency (in cents) as a string (only used if use_adset_level_budgets=False)
    buying_type: Buying type (e.g., 'AUCTION')
    bid_strategy: Bid strategy (default: LOWEST_COST_WITHOUT_CAP). Must be one of: 'LOWEST_COST_WITHOUT_CAP', 'LOWEST_COST_WITH_BID_CAP', 'COST_CAP', 'LOWEST_COST_WITH_MIN_ROAS'. WARNING: If you use LOWEST_COST_WITH_BID_CAP or COST_CAP, all child ad sets will require bid_amount to be set.
    bid_cap: Bid cap in account currency (in cents) as a string
    spend_cap: Spending limit for the campaign in account currency (in cents) as a string
    campaign_budget_optimization: Whether to enable campaign budget optimization (only used if use_adset_level_budgets=False)
    ab_test_control_setups: Settings for A/B testing (e.g., [{"name":"Creative A", "ad_format":"SINGLE_IMAGE"}])
    use_adset_level_budgets: If True, budgets will be set at the ad set level instead of campaign level (default: False)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes
nameYes
objectiveYes
access_tokenNo
statusNoPAUSED
special_ad_categoriesNo
daily_budgetNo
lifetime_budgetNo
buying_typeNo
bid_strategyNoLOWEST_COST_WITHOUT_CAP
bid_capNo
spend_capNo
campaign_budget_optimizationNo
ab_test_control_setupsNo
use_adset_level_budgetsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for create_campaign. Decorated with @mcp_server.tool() and @meta_api_tool. Accepts account_id, name, objective, and many optional parameters. Builds the API request parameters and calls make_api_request with method='POST' to create a new campaign on the Meta Ads API. Returns the response as a JSON string.
    @mcp_server.tool()
    @meta_api_tool
    async def create_campaign(
        account_id: str,
        name: str,
        objective: str,
        access_token: Optional[str] = None,
        status: str = "PAUSED",
        special_ad_categories: Optional[List[str]] = None,
        daily_budget: Optional[int] = None,
        lifetime_budget: Optional[int] = None,
        buying_type: Optional[str] = None,
        bid_strategy: str = "LOWEST_COST_WITHOUT_CAP",
        bid_cap: Optional[int] = None,
        spend_cap: Optional[int] = None,
        campaign_budget_optimization: Optional[bool] = None,
        ab_test_control_setups: Optional[List[Dict[str, Any]]] = None,
        use_adset_level_budgets: bool = False
    ) -> str:
        """
        Create a new Facebook or Instagram ad campaign in a Meta Ads account. Use this to start
        a new campaign with an ODAX objective (OUTCOME_LEADS, OUTCOME_SALES, OUTCOME_AWARENESS,
        OUTCOME_TRAFFIC, OUTCOME_ENGAGEMENT, OUTCOME_APP_PROMOTION), pick CBO (campaign budget
        optimization) or ABO (ad-set-level budgets), and set bid strategy, spend cap, and special
        ad categories. This is the first step of the campaign group → ad set → ad hierarchy on
        Meta. Returns the new campaign id. Also known as: create campaign, new campaign, make
        campaign, campaign group, ABO campaign, CBO campaign.
    
        Note: Campaigns do not support start_time for scheduling — set start_time on the ad set instead.
    
        Args:
            account_id: Meta Ads account ID (format: act_XXXXXXXXX)
            name: Campaign name
            objective: Campaign objective (ODAX, outcome-based). Must be one of:
                       OUTCOME_AWARENESS, OUTCOME_TRAFFIC, OUTCOME_ENGAGEMENT,
                       OUTCOME_LEADS, OUTCOME_SALES, OUTCOME_APP_PROMOTION.
                       Note: Legacy objectives like BRAND_AWARENESS, LINK_CLICKS,
                       CONVERSIONS, APP_INSTALLS, etc. are not valid for new
                       campaigns and will cause a 400 error. Use the outcome-based
                       values above (e.g., BRAND_AWARENESS → OUTCOME_AWARENESS).
            access_token: Meta API access token (optional - will use cached token if not provided)
            status: Initial campaign status (default: PAUSED)
            special_ad_categories: List of special ad categories if applicable
            daily_budget: Daily budget in account currency (in cents) as a string (only used if use_adset_level_budgets=False)
            lifetime_budget: Lifetime budget in account currency (in cents) as a string (only used if use_adset_level_budgets=False)
            buying_type: Buying type (e.g., 'AUCTION')
            bid_strategy: Bid strategy (default: LOWEST_COST_WITHOUT_CAP). Must be one of: 'LOWEST_COST_WITHOUT_CAP', 'LOWEST_COST_WITH_BID_CAP', 'COST_CAP', 'LOWEST_COST_WITH_MIN_ROAS'. WARNING: If you use LOWEST_COST_WITH_BID_CAP or COST_CAP, all child ad sets will require bid_amount to be set.
            bid_cap: Bid cap in account currency (in cents) as a string
            spend_cap: Spending limit for the campaign in account currency (in cents) as a string
            campaign_budget_optimization: Whether to enable campaign budget optimization (only used if use_adset_level_budgets=False)
            ab_test_control_setups: Settings for A/B testing (e.g., [{"name":"Creative A", "ad_format":"SINGLE_IMAGE"}])
            use_adset_level_budgets: If True, budgets will be set at the ad set level instead of campaign level (default: False)
        """
        # Check required parameters
        if not account_id:
            return json.dumps({"error": "No account ID provided"}, indent=2)
        
        if not name:
            return json.dumps({"error": "No campaign name provided"}, indent=2)
            
        if not objective:
            return json.dumps({"error": "No campaign objective provided"}, indent=2)
    
        account_id = ensure_act_prefix(account_id)
    
        # Track whether the user explicitly provided special_ad_categories
        _user_provided_categories = special_ad_categories is not None
        
        # Special_ad_categories is required by the API, set default if not provided
        if special_ad_categories is None:
            special_ad_categories = []
        
        # Only warn if user omitted special_ad_categories entirely.
        # If they explicitly passed [] they are saying none are needed.
        compliance_warning = None
        if objective == "OUTCOME_LEADS" and not special_ad_categories and not _user_provided_categories:
            compliance_warning = (
                "Warning: Campaign objective is OUTCOME_LEADS but no special_ad_categories were specified. "
                "If this campaign is for a regulated industry (insurance, housing, employment, credit), "
                "you must set special_ad_categories (e.g., FINANCIAL_PRODUCTS_SERVICES, HOUSING, EMPLOYMENT, CREDIT) "
                "to comply with Meta advertising policies. Ads without the correct category may be rejected."
            )
        
        # For this example, we'll add a fixed daily budget if none is provided and we're not using ad set level budgets
        if not daily_budget and not lifetime_budget and not use_adset_level_budgets:
            daily_budget = "1000"  # Default to $10 USD
        
        endpoint = f"{account_id}/campaigns"
        
        params = {
            "name": name,
            "objective": objective,
            "status": status,
            "special_ad_categories": json.dumps(special_ad_categories)  # Properly format as JSON string
        }
        
        # Only set campaign-level budgets if we're not using ad set level budgets
        if not use_adset_level_budgets:
            # Convert budget values to strings if they aren't already
            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 campaign_budget_optimization is not None:
                params["campaign_budget_optimization"] = "true" if campaign_budget_optimization else "false"
        else:
            # Meta API v24 requires is_adset_budget_sharing_enabled when not using campaign budget
            params["is_adset_budget_sharing_enabled"] = "false"
    
        # Add new parameters
        if buying_type:
            params["buying_type"] = buying_type
        
        if bid_strategy and not use_adset_level_budgets:
            params["bid_strategy"] = bid_strategy
        
        if bid_cap is not None:
            params["bid_cap"] = str(bid_cap)
        
        if spend_cap is not None:
            params["spend_cap"] = str(spend_cap)
        
        if ab_test_control_setups:
            params["ab_test_control_setups"] = json.dumps(ab_test_control_setups)
        
        try:
            data = await make_api_request(endpoint, access_token, params, method="POST")
            
            # Add a note about budget strategy if using ad set level budgets
            if use_adset_level_budgets:
                data["budget_strategy"] = "ad_set_level"
                data["note"] = "Campaign created with ad set level budgets. Set budgets when creating ad sets within this campaign."
            
            if compliance_warning:
                data["compliance_warning"] = compliance_warning
            
            return json.dumps(data, indent=2)
        except Exception as e:
            error_msg = str(e)
            return json.dumps({
                "error": "Failed to create campaign",
                "details": error_msg,
                "params_sent": params
            }, indent=2)
  • The @mcp_server.tool() decorator on line 115 registers create_campaign as an MCP tool with the MCP server.
    @mcp_server.tool()
  • Function signature with type annotations defining the input schema for create_campaign including parameters like account_id, name, objective, status, special_ad_categories, budgets, bid_strategy, etc.
    async def create_campaign(
        account_id: str,
        name: str,
        objective: str,
        access_token: Optional[str] = None,
        status: str = "PAUSED",
        special_ad_categories: Optional[List[str]] = None,
        daily_budget: Optional[int] = None,
        lifetime_budget: Optional[int] = None,
        buying_type: Optional[str] = None,
        bid_strategy: str = "LOWEST_COST_WITHOUT_CAP",
        bid_cap: Optional[int] = None,
        spend_cap: Optional[int] = None,
        campaign_budget_optimization: Optional[bool] = None,
        ab_test_control_setups: Optional[List[Dict[str, Any]]] = None,
        use_adset_level_budgets: bool = False
    ) -> str:
  • Imports create_campaign from the campaigns module to make it available at the core package level.
    from .campaigns import get_campaigns, get_campaign_details, create_campaign
  • Exports create_campaign in the package-level __all__ list.
    'create_campaign',
Behavior5/5

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

With no annotations, the description carries full burden. It reveals the tool creates a campaign, returns an id, and details constraints (ODAX only, no start_time, bid strategy implications). It also explains budget options (CBO/ABO) and special ad categories.

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 summary, note, and parameter list. It is slightly verbose with a synonym list ('Also known as...'), but every other sentence adds value.

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

Completeness5/5

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

Given 15 parameters with 0% schema coverage, the description provides complete context: purpose, hierarchy, parameter details, output (returns campaign id), and behavioral notes. Sibling tools are listed, and the description fits the campaign creation workflow.

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 coverage is 0%, but the description fully compensates by explaining each parameter's purpose, format, defaults, and constraints (e.g., account_id format, objective enum, budget in cents as string, bid strategy warnings).

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

Purpose5/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 new Facebook or Instagram ad campaign, lists specific ODAX objectives, and mentions the campaign hierarchy (first step). It distinguishes from sibling tools like create_adset and create_ad by focusing on campaign-level creation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides usage context: when to use (starting a new campaign), objectives allowed, and a note about start_time. It warns against legacy objectives. However, it doesn't explicitly state when not to use it (e.g., for updates), though sibling tools imply that.

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