{
  "id": "list_advertisers_with_affiliates",
  "mcp_tool": "list_advertisers_with_affiliates",
  "status": "approved",
  "source_system": "cake",
  "environment": ["staging", "prod"],
  "sharded": false,
  "connections": {
    "whale": "cake_whale_ro",
    "admin": "cake_admin_ro"
  },
  "objects": [
    "whale.lucos_ro_advertiser_stats_daily",
    "whale.lucos_ro_publisher_earnings_daily",
    "Admin.lucos_ro_adv_campaign_performance_daily",
    "Admin.lucos_ro_advertiser_goals",
    "Admin.lucos_ro_advertiser_categories"
  ],
  "parameters": {
    "advertiser_limit": { "type": "int", "required": false, "default": 5 },
    "affiliate_limit": { "type": "int", "required": false, "default": 5 },
    "date_from": { "type": "date", "required": false },
    "date_to": { "type": "date", "required": false }
  },
  "constraints": {
    "max_window_days": 92,
    "default_window_days": 31,
    "max_rows": 10,
    "timeout_ms": 60000
  },
  "allow_fields": [
    "adv_id",
    "adv_name",
    "sales_revenue",
    "spend",
    "clicks",
    "advertiser_conversions",
    "estimated_conversions",
    "unreported_conversions",
    "pub_earnings",
    "affiliates_truncated",
    "affiliates"
  ],
  "deny_fields": ["aov", "rev_share", "postback_url", "ip"],
  "post_processing": [
    "Ranks get_advertiser_report { group_by: advertiser, sort_by: sales_revenue } with the catalog scan cap, then slices advertiser_limit.",
    "For each top advertiser, calls get_advertiser_report { advertiser_id, group_by: publisher, sort_by: sales_revenue } and slices affiliate_limit. Scoped so the unscoped publisher-grain 5000-row click pre-sort cannot drop a high-revenue advertiser's affiliates.",
    "Does not use group_by=affiliate — that grain has no adv_id and cannot attribute publishers to advertisers.",
    "summary is the unbounded advertiser-grain window total from the rank call."
  ],
  "notes": "PREFERRED for 'advertisers that created more revenue AND which affiliates performed for those advertisers'. Do not answer that compound question by joining a group_by=advertiser rank to an unscoped group_by=affiliate leaderboard. Default last 31 days, max 92. advertiser_limit default 5 max 10; affiliate_limit default 5 max 10."
}
