{
  "id": "get_publisher_click_report",
  "mcp_tool": "get_publisher_click_report",
  "status": "approved",
  "source_system": "cake",
  "environment": ["staging", "prod"],
  "sharded": false,
  "connections": {
    "admin": "cake_admin_ro"
  },
  "objects": [
    "Admin.lucos_ro_publisher_clicks",
    "Admin.lucos_ro_affiliate_directory"
  ],
  "parameters": {
    "publisher": { "type": "string", "required": true },
    "report_type": {
      "type": "enum",
      "required": false,
      "default": "detailed_cpc",
      "values": ["detailed_cpc", "custom_click"]
    },
    "advertiser": { "type": "string", "required": false },
    "campaign_id": { "type": "int", "required": false },
    "click_id": { "type": "string", "required": false },
    "ref_id": { "type": "string", "required": false },
    "sub_id": { "type": "string", "required": false },
    "sort_by": { "type": "enum", "required": false, "values": ["click_time", "cpc"] },
    "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": 31,
    "default_window_days": 7,
    "max_rows": 500,
    "timeout_ms": 60000
  },
  "allow_fields": [
    "click_time",
    "adv_id",
    "adv_name",
    "camp_id",
    "cpc",
    "publisher_click_id",
    "publisher_ref_id",
    "publisher_sub_id",
    "device",
    "status"
  ],
  "deny_fields": [
    "rev_share",
    "aff_rev_share",
    "net_cpc_raw",
    "search_terms",
    "click_ip",
    "search_ip",
    "user_agent",
    "referrer",
    "email",
    "pass_clr"
  ],
  "post_processing": [
    "Answers members.admedia.com Detailed CPC Report (report_type=detailed_cpc, affiliate_model.php getAffiliateCPCReport) and Custom Click Report (report_type=custom_click, getAffiliateParamCPCReport).",
    "cpc is the portal's earnings formula, computed inside the view: IF(net_cpc = 0, ROUND(cpc, 2) * rev_share, net_cpc). rev_share never leaves the database.",
    "report_type sets the status filter, because the two portal reports differ: detailed_cpc uses status = 1, custom_click uses status > 0.",
    "CLICK GRAIN IS BOUNDED BY THE TOOL, NOT THE VIEW: publisher is required, the window is capped at 31 days and rows at 500, so no single call can walk aff_cpc_summary. The cake rule against unbounded click exports is kept by these limits.",
    "summary is computed by a separate aggregate query over every matching click, so totals are complete even though only `limit` rows are returned.",
    "click_id / ref_id / sub_id filters are exact matches on the publisher's own identifiers. The portal shows these columns without filtering on them; filtering is additive and does not change any returned value."
  ],
  "notes": "Click-level CPC listing for ONE publisher: time, advertiser, campaign, earned CPC and the publisher's click/ref/sub ids. publisher is mandatory. Distinct from get_publisher_report (daily totals) and get_publisher_merchant_report (per-merchant conversions)."
}
