Skip to main content
Glama
dhawalshah

meta-ads-mcp

get_adsets_by_adaccount

Retrieve ad sets from a Facebook ad account with filtering, pagination, and field selection to analyze campaign performance.

Instructions

Retrieves ad sets from a specific Facebook ad account.

This function allows querying all ad sets belonging to a specific ad account with various filtering options, pagination, and field selection.

Args: act_id (str): The ID of the ad account to retrieve ad sets from, prefixed with 'act_', e.g., 'act_1234567890'. fields (Optional[List[str]]): A list of specific fields to retrieve for each ad set. If None, a default set of fields will be returned. See get_adset_by_id for a comprehensive list of available fields. filtering (Optional[List[dict]]): A list of filter objects to apply to the data. Each object should have 'field', 'operator', and 'value' keys. Operators include: 'EQUAL', 'NOT_EQUAL', 'GREATER_THAN', 'GREATER_THAN_OR_EQUAL', 'LESS_THAN', 'LESS_THAN_OR_EQUAL', 'IN_RANGE', 'NOT_IN_RANGE', 'CONTAIN', 'NOT_CONTAIN', 'IN', 'NOT_IN', 'EMPTY', 'NOT_EMPTY'. Example: [{'field': 'daily_budget', 'operator': 'GREATER_THAN', 'value': 1000}] limit (Optional[int]): Maximum number of ad sets to return per page. Default is 25, max is 100. after (Optional[str]): Pagination cursor for the next page. From response['paging']['cursors']['after']. before (Optional[str]): Pagination cursor for the previous page. From response['paging']['cursors']['before']. date_preset (Optional[str]): A predefined relative date range for selecting ad sets. Options include: 'today', 'yesterday', 'this_month', 'last_month', 'this_quarter', 'lifetime', 'last_3d', 'last_7d', 'last_14d', 'last_28d', 'last_30d', 'last_90d', 'last_quarter', 'last_year', 'this_week_mon_today', 'this_week_sun_today', 'this_year'. time_range (Optional[Dict[str, str]]): A custom time range with 'since' and 'until' dates in 'YYYY-MM-DD' format. Example: {'since': '2023-01-01', 'until': '2023-01-31'} updated_since (Optional[int]): Return ad sets that have been updated since this Unix timestamp. effective_status (Optional[List[str]]): Filter ad sets by their effective status. Options include: 'ACTIVE', 'PAUSED', 'DELETED', 'PENDING_REVIEW', 'DISAPPROVED', 'PREAPPROVED', 'PENDING_BILLING_INFO', 'CAMPAIGN_PAUSED', 'ARCHIVED', 'WITH_ISSUES'. date_format (Optional[str]): Format for date responses. Options: - 'U': Unix timestamp (seconds since epoch) - 'Y-m-d H:i:s': MySQL datetime format - None: ISO 8601 format (default)

Returns: Dict: A dictionary containing the requested ad sets. The main results are in the 'data' list, and pagination info is in the 'paging' object.

Example: ```python # Get active ad sets from an ad account adsets = get_adsets_by_adaccount( act_id="act_123456789", fields=["name", "campaign_id", "effective_status", "daily_budget", "targeting"], effective_status=["ACTIVE"], limit=50 )

# Get ad sets with daily budget above a certain amount
high_budget_adsets = get_adsets_by_adaccount(
    act_id="act_123456789",
    fields=["name", "daily_budget", "lifetime_budget"],
    filtering=[{'field': 'daily_budget', 'operator': 'GREATER_THAN', 'value': 5000}],
    limit=100
)

# Fetch the next page if available using the pagination cursor
next_page_cursor = adsets.get("paging", {}).get("cursors", {}).get("after")
if next_page_cursor:
    next_page = get_adsets_by_adaccount(
        act_id="act_123456789",
        fields=["name", "campaign_id", "effective_status", "daily_budget"],
        effective_status=["ACTIVE"],
        limit=50,
        after=next_page_cursor
    )
```

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
afterNo
limitNo
act_idYes
beforeNo
fieldsNo
filteringNo
time_rangeNo
date_formatNo
date_presetNo
updated_sinceNo
effective_statusNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.8/5.0
Behavior5/5

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

With no annotations provided, the description carries full behavioral burden, and it delivers: it documents default field behavior, default and maximum pagination limits, cursor usage, date format options, status filters, and the response shape in 'data' and 'paging'. It also demonstrates pagination with a concrete example, which is exactly the kind of runtime behavior an agent needs.

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?

Although long, the description is structured into summary, Args, Returns, and Example, and every section earns its place given 11 parameters and no enum support in the schema. The one-sentence purpose is front-loaded, and the examples are functional rather than filler.

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?

For a read-style list operation with 11 parameters, the description leaves little unexplained: all parameter semantics, return structure, pagination flow, and a full usage pattern are included. With an output schema present and no annotations, this is as complete as an agent needs to invoke it correctly.

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 description coverage is 0%, and the description compensates fully: act_id prefix format, fields default semantics, filtering operator list with an example, limit default/max, pagination cursor provenance, date_preset options, time_range format, updated_since units, effective_status options, and date_format choices are all spelled out. This goes far beyond the bare parameter titles in the schema.

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 opens with a specific verb and object: 'Retrieves ad sets from a specific Facebook ad account,' and clarifies the scope as 'all ad sets belonging to a specific ad account.' This scope separates it from sibling tools like get_adsets_by_campaign or get_adset_by_id, even though those siblings aren't named.

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?

It clearly states the tool is for querying all ad sets by ad account, with filtering, pagination, and field selection. It does not explicitly name alternatives or state when not to use it, but the ad-account-scoped context is clear enough for an agent to select it over campaign/id-based variants.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.