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: expand optimization_goal docs for OUTCOME_ENGAGEMENT and fix flaky URL tests (#64)
Yves Junqueirac96485614a87
diff --git a/meta_ads_mcp/core/adsets.py b/meta_ads_mcp/core/adsets.pyindex d11b7bd..83dfd45 100644--- a/meta_ads_mcp/core/adsets.py+++ b/meta_ads_mcp/core/adsets.py@@ -119,7 +119,18 @@ async def create_adset(account_id: Meta Ads account ID (format: act_XXXXXXXXX)campaign_id: Meta Ads campaign ID this ad set belongs toname: Ad set name- optimization_goal: Conversion optimization goal (e.g., 'LINK_CLICKS', 'REACH', 'CONVERSIONS', 'APP_INSTALLS', 'VALUE')+ optimization_goal: Conversion optimization goal. Valid values depend on the campaign objective and destination_type.+ OUTCOME_ENGAGEMENT + destination_type=WEBSITE: OFFSITE_CONVERSIONS, LANDING_PAGE_VIEWS, LINK_CLICKS, IMPRESSIONS, REACH.+ OUTCOME_ENGAGEMENT + On Post: POST_ENGAGEMENT, IMPRESSIONS, REACH.+ OUTCOME_ENGAGEMENT + On Video: THRUPLAY, TWO_SECOND_CONTINUOUS_VIDEO_VIEWS.+ OUTCOME_ENGAGEMENT + On Event: EVENT_RESPONSES, IMPRESSIONS, POST_ENGAGEMENT, REACH.+ OUTCOME_ENGAGEMENT + On Page: PAGE_LIKES.+ OUTCOME_ENGAGEMENT + Messaging (MESSENGER/WHATSAPP/INSTAGRAM_DIRECT): CONVERSATIONS, LINK_CLICKS.+ OUTCOME_TRAFFIC + WEBSITE: LANDING_PAGE_VIEWS, LINK_CLICKS, IMPRESSIONS, REACH.+ OUTCOME_AWARENESS: REACH, IMPRESSIONS, AD_RECALL_LIFT, THRUPLAY.+ OUTCOME_LEADS: LEAD_GENERATION, QUALITY_LEAD (forms), QUALITY_CALL (calls), OFFSITE_CONVERSIONS, LINK_CLICKS (website).+ OUTCOME_SALES: OFFSITE_CONVERSIONS, VALUE, CONVERSATIONS, LINK_CLICKS, IMPRESSIONS, REACH.+ OUTCOME_APP_PROMOTION: APP_INSTALLS, APP_INSTALLS_AND_OFFSITE_CONVERSIONS, VALUE.billing_event: How you're charged (e.g., 'IMPRESSIONS', 'LINK_CLICKS')status: Initial ad set status (default: PAUSED)daily_budget: Daily budget in account currency (in cents) as a stringdiff --git a/tests/test_duplication.py b/tests/test_duplication.pyindex 7ed4328..513c061 100644--- a/tests/test_duplication.py+++ b/tests/test_duplication.py@@ -90,28 +90,28 @@ async def test_forward_duplication_request_with_both_tokens():await _forward_duplication_request("campaign", "123456789", None, {"name_suffix": " - Test"})- result_json = json.loads(str(exc_info.value))+ result_json = json.loads(str(exc_info.value))- # Should raise with premium feature message for 403 response- assert result_json["error"] == "premium_feature_required"- assert "premium feature" in result_json["message"]+ # Should raise with premium feature message for 403 response+ assert result_json["error"] == "premium_feature_required"+ assert "premium feature" in result_json["message"]- # Verify the HTTP request was made with correct parameters- mock_client.return_value.__aenter__.return_value.post.assert_called_once()- call_args = mock_client.return_value.__aenter__.return_value.post.call_args-- # Check URL- assert call_args[0][0] == "https://mcp.pipeboard.co/api/meta/duplicate/campaign/123456789"-- # Check dual headers (the key change!)- headers = call_args[1]["headers"]- assert headers["Authorization"] == "Bearer facebook_token" # Facebook token for Meta API- assert headers["X-Pipeboard-Token"] == "pipeboard_token" # Pipeboard token for auth- assert headers["Content-Type"] == "application/json"-- # Check JSON payload- json_payload = call_args[1]["json"]- assert json_payload == {"name_suffix": " - Test"}+ # Verify the HTTP request was made with correct parameters+ mock_client.return_value.__aenter__.return_value.post.assert_called_once()+ call_args = mock_client.return_value.__aenter__.return_value.post.call_args++ # Check URL+ assert call_args[0][0] == "https://mcp.pipeboard.co/api/meta/duplicate/campaign/123456789"++ # Check dual headers (the key change!)+ headers = call_args[1]["headers"]+ assert headers["Authorization"] == "Bearer facebook_token" # Facebook token for Meta API+ assert headers["X-Pipeboard-Token"] == "pipeboard_token" # Pipeboard token for auth+ assert headers["Content-Type"] == "application/json"++ # Check JSON payload+ json_payload = call_args[1]["json"]+ assert json_payload == {"name_suffix": " - Test"}@pytest.mark.asynciodiff --git a/tests/test_duplication_regression.py b/tests/test_duplication_regression.pyindex 25ebbcf..9138e22 100644--- a/tests/test_duplication_regression.py+++ b/tests/test_duplication_regression.py@@ -141,24 +141,25 @@ class TestDuplicationAPIContract:for resource_type, resource_id, expected_url in test_cases:# Mock dual-header authentication- with patch("meta_ads_mcp.core.duplication.FastMCPAuthIntegration") as mock_auth:- mock_auth.get_pipeboard_token.return_value = "pipeboard_token"- mock_auth.get_auth_token.return_value = "facebook_token"-- with patch("meta_ads_mcp.core.duplication.httpx.AsyncClient") as mock_client:- mock_response = MagicMock()- mock_response.status_code = 200- mock_response.json.return_value = {"success": True}- mock_client.return_value.__aenter__.return_value.post.return_value = mock_response-- await duplication._forward_duplication_request(- resource_type, resource_id, "test_token", {}- )-- # Verify the correct URL was called- call_args = mock_client.return_value.__aenter__.return_value.post.call_args- actual_url = call_args[0][0]- assert actual_url == expected_url, f"Expected {expected_url}, got {actual_url}"+ with patch.dict(os.environ, {"PIPEBOARD_API_BASE_URL": "https://mcp.pipeboard.co"}):+ with patch("meta_ads_mcp.core.duplication.FastMCPAuthIntegration") as mock_auth:+ mock_auth.get_pipeboard_token.return_value = "pipeboard_token"+ mock_auth.get_auth_token.return_value = "facebook_token"++ with patch("meta_ads_mcp.core.duplication.httpx.AsyncClient") as mock_client:+ mock_response = MagicMock()+ mock_response.status_code = 200+ mock_response.json.return_value = {"success": True}+ mock_client.return_value.__aenter__.return_value.post.return_value = mock_response++ await duplication._forward_duplication_request(+ resource_type, resource_id, "test_token", {}+ )++ # Verify the correct URL was called+ call_args = mock_client.return_value.__aenter__.return_value.post.call_args+ actual_url = call_args[0][0]+ assert actual_url == expected_url, f"Expected {expected_url}, got {actual_url}"@pytest.mark.asyncioasync def test_request_headers_format(self, enable_feature):