meta-ads-mcp 0.7.8__py3-none-any.whl → 0.7.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
meta_ads_mcp/__init__.py CHANGED
@@ -7,7 +7,7 @@ with the Claude LLM.
7
7
 
8
8
  from meta_ads_mcp.core.server import main
9
9
 
10
- __version__ = "0.7.8"
10
+ __version__ = "0.7.9"
11
11
 
12
12
  __all__ = [
13
13
  'get_ad_accounts',
meta_ads_mcp/core/ads.py CHANGED
@@ -171,7 +171,7 @@ async def get_ad_creatives(access_token: str = None, ad_id: str = None) -> str:
171
171
 
172
172
  endpoint = f"{ad_id}/adcreatives"
173
173
  params = {
174
- "fields": "id,name,status,thumbnail_url,image_url,image_hash,object_story_spec" # Added image_hash
174
+ "fields": "id,name,status,thumbnail_url,image_url,image_hash,object_story_spec,asset_feed_spec,image_urls_for_viewing"
175
175
  }
176
176
 
177
177
  data = await make_api_request(endpoint, access_token, params)
@@ -279,14 +279,26 @@ async def get_ad_image(access_token: str = None, ad_id: str = None) -> Image:
279
279
  if "data" in creative_data and creative_data["data"]:
280
280
  creative = creative_data["data"][0]
281
281
 
282
- # Try image_urls_for_viewing first (usually higher quality)
282
+ # Prioritize higher quality image URLs in this order:
283
+ # 1. image_urls_for_viewing (usually highest quality)
284
+ # 2. image_url (direct field)
285
+ # 3. object_story_spec.link_data.picture (usually full size)
286
+ # 4. thumbnail_url (last resort - often profile thumbnail)
287
+
283
288
  if "image_urls_for_viewing" in creative and creative["image_urls_for_viewing"]:
284
289
  image_url = creative["image_urls_for_viewing"][0]
285
290
  print(f"Using image_urls_for_viewing: {image_url}")
286
- # Fall back to thumbnail_url
291
+ elif "image_url" in creative and creative["image_url"]:
292
+ image_url = creative["image_url"]
293
+ print(f"Using image_url: {image_url}")
294
+ elif "object_story_spec" in creative and "link_data" in creative["object_story_spec"]:
295
+ link_data = creative["object_story_spec"]["link_data"]
296
+ if "picture" in link_data and link_data["picture"]:
297
+ image_url = link_data["picture"]
298
+ print(f"Using object_story_spec.link_data.picture: {image_url}")
287
299
  elif "thumbnail_url" in creative and creative["thumbnail_url"]:
288
300
  image_url = creative["thumbnail_url"]
289
- print(f"Using thumbnail_url: {image_url}")
301
+ print(f"Using thumbnail_url (fallback): {image_url}")
290
302
 
291
303
  if not image_url:
292
304
  return "Error: No image URLs found in creative"
@@ -78,23 +78,31 @@ ad_creative_images = {}
78
78
  def extract_creative_image_urls(creative: Dict[str, Any]) -> List[str]:
79
79
  """
80
80
  Extract image URLs from a creative object for direct viewing.
81
+ Prioritizes higher quality images over thumbnails.
81
82
 
82
83
  Args:
83
84
  creative: Meta Ads creative object
84
85
 
85
86
  Returns:
86
- List of image URLs found in the creative
87
+ List of image URLs found in the creative, prioritized by quality
87
88
  """
88
89
  image_urls = []
89
90
 
91
+ # Prioritize higher quality image URLs in this order:
92
+ # 1. image_urls_for_viewing (usually highest quality)
93
+ # 2. image_url (direct field)
94
+ # 3. object_story_spec.link_data.picture (usually full size)
95
+ # 4. asset_feed_spec images (multiple high-quality images)
96
+ # 5. thumbnail_url (last resort - often profile thumbnail)
97
+
98
+ # Check for image_urls_for_viewing (highest priority)
99
+ if "image_urls_for_viewing" in creative and creative["image_urls_for_viewing"]:
100
+ image_urls.extend(creative["image_urls_for_viewing"])
101
+
90
102
  # Check for direct image_url field
91
103
  if "image_url" in creative and creative["image_url"]:
92
104
  image_urls.append(creative["image_url"])
93
105
 
94
- # Check for thumbnail_url field
95
- if "thumbnail_url" in creative and creative["thumbnail_url"]:
96
- image_urls.append(creative["thumbnail_url"])
97
-
98
106
  # Check object_story_spec for image URLs
99
107
  if "object_story_spec" in creative:
100
108
  story_spec = creative["object_story_spec"]
@@ -103,7 +111,7 @@ def extract_creative_image_urls(creative: Dict[str, Any]) -> List[str]:
103
111
  if "link_data" in story_spec:
104
112
  link_data = story_spec["link_data"]
105
113
 
106
- # Check for picture field
114
+ # Check for picture field (usually full size)
107
115
  if "picture" in link_data and link_data["picture"]:
108
116
  image_urls.append(link_data["picture"])
109
117
 
@@ -121,6 +129,10 @@ def extract_creative_image_urls(creative: Dict[str, Any]) -> List[str]:
121
129
  if "url" in image and image["url"]:
122
130
  image_urls.append(image["url"])
123
131
 
132
+ # Check for thumbnail_url field (lowest priority)
133
+ if "thumbnail_url" in creative and creative["thumbnail_url"]:
134
+ image_urls.append(creative["thumbnail_url"])
135
+
124
136
  # Remove duplicates while preserving order
125
137
  seen = set()
126
138
  unique_urls = []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meta-ads-mcp
3
- Version: 0.7.8
3
+ Version: 0.7.9
4
4
  Summary: Model Context Protocol (MCP) plugin for interacting with Meta Ads API
5
5
  Project-URL: Homepage, https://github.com/pipeboard-co/meta-ads-mcp
6
6
  Project-URL: Bug Tracker, https://github.com/pipeboard-co/meta-ads-mcp/issues
@@ -1,8 +1,8 @@
1
- meta_ads_mcp/__init__.py,sha256=BiSbN8PrAeLKejVnkAfsz06KLVM59vQJmehwssDnEzc,1492
1
+ meta_ads_mcp/__init__.py,sha256=Ge5-JTZbLcmw6V6e25ojPoaGG6le-XRkrrbxBV5ipH8,1492
2
2
  meta_ads_mcp/__main__.py,sha256=XaQt3iXftG_7f0Zu7Wop9SeFgrD2WBn0EQOaPMc27d8,207
3
3
  meta_ads_mcp/core/__init__.py,sha256=6nYdue6yRepkt6JTAoPGhGbS51qfDSvmczRrDwYOG6A,1709
4
4
  meta_ads_mcp/core/accounts.py,sha256=4IAdGLZ4WE4j4pGW6E0qaXcXqbUIW6Wk2kuQUtlmRTQ,4030
5
- meta_ads_mcp/core/ads.py,sha256=aaK70mgfhBJRXr4cdkKag5mjYzvHuHpRttJvTMzPk4Y,36156
5
+ meta_ads_mcp/core/ads.py,sha256=Fcdi1Oa3W-NyY8lXdglkCP1xrYT4YdNSy6acxl6qtzY,37002
6
6
  meta_ads_mcp/core/ads_library.py,sha256=BBGVbtjO5eFV42iiY3XPU-wIV8HupzUKpHgPBrydSvU,3232
7
7
  meta_ads_mcp/core/adsets.py,sha256=vY5JNHmGK1a_sQ5B1LnjxLYXzs5_jOajTTjWHRDJ4_Y,12518
8
8
  meta_ads_mcp/core/api.py,sha256=aAzM6Q75VQOFXtr5D-mDmBRhxWK4wsiODsJYnR3mpDI,14994
@@ -20,9 +20,9 @@ meta_ads_mcp/core/reports.py,sha256=Dv3hfsPOR7IZ9WrYrKd_6SNgZl-USIphg7knva3UYAw,
20
20
  meta_ads_mcp/core/resources.py,sha256=-zIIfZulpo76vcKv6jhAlQq91cR2SZ3cjYZt3ek3x0w,1236
21
21
  meta_ads_mcp/core/server.py,sha256=WhbAag7xdhbGcp7rnU4sKhqXJ8Slapa_ba3T23Yp_2U,17889
22
22
  meta_ads_mcp/core/targeting.py,sha256=3HW1qirEdwaQurlBZGenbIwawcb5J06ghJKRfgu9ZEs,6318
23
- meta_ads_mcp/core/utils.py,sha256=ofKUhyo-5SZoJVuBeTVFPPQCffk0UKpwmDMrd8qQxNc,8715
24
- meta_ads_mcp-0.7.8.dist-info/METADATA,sha256=HjCu4iRgkgfEv5WYS3-E6CchfrkassZHZjMVbgfOphE,20409
25
- meta_ads_mcp-0.7.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
26
- meta_ads_mcp-0.7.8.dist-info/entry_points.txt,sha256=Dv2RkoBjRJBqj6CyhwqGIiwPCD-SCL1-7B9-zmVRuv0,57
27
- meta_ads_mcp-0.7.8.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
28
- meta_ads_mcp-0.7.8.dist-info/RECORD,,
23
+ meta_ads_mcp/core/utils.py,sha256=ytj41yC5SqduLrAiZYBSd6OUwlJRaIClTwnnYKpNFds,9387
24
+ meta_ads_mcp-0.7.9.dist-info/METADATA,sha256=BThlFWPWAY5G88QRv0JzX_A79WcyTTtbUAbikcfYbhc,20409
25
+ meta_ads_mcp-0.7.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
26
+ meta_ads_mcp-0.7.9.dist-info/entry_points.txt,sha256=Dv2RkoBjRJBqj6CyhwqGIiwPCD-SCL1-7B9-zmVRuv0,57
27
+ meta_ads_mcp-0.7.9.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
28
+ meta_ads_mcp-0.7.9.dist-info/RECORD,,