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(ads): drop video_data from object_story_spec when asset_feed_spec.videos[] is used (Meta 1443048) (#89)
Yves Junqueira0c2150d1673e
diff --git a/meta_ads_mcp/core/ads.py b/meta_ads_mcp/core/ads.pyindex 2d618d8..3ce1705 100644--- a/meta_ads_mcp/core/ads.py+++ b/meta_ads_mcp/core/ads.py@@ -2188,35 +2188,22 @@ async def create_ad_creative(# ------------------------------------------------------------------# Build object_story_spec for asset_feed_spec creatives.- # Meta rejects bare page_id (error 2061015) — needs a link anchor.+ #+ # When asset_feed_spec.videos[] carries the video, object_story_spec+ # MUST contain only page_id (plus instagram_user_id, appended later).+ # Adding a video_data anchor here triggers Meta API v24 error 1443048+ # ("object_story_spec ill formed"). Per Meta's official docs, the+ # canonical shape for asset_feed_spec.videos[] is bare page_id —+ # the video, thumbnail, link URL, and CTA all live in+ # asset_feed_spec.+ # Ref: https://developers.facebook.com/docs/marketing-api/dynamic-creative/dynamic-creative-optimization# ------------------------------------------------------------------- if video_id:- # Single video: use video_data with call_to_action carrying- # the link URL. This is required for Meta to associate the- # video and destination URL with the creative.- video_anchor = {"video_id": video_id}- if thumbnail_url:- video_anchor["image_url"] = thumbnail_url- cta_type = call_to_action_type or "LEARN_MORE"- cta_value = {}- if link_url:- cta_value["link"] = link_url- if lead_gen_form_id:- cta_value["lead_gen_form_id"] = lead_gen_form_id- if phone_number:- cta_value["phone_number"] = phone_number- cta_data = {"type": cta_type}- if cta_value:- cta_data["value"] = cta_value- video_anchor["call_to_action"] = cta_data- creative_data["object_story_spec"] = {- "page_id": page_id,- "video_data": video_anchor- }- elif not is_dof:- # Non-DOF (including PLACEMENT): bare object_story_spec.- # URLs, images, CTA live exclusively in asset_feed_spec.- # Ref: developers.facebook.com/docs/marketing-api/asset-customization-rules+ if video_id or not is_dof:+ # video_id branch: asset_feed_spec.videos already carries the+ # video + thumbnail; link_urls + call_to_action_types carry+ # the destination + CTA. object_story_spec must be bare.+ # Non-DOF image (PLACEMENT etc.) branch: same shape — URLs,+ # images, CTA live exclusively in asset_feed_spec.creative_data["object_story_spec"] = {"page_id": page_id,}diff --git a/tests/test_video_creatives.py b/tests/test_video_creatives.pyindex 4f08c6a..6263b43 100644--- a/tests/test_video_creatives.py+++ b/tests/test_video_creatives.py@@ -167,13 +167,14 @@ async def test_video_creative_with_instagram_actor_id():assert "videos" in afsassert afs["videos"][0]["video_id"] == "vid_333444"- # instagram_user_id must be in object_story_spec (not inside video_data)- # (Meta deprecated instagram_actor_id in Jan 2026; error_subcode 1443050 if inside video_data)+ # PR-C: video metadata moved from object_story_spec.video_data to asset_feed_spec.+ # instagram_user_id stays in object_story_spec (instagram_actor_id deprecated Jan 2026).assert "object_story_spec" in creative_data- video_data = creative_data["object_story_spec"]["video_data"]- assert "instagram_actor_id" not in video_data- assert "instagram_user_id" not in video_data- assert creative_data["object_story_spec"]["instagram_user_id"] == "ig_555666"+ oss = creative_data["object_story_spec"]+ assert "video_data" not in oss+ assert "link_data" not in oss+ assert "instagram_actor_id" not in oss+ assert oss == {"page_id": "123456789", "instagram_user_id": "ig_555666"}@pytest.mark.asyncio@@ -223,13 +224,13 @@ async def test_video_creative_asset_feed_spec_path():assert len(afs["titles"]) == 2assert len(afs["bodies"]) == 2- # Video FLEX: object_story_spec uses video_data with call_to_action- assert "video_data" in creative_data["object_story_spec"]- vd = creative_data["object_story_spec"]["video_data"]- assert vd["video_id"] == "vid_555666"- assert "link" not in vd, "link must NOT be in video_data directly"- assert vd["call_to_action"]["type"] == "LEARN_MORE"- assert vd["call_to_action"]["value"]["link"] == "https://example.com/"+ # PR-C: video metadata moved from object_story_spec.video_data to asset_feed_spec.+ oss = creative_data["object_story_spec"]+ assert "video_data" not in oss+ assert "link_data" not in oss+ assert oss == {"page_id": "123456789"}+ # link relocated from video_data.call_to_action.value.link to asset_feed_spec.link_urls.+ assert afs["link_urls"] == [{"website_url": "https://example.com/"}]@pytest.mark.asyncio@@ -272,13 +273,13 @@ async def test_video_creative_with_dof_optimization():# Auto-fetched thumbnail should be included in videos arrayassert afs["videos"] == [{"video_id": "vid_777888", "thumbnail_url": "https://example.com/auto-thumb.jpg"}]- # Video FLEX: video_data anchor with call_to_action- assert "video_data" in creative_data["object_story_spec"]- vd = creative_data["object_story_spec"]["video_data"]- assert vd["image_url"] == "https://example.com/auto-thumb.jpg"- assert "link" not in vd- assert vd["call_to_action"]["type"] == "LEARN_MORE"- assert vd["call_to_action"]["value"]["link"] == "https://example.com/"+ # PR-C: video metadata moved from object_story_spec.video_data to asset_feed_spec.+ # Thumbnail (was video_data.image_url) is now on asset_feed_spec.videos[].+ oss = creative_data["object_story_spec"]+ assert "video_data" not in oss+ assert "link_data" not in oss+ assert oss == {"page_id": "123456789"}+ assert afs["videos"][0]["thumbnail_url"] == "https://example.com/auto-thumb.jpg"@pytest.mark.asyncio@@ -493,13 +494,12 @@ async def test_video_creative_with_description():assert "videos" in afsassert afs["videos"][0]["video_id"] == "vid_desc_test"- # object_story_spec should use video_data as the anchor (not link_data)- assert "video_data" in creative_data["object_story_spec"]- assert "link_data" not in creative_data["object_story_spec"]-- # description must NOT be in video_data (Meta API v24 rejects it there)- video_data = creative_data["object_story_spec"]["video_data"]- assert "description" not in video_data+ # PR-C: video metadata moved from object_story_spec.video_data to asset_feed_spec.+ # description is carried by asset_feed_spec.descriptions (asserted above).+ oss = creative_data["object_story_spec"]+ assert "video_data" not in oss+ assert "link_data" not in oss+ assert oss == {"page_id": "123456789"}@pytest.mark.asyncio