Skip to main content
Glama
dhawalshah

meta-ads-mcp

get_adsets_by_campaign

Fetch ad sets from a Facebook campaign, applying status filters, field selection, and pagination to analyze performance.

Instructions

Retrieves ad sets associated with a specific Facebook campaign.

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

Args: campaign_id (str): The ID of the campaign to retrieve ad sets from. 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']. effective_status (Optional[List[str]]): Filter ad sets by their effective status. Options include: 'ACTIVE', 'PAUSED', 'DELETED', 'PENDING_REVIEW', 'DISAPPROVED', 'PREAPPROVED', 'PENDING_BILLING_INFO', '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 all active ad sets from a campaign adsets = get_adsets_by_campaign( campaign_id="23843211234567", fields=["name", "effective_status", "daily_budget", "targeting", "optimization_goal"], effective_status=["ACTIVE"], limit=50 )

# Get ad sets with specific optimization goals
conversion_adsets = get_adsets_by_campaign(
    campaign_id="23843211234567",
    fields=["name", "optimization_goal", "billing_event", "bid_amount"],
    filtering=[{
        'field': 'optimization_goal', 
        'operator': 'IN', 
        'value': ['OFFSITE_CONVERSIONS', 'VALUE']
    }]
)

# 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_campaign(
        campaign_id="23843211234567",
        fields=["name", "effective_status", "daily_budget", "targeting"],
        effective_status=["ACTIVE"],
        limit=50,
        after=next_page_cursor
    )
```

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
afterNo
limitNo
beforeNo
fieldsNo
filteringNo
campaign_idYes
date_formatNo
effective_statusNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.1/5.0
Behavior4/5

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

With no annotations, the description carries the full behavioral burden and does so well: it explains default field behavior, filter object structure and operators, pagination cursors, effective_status options, date formats, and the response envelope. It doesn't address auth, rate limits, or errors, but the read-only retrieval nature and response shape are disclosed clearly enough.

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 long but well organized: purpose first, then Args, Returns, and a multi-scenario Example section. Every section earns its place, though the text could be tightened without losing critical details.

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 an 8-parameter tool with no annotations, the description is effectively self-contained: every parameter is explained, the return structure ('data' and 'paging') is specified, and examples cover basic queries, filtering, and pagination. Referencing get_adset_by_id for the full field list is an appropriate pointer rather than a gap.

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 input schema has 0% description coverage and no enums, yet the description fully documents all eight parameters, including defaults, the 25/100 limit, filter object requirements, available operators, pagination source fields, status options, and date format choices. This adds substantial meaning that the schema alone completely lacks.

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?

States a specific verb ('Retrieves') and resource ('ad sets associated with a specific Facebook campaign'), and the campaign scoping is unambiguous. It doesn't explicitly compare itself to sibling tools like get_adsets_by_adaccount or get_adsets_by_ids, so differentiation is mostly left to the name and required parameter.

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

Usage Guidelines3/5

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

The description clearly implies usage: pass a campaign_id to get that campaign's ad sets, and the examples demonstrate realistic filtering and pagination workflows. However, it never states when to prefer this tool over account-level or single-ad-set siblings, and there are no explicit exclusion criteria.

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