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: remove unsupported link field from video_data in object_story_spec
Yves Junqueiraa8ad25148014
diff --git a/meta_ads_mcp/core/ads.py b/meta_ads_mcp/core/ads.pyindex 257833f..a7c4078 100644--- a/meta_ads_mcp/core/ads.py+++ b/meta_ads_mcp/core/ads.py@@ -1030,11 +1030,12 @@ async def create_ad_creative(# For dynamic/FLEX creatives with asset_feed_spec, object_story_spec still# needs page_id and a media anchor (Meta API requires this).if is_video:+ # video_data does NOT support "link" directly — URL goes in+ # call_to_action.value.link or is handled by asset_feed_spec.link_urls.creative_data["object_story_spec"] = {"page_id": page_id,"video_data": {"video_id": video_id,- "link": link_url}}else:@@ -1046,10 +1047,11 @@ async def create_ad_creative(}else:if is_video:- # Use object_story_spec with video_data for simple video creatives+ # Use object_story_spec with video_data for simple video creatives.+ # NOTE: video_data does NOT support a "link" field directly.+ # The destination URL goes in call_to_action.value.link.video_data = {"video_id": video_id,- "link": link_url}if thumbnail_url:@@ -1064,10 +1066,19 @@ async def create_ad_creative(if description:video_data["description"] = description- if call_to_action_type:- cta_data = {"type": call_to_action_type}- if lead_gen_form_id:- cta_data["value"] = {"lead_gen_form_id": lead_gen_form_id}+ # Build call_to_action with the destination URL.+ # For video creatives, link_url MUST go in call_to_action.value.link+ # (not as a top-level field in video_data).+ 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+ cta_type = call_to_action_type or ("LEARN_MORE" if link_url else None)+ if cta_type:+ cta_data = {"type": cta_type}+ if cta_value:+ cta_data["value"] = cta_valuevideo_data["call_to_action"] = cta_data# Instagram actor ID goes inside video_data for proper Instagram deliverydiff --git a/tests/test_video_creatives.py b/tests/test_video_creatives.pyindex 15e7933..21a52f6 100644--- a/tests/test_video_creatives.py+++ b/tests/test_video_creatives.py@@ -61,11 +61,12 @@ async def test_simple_video_creative_uses_video_data():video_data = creative_data["object_story_spec"]["video_data"]assert video_data["video_id"] == "vid_987654"- assert video_data["link"] == "https://example.com/"+ assert "link" not in video_data, "link must NOT be in video_data directly"assert video_data["message"] == "Check out this video"assert video_data["title"] == "Watch Now"assert video_data["description"] == "Amazing content"assert video_data["call_to_action"]["type"] == "LEARN_MORE"+ assert video_data["call_to_action"]["value"]["link"] == "https://example.com/"@pytest.mark.asyncio@@ -100,6 +101,9 @@ async def test_video_creative_with_thumbnail():assert video_data["image_url"] == "https://example.com/thumb.jpg"assert video_data["video_id"] == "vid_111222"+ # link_url should be in call_to_action.value.link with default CTA type+ assert video_data["call_to_action"]["type"] == "LEARN_MORE"+ assert video_data["call_to_action"]["value"]["link"] == "https://example.com/"@pytest.mark.asyncio@@ -185,9 +189,10 @@ async def test_video_creative_asset_feed_spec_path():assert len(afs["titles"]) == 2assert len(afs["bodies"]) == 2- # object_story_spec should use video_data anchor+ # object_story_spec should use video_data anchor without "link"assert "video_data" in creative_data["object_story_spec"]assert creative_data["object_story_spec"]["video_data"]["video_id"] == "vid_555666"+ assert "link" not in creative_data["object_story_spec"]["video_data"]@pytest.mark.asyncio@@ -225,6 +230,9 @@ async def test_video_creative_with_dof_optimization():assert "videos" in afsassert afs["videos"] == [{"video_id": "vid_777888"}]+ # video_data anchor should not contain "link"+ assert "link" not in creative_data["object_story_spec"]["video_data"]+@pytest.mark.asyncioasync def test_video_and_image_hash_mutual_exclusivity():@@ -327,7 +335,9 @@ async def test_video_creative_with_lead_gen():creative_data = mock_api.call_args_list[0][0][2]video_data = creative_data["object_story_spec"]["video_data"]+ assert "link" not in video_data, "link must NOT be in video_data directly"assert video_data["call_to_action"]["type"] == "SIGN_UP"+ assert video_data["call_to_action"]["value"]["link"] == "https://example.com/"assert video_data["call_to_action"]["value"]["lead_gen_form_id"] == "form_12345"