list_ad_sets
Retrieve ad sets from Meta Ads accounts or campaigns to manage advertising groups and analyze campaign structure.
Instructions
List ad sets under an account or campaign.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ad_account_id | Yes | ||
| meta_access_token | No | ||
| page_size | No | ||
| campaign_id | No | ||
| page_cursor | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- The implementation of the `list_ad_sets` tool handler, which fetches ad set data from the Meta Graph API.
@mcp_server.tool() @meta_api_tool async def list_ad_sets( ad_account_id: str, meta_access_token: Optional[str] = None, page_size: int = 10, campaign_id: str = "", page_cursor: str = "", ) -> str: """List ad sets under an account or campaign.""" if not ad_account_id: return _json({"error": "No account ID specified"}) target = campaign_id or ad_account_id endpoint = f"{target}/adsets" params: Dict[str, Any] = { "fields": ( "id,name,campaign_id,status,daily_budget,lifetime_budget,targeting,bid_amount,bid_strategy," "bid_constraints,optimization_goal,billing_event,start_time,end_time,created_time,updated_time," "is_dynamic_creative,frequency_control_specs{event,interval_days,max_frequency}" ), "page_size": int(page_size), } if page_cursor: params["page_cursor"] = page_cursor payload = await make_api_request(endpoint, meta_access_token, params) return _json(payload)