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
Add image analysis functionality for ad creatives
Yves Junqueirad59ef2ff2aed
diff --git a/meta_ads_generated.py b/meta_ads_generated.pyindex 07c2a4f..0c93989 100644--- a/meta_ads_generated.py+++ b/meta_ads_generated.py@@ -3,9 +3,11 @@ import httpximport jsonimport osimport base64-from mcp.server.fastmcp import FastMCP+from mcp.server.fastmcp import FastMCP, Imageimport datetimefrom urllib.parse import urlparse+from PIL import Image as PILImage+import io# Initialize FastMCP servermcp_server = FastMCP("meta-ads-generated")@@ -1165,6 +1167,38 @@ async def save_ad_image_via_api(access_token: str, ad_id: str) -> str:return json.dumps(result, indent=2)+@mcp_server.tool()+def analyze_ad_creative_image(image_path: str) -> Image:+ """+ Open and analyze a local ad creative image previously downloaded with download_ad_creative_image.+ This returns the image directly to the LLM for visual analysis.++ Args:+ image_path: Path to the local image file (e.g., ad_creatives/ad_123456789_image.jpg)++ Returns:+ The image for direct LLM analysis+ """+ try:+ # Open the image file using PIL+ img = PILImage.open(image_path)++ # Convert to RGB if needed (in case of RGBA, etc.)+ if img.mode != "RGB":+ img = img.convert("RGB")++ # Create a byte stream of the image data+ byte_arr = io.BytesIO()+ img.save(byte_arr, format="JPEG")+ img_bytes = byte_arr.getvalue()++ # Return as an Image object that LLM can directly analyze+ return Image(data=img_bytes, format="jpeg")++ except Exception as e:+ # Return an error message if something goes wrong+ return f"Error analyzing image: {str(e)}"+if __name__ == "__main__":# Initialize and run the servermcp_server.run(transport='stdio')\ No newline at end of file