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: add account_id param to get_ad_video for BM token compatibility
Yves Junqueira7eb32942b67c
diff --git a/meta_ads_mcp/core/ads.py b/meta_ads_mcp/core/ads.pyindex 1037ce2..f000fc2 100644--- a/meta_ads_mcp/core/ads.py+++ b/meta_ads_mcp/core/ads.py@@ -629,16 +629,19 @@ async def get_ad_image(ad_id: str, access_token: Optional[str] = None) -> Image:@mcp_server.tool()@meta_api_tool-async def get_ad_video(ad_id: str = "", video_id: str = "", access_token: Optional[str] = None) -> str:+async def get_ad_video(ad_id: str = "", video_id: str = "", account_id: str = "", access_token: Optional[str] = None) -> str:"""Get video details and source URL for a Meta ad video creative. Returns the video source URL(direct download link), thumbnail URL, and metadata (title, description, duration).Provide either ad_id (to auto-extract the video from the ad creative) or video_id directly.+ Providing account_id is strongly recommended — it enables the advideos edge which works+ with Business Manager tokens (avoids error 100/33 and error #10 on account-uploaded videos).Args:ad_id: Meta Ads ad ID (will extract video_id from the ad creative)video_id: Meta video ID (use this if you already have it from get_ad_creatives)+ account_id: Ad account ID (e.g. "act_123" or "123"). Enables advideos edge lookup.access_token: Meta API access token (optional - will use cached token if not provided)"""if not ad_id and not video_id:@@ -680,8 +683,11 @@ async def get_ad_video(ad_id: str = "", video_id: str = "", access_token: Option# Direct GET /{video_id} fails for BM-shared tokens (error 100/33) and# page-owned videos (error #10). The ad account edge works for any video# that belongs to the account's video library.- account_id = ""- if ad_id:+ # Normalize: strip act_ prefix if present (we add it back below)+ if account_id and account_id.startswith("act_"):+ account_id = account_id[4:]++ if not account_id and ad_id:ad_data = await make_api_request(ad_id, access_token, {"fields": "account_id"})account_id = ad_data.get("account_id", "")diff --git a/tests/test_get_ad_video.py b/tests/test_get_ad_video.pyindex fd7321f..4925834 100644--- a/tests/test_get_ad_video.py+++ b/tests/test_get_ad_video.py@@ -167,6 +167,32 @@ class TestGetAdVideo:assert "error" in dataassert "Could not get video" in data["error"]+ async def test_get_ad_video_with_account_id_param(self):+ """When account_id is provided, skip ad lookup and use advideos edge directly."""+ mock_advideos_response = {+ "data": [{+ "id": "6666",+ "source": "https://video-xx.fbcdn.net/v/bm-token.mp4",+ "picture": "https://example.com/thumb.jpg",+ "title": "BM Video",+ "length": 45.0,+ }]+ }++ with patch('meta_ads_mcp.core.ads.make_api_request', new_callable=AsyncMock) as mock_api:+ # Only one call: advideos edge (no ad lookup needed)+ mock_api.return_value = mock_advideos_response++ result = await get_ad_video(access_token="test_token", video_id="6666", account_id="act_999888")+ data = json.loads(result)++ assert data["video_id"] == "6666"+ assert data["source_url"] == "https://video-xx.fbcdn.net/v/bm-token.mp4"+ # Should call advideos edge with normalized account_id (act_ stripped and re-added)+ mock_api.assert_called_once()+ call_args = mock_api.call_args+ assert "act_999888/advideos" in call_args[0][0]+async def test_get_ad_video_account_id_lookup_fails(self):"""When account_id lookup fails, skip advideos edge and go direct."""mock_creatives = {