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.
Python advertisingai-agentschatgptclaudefacebook-adsinstagram-adsmcpmeta-adsmodel-context-protocolpipeboard
Fix: Add ON_AD destination_type support for lead generation campaigns
Yves Junqueira98ad48b7b106
diff --git a/meta_ads_mcp/core/adsets.py b/meta_ads_mcp/core/adsets.pyindex e021808..e42c419 100644--- a/meta_ads_mcp/core/adsets.py+++ b/meta_ads_mcp/core/adsets.py@@ -130,8 +130,9 @@ async def create_adset(promoted_object: Mobile app configuration for APP_INSTALLS campaigns. Required fields: application_id, object_store_url.Optional fields: custom_event_type, pixel_id, page_id.Example: {"application_id": "123456789012345", "object_store_url": "https://apps.apple.com/app/id123456789"}- destination_type: Where users are directed after clicking the ad (e.g., 'APP_STORE', 'DEEPLINK', 'APP_INSTALL').- Required for mobile app campaigns.+ destination_type: Where users are directed after clicking the ad (e.g., 'APP_STORE', 'DEEPLINK', 'APP_INSTALL', 'ON_AD').+ Required for mobile app campaigns and lead generation campaigns.+ Use 'ON_AD' for lead generation campaigns where user interaction happens within the ad.access_token: Meta API access token (optional - will use cached token if not provided)"""# Check required parameters@@ -196,7 +197,7 @@ async def create_adset(# Validate destination_type if providedif destination_type:- valid_destination_types = ["APP_STORE", "DEEPLINK", "APP_INSTALL"]+ valid_destination_types = ["APP_STORE", "DEEPLINK", "APP_INSTALL", "ON_AD"]if destination_type not in valid_destination_types:return json.dumps({"error": f"Invalid destination_type: {destination_type}",diff --git a/tests/test_mobile_app_adset_creation.py b/tests/test_mobile_app_adset_creation.pyindex a47d144..fd7e73f 100644--- a/tests/test_mobile_app_adset_creation.py+++ b/tests/test_mobile_app_adset_creation.py@@ -409,6 +409,57 @@ class TestMobileAppAdsetCreation:params = call_args[0][2]assert params['destination_type'] == "APP_INSTALL"+ @pytest.mark.asyncio+ async def test_on_ad_destination_type_for_lead_generation(+ self, mock_api_request, mock_auth_manager, valid_mobile_app_params+ ):+ """Test ON_AD destination_type for lead generation campaigns (Issue #009 fix)"""++ # Create a lead generation adset configuration (without promoted_object since it's for lead gen, not mobile apps)+ lead_gen_params = valid_mobile_app_params.copy()+ lead_gen_params.update({+ "optimization_goal": "LEAD_GENERATION",+ "billing_event": "IMPRESSIONS"+ })++ result = await create_adset(+ **lead_gen_params,+ destination_type="ON_AD"+ )++ # Should pass validation and include destination_type in API call+ call_args = mock_api_request.call_args+ params = call_args[0][2]+ assert params['destination_type'] == "ON_AD"++ @pytest.mark.asyncio+ async def test_on_ad_validation_passes(+ self, mock_api_request, mock_auth_manager, valid_mobile_app_params+ ):+ """Test that ON_AD destination_type passes validation (Issue #009 regression test)"""++ # Use parameters that work with ON_AD (lead generation, not mobile app)+ lead_gen_params = valid_mobile_app_params.copy()+ lead_gen_params.update({+ "optimization_goal": "LEAD_GENERATION",+ "billing_event": "IMPRESSIONS"+ })++ result = await create_adset(+ **lead_gen_params,+ destination_type="ON_AD"+ )++ result_data = json.loads(result)++ # Should NOT return a validation error about destination_type+ # Before the fix, this would return: "Invalid destination_type: ON_AD"+ if "data" in result_data:+ error_data = json.loads(result_data["data"])+ assert "error" not in error_data or "destination_type" not in error_data.get("error", "").lower()+ else:+ assert "error" not in result_data or "destination_type" not in result_data.get("error", "").lower()+# Test: Error Handling@pytest.mark.asyncioasync def test_meta_api_error_handling(