Skip to main content
Glama

get_adsets

Retrieve ad sets for a Meta Ads account, with optional filtering by campaign ID or status (active, paused, archived).

Instructions

List ad sets for an account or filtered by campaign.

Args: account_id: Ad account ID (e.g., 'act_123456789'). campaign_id: Optional campaign ID to filter ad sets for that campaign only. status_filter: Filter by effective_status: 'ACTIVE', 'PAUSED', 'ARCHIVED', or 'ALL'. limit: Maximum results per page (default 50).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes
campaign_idNo
status_filterNo
limitNo

Implementation Reference

  • The main handler function for the 'get_adsets' MCP tool. Lists ad sets for an account (or filtered by campaign) via Meta's Graph API. Supports status filtering, pagination (up to 200), budget enrichment (cents to currency display), and status counting.
    @mcp.tool()
    def get_adsets(
        account_id: str,
        campaign_id: Optional[str] = None,
        status_filter: Optional[str] = None,
        limit: int = 50,
    ) -> dict:
        """
        List ad sets for an account or filtered by campaign.
    
        Args:
            account_id: Ad account ID (e.g., 'act_123456789').
            campaign_id: Optional campaign ID to filter ad sets for that campaign only.
            status_filter: Filter by effective_status: 'ACTIVE', 'PAUSED', 'ARCHIVED', or 'ALL'.
            limit: Maximum results per page (default 50).
        """
        api_client._ensure_initialized()
        account_id = ensure_account_id_format(account_id)
    
        params = {"limit": str(min(limit, 100))}
    
        if status_filter and status_filter.upper() != "ALL":
            status_val = status_filter.upper()
            valid_statuses = ["ACTIVE", "PAUSED", "DELETED", "ARCHIVED"]
            if status_val in valid_statuses:
                params["filtering"] = f'[{{"field":"effective_status","operator":"IN","value":["{status_val}"]}}]'
    
        # Choose endpoint: campaign-scoped or account-scoped
        if campaign_id:
            endpoint = f"/{campaign_id}/adsets"
        else:
            endpoint = f"/{account_id}/adsets"
    
        try:
            result = api_client.graph_get(
                endpoint,
                fields=ADSET_LIST_FIELDS,
                params=params,
            )
    
            adsets = result.get("data", [])
    
            # Enrich with human-readable budget
            for a in adsets:
                if a.get("daily_budget"):
                    a["daily_budget_display"] = format_budget_cents_to_currency(a["daily_budget"])
                if a.get("lifetime_budget"):
                    a["lifetime_budget_display"] = format_budget_cents_to_currency(a["lifetime_budget"])
    
            # Paginate up to 200
            all_adsets = list(adsets)
            paging = result.get("paging", {})
            while paging.get("next") and len(all_adsets) < 200:
                after_cursor = paging.get("cursors", {}).get("after")
                if not after_cursor:
                    break
                params["after"] = after_cursor
                result = api_client.graph_get(endpoint, fields=ADSET_LIST_FIELDS, params=params)
                next_adsets = result.get("data", [])
                if not next_adsets:
                    break
                for a in next_adsets:
                    if a.get("daily_budget"):
                        a["daily_budget_display"] = format_budget_cents_to_currency(a["daily_budget"])
                    if a.get("lifetime_budget"):
                        a["lifetime_budget_display"] = format_budget_cents_to_currency(a["lifetime_budget"])
                all_adsets.extend(next_adsets)
                paging = result.get("paging", {})
    
            # Count by status
            status_counts = {}
            for a in all_adsets:
                es = a.get("effective_status", "UNKNOWN")
                status_counts[es] = status_counts.get(es, 0) + 1
    
            return {
                "total": len(all_adsets),
                "status_counts": status_counts,
                "adsets": all_adsets,
                "rate_limit_usage_pct": api_client.rate_limits.max_usage_pct,
            }
    
        except MetaAPIError:
            raise
  • The @mcp.tool() decorator that registers 'get_adsets' as an MCP tool.
    @mcp.tool()
  • Schema fields used when fetching ad sets via the Graph API list endpoint.
    ADSET_LIST_FIELDS = [
        "id", "name", "status", "effective_status",
        "campaign_id", "daily_budget", "lifetime_budget",
        "optimization_goal", "billing_event", "bid_strategy",
        "start_time", "end_time",
        "created_time", "updated_time",
    ]
  • Return value shape including total count, status breakdown, enriched ad set list, and rate limit info.
    return {
        "total": len(all_adsets),
        "status_counts": status_counts,
        "adsets": all_adsets,
        "rate_limit_usage_pct": api_client.rate_limits.max_usage_pct,
    }
  • Caller in delete_campaign_structure that uses get_adsets to find all ad sets under a campaign for bulk deletion.
    camp_adsets = get_adsets(account_id, campaign_id=cid)
Behavior2/5

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

No annotations are provided, so the description must disclose behavioral traits. It does not mention that the operation is read-only, whether pagination is supported beyond the limit parameter, or any side effects. It also does not describe the return format or potential errors.

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 concise (9 lines) and front-loaded with the main purpose. Every sentence is necessary and provides clear information without redundancy.

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

Completeness3/5

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

Given the tool has 4 parameters and no output schema, the description covers the parameters adequately but lacks information about the return value format, error handling, or any assumptions. It is adequate for a simple list operation but not fully complete.

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's Args section adds significant meaning beyond the schema titles. It provides an example for account_id, clarifies campaign_id is optional, lists enum values for status_filter, and states the default for limit. This fully compensates for the 0% schema description coverage.

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 'List ad sets for an account or filtered by campaign,' which includes a specific verb ('list') and resource ('ad sets'). It distinguishes from sibling tools like get_adset_details (single ad set) and get_campaigns (different resource).

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 vs alternatives. For example, it does not mention that for a single ad set's details one should use get_adset_details, nor does it specify prerequisites or context for filtering.

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/brandu-mos/konquest-meta-ads-mcp'

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