{
  "id": "get_publisher_merchant_report",
  "mcp_tool": "get_publisher_merchant_report",
  "status": "approved",
  "source_system": "cake",
  "environment": [
    "staging",
    "prod"
  ],
  "sharded": false,
  "connections": {
    "admin": "cake_admin_ro"
  },
  "objects": [
    "Admin.lucos_ro_publisher_merchant_daily",
    "Admin.lucos_ro_publisher_merchant_revenue",
    "Admin.lucos_ro_affiliate_directory"
  ],
  "parameters": {
    "publisher": {
      "type": "string",
      "required": false
    },
    "advertiser": {
      "type": "string",
      "required": false
    },
    "group_by": {
      "type": "enum",
      "required": false,
      "default": "advertiser",
      "values": [
        "advertiser",
        "campaign",
        "day",
        "publisher",
        "total"
      ]
    },
    "quality": {
      "type": "enum",
      "required": false,
      "values": [
        "very_high",
        "high",
        "low",
        "very_low",
        "no_sales"
      ]
    },
    "sort_by": {
      "type": "enum",
      "required": false,
      "values": [
        "date",
        "revenue",
        "clicks",
        "conversions",
        "cvr",
        "aov",
        "total_sales",
        "valid_clicks",
        "cost_of_sale"
      ]
    },
    "sort_dir": {
      "type": "enum",
      "required": false,
      "values": [
        "desc",
        "asc"
      ]
    },
    "date_from": {
      "type": "date",
      "required": false
    },
    "date_to": {
      "type": "date",
      "required": false
    },
    "limit": {
      "type": "int",
      "required": false,
      "default": 50
    }
  },
  "constraints": {
    "max_window_days": 92,
    "default_window_days": 30,
    "max_rows": 500,
    "timeout_ms": 60000
  },
  "allow_fields": [
    "date",
    "publisher_id",
    "publisher_name",
    "adv_id",
    "adv_name",
    "camp_id",
    "camp_name",
    "clicks",
    "conversions",
    "cvr",
    "aov",
    "total_sales",
    "revenue",
    "valid_clicks",
    "publisher_cpc",
    "cost_of_sale",
    "quality",
    "days"
  ],
  "deny_fields": [
    "rev_share",
    "aff_rev_share",
    "bid",
    "commission",
    "pass_clr",
    "SSN",
    "Tax_ID",
    "email",
    "search_terms",
    "publisher_click_id",
    "publisher_sub_id"
  ],
  "post_processing": [
    "Answers members.admedia.com Merchant Conversion Report (reports/merchantconv_old) and Merchant Level Quality Report (reports/merchant_level_quality).",
    "clicks, conversions, cvr, aov and campaign bid come from adv_cmp_performance via Admin.lucos_ro_publisher_merchant_daily; validated revenue and valid clicks come from daily_stats_valid_merchant_revenue via Admin.lucos_ro_publisher_merchant_revenue, matched on publisher+advertiser+date.",
    "total_sales = aov * conversions, as the portal computes it.",
    "cost_of_sale = clicks * publisher_cpc / conversions (the portal's clicks * ((bid * rev_share) / conversions)); null when there are no conversions, where the portal prints '-'.",
    "quality buckets follow the portal's cvr thresholds: >8 very_high, 4-8 high, 2-4 low, 0-2 very_low, otherwise no_sales. The portal's exact boundary values (8, 4, 2) fall through to no_sales and that behaviour is reproduced.",
    "DELIBERATE DIFFERENCE: the portal SUMs cvr and aov across rows, which is a sum of rates and only correct when a group holds one row. This tool averages them weighted by clicks and reports weighted_rates=true, so a multi-row group is not reported as a 300% conversion rate.",
    "publisher_cpc is campaign bid x rev_share, computed inside the view; neither the raw bid nor rev_share is exposed.",
    "summary is computed over every matching row before the limit."
  ],
  "notes": "Per-merchant (advertiser) performance for a publisher: clicks, conversions, CVR, AOV, total sales, validated revenue and a quality bucket. publisher accepts a name or numeric id and may be omitted to compare publishers. Distinct from get_advertiser_report, which is advertiser-side cake reporting."
}
