get_ad_details
Retrieve detailed ad information including creative reference, tracking specs, conversion specs, issues, and recommendations by providing the ad ID.
Instructions
Get detailed ad information including creative reference, tracking specs, conversion specs, issues, and recommendations.
Args: ad_id: Ad ID (numeric string).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ad_id | Yes |
Implementation Reference
- meta_ads_mcp/core/ads.py:294-328 (handler)The @mcp.tool() decorated function that implements the 'get_ad_details' tool. Calls the Meta Graph API with AD_DETAIL_FIELDS, then enriches the result with creative details by fetching the associated creative resource. Handles errors gracefully if the creative fetch fails.
@mcp.tool() def get_ad_details(ad_id: str) -> dict: """ Get detailed ad information including creative reference, tracking specs, conversion specs, issues, and recommendations. Args: ad_id: Ad ID (numeric string). """ api_client._ensure_initialized() try: result = api_client.graph_get(f"/{ad_id}", fields=AD_DETAIL_FIELDS) creative_ref = result.get("creative") if creative_ref and isinstance(creative_ref, dict): creative_id = creative_ref.get("id") if creative_id: try: creative_details = api_client.graph_get( f"/{creative_id}", fields=[ "id", "name", "title", "body", "status", "thumbnail_url", "image_url", "object_story_spec", "asset_feed_spec", "degrees_of_freedom_spec", "url_tags", "call_to_action_type", ], ) result["creative_details"] = creative_details except MetaAPIError as e: logger.warning("Could not fetch creative %s: %s", creative_id, e) result["creative_details"] = {"error": str(e)} result["rate_limit_usage_pct"] = api_client.rate_limits.max_usage_pct return result except MetaAPIError: raise - meta_ads_mcp/core/ads.py:57-62 (schema)AD_DETAIL_FIELDS constant defining the API fields fetched by get_ad_details, extending AD_LIST_FIELDS with bid_amount, bid_type, conversion_specs, source_ad_id, issues_info, and recommendations.
# Fields for detail view AD_DETAIL_FIELDS = AD_LIST_FIELDS + [ "bid_amount", "bid_type", "conversion_specs", "source_ad_id", "issues_info", "recommendations", ] - meta_ads_mcp/core/ads.py:294-294 (registration)The @mcp.tool() decorator that registers get_ad_details as an MCP tool. This is the only registration needed since the decorator handles it directly. The ads module is imported in server.py (line 28) to trigger registration.
@mcp.tool()