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.

fix: include image_hash in DOF link_data to prevent "Could not get image" error (#53)

Yves Junqueiraab3fd20d79fb
diff --git a/meta_ads_mcp/core/ads.py b/meta_ads_mcp/core/ads.py
index c3df2ba..860086c 100644
--- a/meta_ads_mcp/core/ads.py
+++ b/meta_ads_mcp/core/ads.py
@@ -1540,6 +1540,8 @@ async def create_ad_creative(
link_data = {"link": link_url}
if image_hashes:
link_data["image_hash"] = image_hashes[0]
+ elif image_hash:
+ link_data["image_hash"] = image_hash
if caption:
link_data["caption"] = caption
if image_crops:
diff --git a/tests/test_ad_formats_flexible.py b/tests/test_ad_formats_flexible.py
index 87441be..25af527 100644
--- a/tests/test_ad_formats_flexible.py
+++ b/tests/test_ad_formats_flexible.py
@@ -342,10 +342,12 @@ class TestFlexibleCreativeFullFlow:
# Single-image: object_story_spec keeps link_data (error 2061015 without it)
# CTA is placed in link_data for DOF creatives.
+ # image_hash in link_data fixes subcode 2446388 "Could not get image"
assert creative_data["object_story_spec"] == {
"page_id": "987654321",
"link_data": {
"link": "https://example.com",
+ "image_hash": "hash1",
"call_to_action": {"type": "SHOP_NOW", "value": {"link": "https://example.com"}},
}
}
diff --git a/tests/test_flex_creatives.py b/tests/test_flex_creatives.py
index 4d9a9b9..86e10b6 100644
--- a/tests/test_flex_creatives.py
+++ b/tests/test_flex_creatives.py
@@ -240,9 +240,11 @@ class TestFlexCreatives:
assert creative_data["asset_feed_spec"]["optimization_type"] == "DEGREES_OF_FREEDOM"
# object_story_spec needs page_id + link_data with destination URL
# (Meta rejects object_story_spec without link — error 2061015)
+ # DOF link_data must include image_hash for Meta to find the image
+ # (fix for subcode 2446388 "Could not get image for creative")
assert creative_data["object_story_spec"] == {
"page_id": "987654321",
- "link_data": {"link": "https://example.com"}
+ "link_data": {"link": "https://example.com", "image_hash": "abc123"}
}
async def test_no_optimization_type_unchanged_behavior(self):