Skip to content

Meta Ads (Facebook/Instagram) MCP server for Claude, ChatGPT, Perplexity & Cursor — the Meta node of Pipeboard’s 5-platform family (+ Google, TikTok, Snap, Reddit). Hosted remote MCP, badged Meta Business Partner, free plan — no self-hosting required.

feat: add dsa_payor to create_adset/update_adset and fetch fields

Yves Junqueira3d633bfeb226
diff --git a/meta_ads_mcp/core/adsets.py b/meta_ads_mcp/core/adsets.py
index 9642eac..1fef28a 100644
--- a/meta_ads_mcp/core/adsets.py
+++ b/meta_ads_mcp/core/adsets.py
@@ -67,7 +67,7 @@ async def get_adset_details(adset_id: str, access_token: Optional[str] = None) -
endpoint = f"{adset_id}"
# Explicitly prioritize frequency_control_specs in the fields request
params = {
- "fields": "id,name,campaign_id,status,frequency_control_specs{event,interval_days,max_frequency},daily_budget,lifetime_budget,targeting,bid_amount,bid_strategy,bid_constraints,optimization_goal,billing_event,start_time,end_time,created_time,updated_time,attribution_spec,destination_type,promoted_object,pacing_type,budget_remaining,dsa_beneficiary,is_dynamic_creative"
+ "fields": "id,name,campaign_id,status,frequency_control_specs{event,interval_days,max_frequency},daily_budget,lifetime_budget,targeting,bid_amount,bid_strategy,bid_constraints,optimization_goal,billing_event,start_time,end_time,created_time,updated_time,attribution_spec,destination_type,promoted_object,pacing_type,budget_remaining,dsa_beneficiary,dsa_payor,is_dynamic_creative"
}
data = await make_api_request(endpoint, access_token, params)
@@ -99,6 +99,7 @@ async def create_adset(
start_time: Optional[str] = None,
end_time: Optional[str] = None,
dsa_beneficiary: Optional[str] = None,
+ dsa_payor: Optional[str] = None,
promoted_object: Optional[Dict[str, Any]] = None,
destination_type: Optional[str] = None,
is_dynamic_creative: Optional[bool] = None,
@@ -139,7 +140,10 @@ async def create_adset(
Meta will show effective_status as SCHEDULED and automatically begin delivery at start_time.
NOTE: Only ad set start_time controls delivery scheduling. Campaigns do not support start_time.
end_time: End time in ISO 8601 format. Required when lifetime_budget is specified.
- dsa_beneficiary: DSA beneficiary for European compliance
+ dsa_beneficiary: DSA beneficiary for European compliance (person/org that benefits from ads).
+ Required for EU-targeted ad sets along with dsa_payor.
+ dsa_payor: DSA payor for European compliance (person/org paying for the ads).
+ Required for EU-targeted ad sets along with dsa_beneficiary.
promoted_object: App config for APP_INSTALLS. Required: application_id, object_store_url.
destination_type: Where users go after click. Common values: 'WEBSITE', 'WHATSAPP', 'MESSENGER',
'INSTAGRAM_DIRECT', 'ON_AD', 'APP', 'FACEBOOK', 'SHOP_AUTOMATIC'.
@@ -325,10 +329,12 @@ async def create_adset(
if end_time:
params["end_time"] = end_time
- # Add DSA beneficiary if provided
+ # Add DSA fields if provided (both required for EU-targeted ad sets)
if dsa_beneficiary:
params["dsa_beneficiary"] = dsa_beneficiary
-
+ if dsa_payor:
+ params["dsa_payor"] = dsa_payor
+
# Add mobile app parameters if provided
if promoted_object:
params["promoted_object"] = json.dumps(promoted_object)
@@ -385,6 +391,8 @@ async def update_adset(adset_id: str, frequency_control_specs: Optional[List[Dic
is_dynamic_creative: Optional[bool] = None,
start_time: Optional[str] = None,
end_time: Optional[str] = None,
+ dsa_beneficiary: Optional[str] = None,
+ dsa_payor: Optional[str] = None,
access_token: Optional[str] = None) -> str:
"""
Update an ad set with new settings including frequency caps and budgets.
@@ -413,6 +421,10 @@ async def update_adset(adset_id: str, frequency_control_specs: Optional[List[Dic
start_time: Start time in ISO 8601 format (e.g., '2023-12-01T12:00:00-0800').
Use with status=ACTIVE to schedule the ad set for future delivery (effective_status will be SCHEDULED until start_time).
end_time: End time in ISO 8601 format. Required when lifetime_budget is specified.
+ dsa_beneficiary: DSA beneficiary for European compliance (person/org that benefits from ads).
+ Required for EU-targeted ad sets along with dsa_payor.
+ dsa_payor: DSA payor for European compliance (person/org paying for the ads).
+ Required for EU-targeted ad sets along with dsa_beneficiary.
access_token: Meta API access token (optional - will use cached token if not provided)
"""
if not adset_id:
@@ -502,6 +514,12 @@ async def update_adset(adset_id: str, frequency_control_specs: Optional[List[Dic
if end_time is not None:
params['end_time'] = end_time
+ if dsa_beneficiary is not None:
+ params['dsa_beneficiary'] = dsa_beneficiary
+
+ if dsa_payor is not None:
+ params['dsa_payor'] = dsa_payor
+
if not params:
return json.dumps({"error": "No update parameters provided"}, indent=2)