@apex-inc/mcp-server 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apex-inc/mcp-server",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "MCP server for Apex — currently in private beta.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -30,6 +30,8 @@ Belief → Hypothesis → Prediction → Experiment → Outcome → Updated Beli
30
30
  | `record_outcome` | After experiment completes — updates belief confidence, marks prediction evaluated |
31
31
  | `predict_impact` | Before building something — searches past experiments and beliefs for similar changes |
32
32
  | `evaluate_feature` | Pre-build decision: should we invest in this? Uses beliefs + experiment history |
33
+ | `get_channel_economics` | "Where should my next dollar go?" — GM-adjusted LTV:CAC, payback, and CAC per acquisition channel, split acquisition vs leverage |
34
+ | `get_growth_reality` | "Is our growth real?" — per-goal lift vs the do-nothing global holdout, with 95% CIs |
33
35
 
34
36
  ## MCP resources
35
37
 
@@ -93,10 +95,39 @@ Use calibration to coach the user: "Your predictions at 80%+ confidence are only
93
95
  | `correlation_hint` | Detected relationship between metrics |
94
96
  | `metric_shift` | Significant change in a tracked metric |
95
97
 
98
+ ## Channel economics (where the next dollar goes)
99
+
100
+ `get_channel_economics` is Layer 1 of Apex's cross-channel measurement stack
101
+ (the established triangulation / Unified Marketing Measurement approach): cohort
102
+ **LTV:CAC by acquisition channel** is the unit-economics foundation, with
103
+ multi-touch attribution as a directional contrast lens layered on top.
104
+
105
+ How to reason with it:
106
+
107
+ - **Currency is gross-margin-adjusted LTV:CAC, not blended ROAS.** A 3:1 blended
108
+ ratio routinely hides organic at 6:1 subsidizing paid social below 1:1. Always
109
+ read it per channel.
110
+ - **Acquisition vs leverage.** Paid channels (have spend) are where you "go get
111
+ users"; leverage channels (owned/organic, no spend) are where you "monetize the
112
+ base." Different plays — never average them together.
113
+ - **Benchmarks for the verdict:** LTV:CAC 3-5x healthy, <3x investigate, >5x
114
+ likely underinvested; payback ≤12-18mo SaaS, 3-9mo ecommerce.
115
+ - **Missing inputs read as "—", never a guess.** A channel with no connected
116
+ spend or revenue shows null, not a fabricated number.
117
+ - **The verdict is free intelligence — never gate it.** Apex meters only when it
118
+ *runs* something (a test, an optimizer, AI narration), not the measurement.
119
+ - **Action boundary:** owned channels get an in-Apex action; paid channels get
120
+ advice the merchant applies in their ad platform. Apex never writes to Meta/Google.
121
+
122
+ For the causal ground truth behind a channel's number, pair it with
123
+ `get_growth_reality` (holdout-based lift). Attribution is directional;
124
+ incrementality is causal.
125
+
96
126
  ## When to activate this skill
97
127
 
98
128
  - User says "what have we learned?" or "what do we know?" → surface beliefs + ledger
99
129
  - User asks "should we build X?" → use `evaluate_feature` or `predict_impact`
130
+ - User asks "where should I spend?" / "which channel is best?" → `get_channel_economics`
100
131
  - User wants to review experiment results → connect outcome to belief update
101
132
  - User asks about prediction accuracy → surface calibration metrics
102
133
  - User is planning strategy → show Growth Intelligence Score and learning velocity
@@ -114,3 +145,25 @@ Use calibration to coach the user: "Your predictions at 80%+ confidence are only
114
145
  - Experiment design and instrumentation: see **apex-experimentation** skill
115
146
  - Event tracking and identity: see **apex-growth-tracking** skill
116
147
  - Communication experiments: see **apex-communications** skill
148
+
149
+ ## Vertical metrics → growth actions (Vertical Widget Packs)
150
+
151
+ Apex ships vertical-specific read tools. Use them AMBIENTLY: when a
152
+ metric implies a growth move, propose the belief/experiment — don't
153
+ just report the number.
154
+
155
+ | Signal (tool) | Growth action to propose |
156
+ |---|---|
157
+ | High zero-result-search rate (`get_marketplace_metrics`) | Supply-acquisition experiment for the missing categories — the queries name the gap |
158
+ | Low search→transaction with healthy supply | Search-relevance or trust experiment (badges, reviews) |
159
+ | Rising unfulfilled demand | Seller-activation journey (listing nudges) before paid demand spend |
160
+ | Concentration: top 10% sellers > ~60% GMV | Long-tail seller enablement; the platform is one churn away from a revenue cliff |
161
+ | NRR < 100% (`get_saas_recurring_revenue`) | Expansion journey + contraction interviews; churned-MRR column names the cohort |
162
+ | Contraction MRR spike (`get_saas_expansion`) | Downgrade-reason capture (`subscription_event` action="downgrade" with reason) → pricing/packaging belief |
163
+ | Rising return rate on one SKU (`get_dtc_returns` + `get_dtc_merchandising`) | Fix the PDP (size guide, photos) — reasons name the fix; returns are goods-back, refunds are money-back |
164
+ | High views, low add-to-cart on a top SKU | Merchandising experiment (price anchor, social proof) on that product page |
165
+
166
+ Honesty rules baked into every tool: metrics with unwired inputs come
167
+ back as unwired hints (never zeros), rates follow small-n rules, low-
168
+ volume slices are privacy-suppressed, and marketplace GMV never counts
169
+ as the operator's revenue (the take — `fee_amount` — does).
@@ -249,3 +249,80 @@ Each producer that sends events into a workspace is a **Data Source** (Website,
249
249
  - Experiment design: see **apex-experimentation** skill
250
250
  - Communication setup: see **apex-communications** skill
251
251
  - Affiliate / partner programs: see **apex-partner-network** skill
252
+
253
+ ## Recipe: Vertical instrumentation (Vertical Widget Packs, 2026-07)
254
+
255
+ Each launch vertical has a canonical event set that unlocks its
256
+ industry-specific dashboard pack. Wire the vertical's set and the
257
+ matching widgets + read APIs light up automatically.
258
+
259
+ ### B2B SaaS — recurring revenue
260
+
261
+ ```typescript
262
+ // Subscription lifecycle (server transport — money truth). MRR-bearing
263
+ // actions REQUIRE amount + period_type or the event is quarantined for
264
+ // MRR purposes (an annual $299 sub must never read as $299 MRR).
265
+ track("subscription_event", {
266
+ product_id: "pro_annual",
267
+ action: "start", // start|renew|upgrade|downgrade|cancel|reactivate|trial_convert
268
+ amount: 299, period_type: "annual", // → $24.92 MRR
269
+ seat_count: 25,
270
+ });
271
+ // Account economics via identify (typed: ApexAccountTraits)
272
+ identify(user.id, { account_id: "acct_42", plan: "pro", mrr: 24.92, seat_count: 25 });
273
+ ```
274
+
275
+ Unlocks: MRR waterfall, NRR/GRR, expansion & seats
276
+ (`GET /api/saas/recurring-revenue`, `/api/saas/expansion` —
277
+ `getSaasRecurringRevenue()` / `getSaasExpansion()` in the SDK,
278
+ `get_saas_recurring_revenue` / `get_saas_expansion` via MCP).
279
+ Connecting Stripe replaces manual events per account (Stripe wins).
280
+
281
+ ### E-commerce / DTC — merchandising + returns
282
+
283
+ ```typescript
284
+ track("product_view", { product_id: "sku_a", product_name: "Trail Runner", category: "footwear", value: 129.99 });
285
+ track("add_to_cart", { product_id: "sku_a", value: 129.99, quantity: 1 });
286
+ // Money truth from the server:
287
+ track("order_placed", { order_id: "o_1", value: 129.99, currency: "USD" });
288
+ // Returns are GOODS BACK; refunds are MONEY BACK — separate events, separate rates:
289
+ track("return_requested", { order_id: "o_1", product_id: "sku_a", reason: "wrong_size" });
290
+ track("return_completed", { order_id: "o_1", product_id: "sku_a", reason: "wrong_size", refunded: true });
291
+ track("purchase_refunded", { order_id: "o_1", value: 129.99, currency: "USD", reason: "wrong_size", product_id: "sku_a" });
292
+ ```
293
+
294
+ Unlocks: per-product funnel, returns & reasons, AOV/repeat
295
+ (`GET /api/dtc/merchandising`, `/api/dtc/returns`).
296
+
297
+ ### Marketplace — two-sided lifecycle
298
+
299
+ ```typescript
300
+ // Supply side (server recommended):
301
+ track("seller_signup", { seller_id: "sel_1", store_name: "Atlas Outfitters" });
302
+ track("listing_created", { listing_id: "lst_9", price: 120, currency: "USD" });
303
+ // Demand side:
304
+ track("search", { query: "trail runner", results_count: 24 }); // results_count powers zero-result-search rate
305
+ track("offer_submitted", { listing_id: "lst_9", amount: 110 });
306
+ // The transaction (SERVER — carries BOTH parties + the take):
307
+ track("transaction_completed", {
308
+ transaction_id: "txn_1",
309
+ amount: 120, // GMV — NEVER credited as your revenue
310
+ fee_amount: 14.4, // the take — THIS is your revenue (required for revenue credit)
311
+ buyer_id: "u_9", seller_id: "sel_1", listing_id: "lst_9",
312
+ category: "footwear", geo: "US", price_band: "100-250",
313
+ });
314
+ // Tag sides via identify so segments work: marketplace_side / is_seller / store_name / payout_method (enum: stripe|paypal|bank_transfer|other)
315
+ identify(user.id, { marketplace_side: "seller", is_seller: true, store_name: "Atlas Outfitters", payout_method: "stripe" });
316
+ ```
317
+
318
+ Unlocks: liquidity, supply & demand, economics (GMV vs take), trust,
319
+ concentration (`GET /api/marketplace/metrics`, sliceable by
320
+ category/geo/price_band).
321
+
322
+ ### Agency — client portfolio
323
+
324
+ No new events: each client is a LINKED WORKSPACE. Connect the client's
325
+ ad accounts + Stripe in their workspace; per-client spend/revenue/ROI
326
+ and the transparent at-risk rule roll up on the agency org
327
+ (`GET /api/agency/clients` — org owner/admin sessions only; it is a
328
+ financial boundary with no API-key lane).
@@ -16,10 +16,11 @@ find where each business truth already lives and instrument it there.
16
16
  1. **Scan before asking.** Never ask the merchant to enumerate their
17
17
  events. Audit the codebase for Spec opportunities:
18
18
  - auth / signup flows → `apex.identify(email, first_name, last_name)` + `user_signed_up`
19
- - login flows → `identify` (cross-device stitching)
20
- - checkout / payment success paths → `purchase` / `checkout_started` / `order_placed` (server)
21
- - in-app purchase / StoreKit / Play Billing → `in_app_purchase`
22
- - subscription create / renew / cancel webhooks → `subscription_event`
19
+ - login flows → `identify` (cross-device stitching). If the auth provider exposes a profile photo (OIDC `picture` claim, Firebase `photoURL`), map it to the canonical `avatar_url` trait so the Customer gets a photo across Apex — Customers list, detail, Live Customers widget.
20
+ - checkout flow begun → `checkout_started` (client)
21
+ - checkout / payment success paths → `order_placed` (server, money-truth) and/or `checkout_completed` (client mirror)
22
+ - in-app purchase / StoreKit / Play Billing → `in_app_purchase` (store-verified)
23
+ - subscription create / renew / cancel webhooks → `subscription_started` / `subscription_renewed` / `subscription_canceled` (discrete) or `subscription_event` (action-driven)
23
24
  - lead/contact forms → `form_submit`
24
25
  - cart mutations → `add_to_cart`, `remove_from_cart`
25
26
  - search, share, content views → `search`, `share`, `content_view`
@@ -54,6 +55,17 @@ find where each business truth already lives and instrument it there.
54
55
  smallest change that works; never commit; never enable test mode in
55
56
  production paths.
56
57
 
58
+ **Transport is in the spec, not a guess.** Each event declares a
59
+ `recommendedTransport` (`server` | `client` | `either`) and revenue
60
+ events a `revenueRole` (`primary` | `client_mirror` | `iap`) — read
61
+ them from `get_event_spec`. The rule: fire money-truth events
62
+ (`order_placed` = primary, `in_app_purchase` = iap, all `payment_*` /
63
+ `invoice_*` / `subscription_*`) from the **server/store**; fire intent
64
+ and engagement events (`checkout_started`, `add_to_cart`, `page_view`,
65
+ `checkout_completed` = client_mirror) from the **client**. Never make
66
+ `checkout_completed` the dollar source of record when `order_placed`
67
+ exists — it's the client mirror and can duplicate.
68
+
57
69
  4. **Verify your own work.** Call `get_wiring_status` after wiring and
58
70
  iterate until every event you proposed reports `detected`. The
59
71
  merchant's page celebrates each first arrival — your verification
@@ -72,6 +84,42 @@ find where each business truth already lives and instrument it there.
72
84
  - Custom events are allowed (`apex.track` accepts any snake_case
73
85
  name) but prefer canonical Spec names — they unlock journeys,
74
86
  funnels, and metric chips automatically.
87
+ - When a merchant's event has no canonical equivalent and matters to
88
+ their business, GOVERN it instead of leaving it loose: propose a
89
+ schema from the observed payloads (`get_schema`) + the codebase,
90
+ confirm with the merchant, then call `define_event` (snake_case name,
91
+ typed fields, scope). A governed event behaves like a canonical one —
92
+ trigger/goal-selectable, token-resolvable, validated, versioned
93
+ (SchemaVer). It can never shadow a canonical Spec name.
75
94
  - Revenue events MUST carry `value` + `currency`, and a stable
76
95
  external id when one exists (order id, invoice id) — dedupe depends
77
96
  on it.
97
+
98
+ ## Vertical event sets (Vertical Widget Packs, 2026-07)
99
+
100
+ Scan-first additions per vertical — wire where the truth lives:
101
+
102
+ - **SaaS**: subscription webhooks → `subscription_event` with a CLOSED
103
+ action enum (start/renew/upgrade/downgrade/cancel/reactivate/
104
+ trial_convert). MRR-bearing actions REQUIRE `amount` + `period_type`
105
+ (monthly|annual|quarterly|weekly) — quarantined for MRR otherwise.
106
+ `seat_count` unlocks seat growth. Account traits: `account_id`,
107
+ `plan`, `mrr`, `arr`, `seat_count` (typed via ApexAccountTraits).
108
+ - **DTC**: returns pipeline → `return_requested` / `return_completed`
109
+ (goods back) alongside `purchase_refunded` (money back — now carries
110
+ optional `product_id` for per-SKU attribution). Never conflate the two.
111
+ - **Marketplace**: supply (`seller_signup`, `listing_created`,
112
+ `payout_sent`), demand (`search` WITH `results_count`,
113
+ `listing_viewed`, `seller_viewed`, `item_saved`, `inquiry_started`,
114
+ `offer_submitted`, `match_created`), outcome
115
+ (`transaction_completed` — SERVER, with `amount` (GMV), `fee_amount`
116
+ (the take — the ONLY field credited as revenue), `buyer_id`,
117
+ `seller_id`, `listing_id`, and `category`/`geo`/`price_band` slices),
118
+ trust (`transaction_canceled`, `dispute_opened`, `review_submitted`
119
+ with `rating`). Legacy vocabularies (`supply_signup`,
120
+ `demand_signup`, `first_transaction`, `marketplace_*`) resolve via
121
+ built-in aliases — never wire them as new names.
122
+ Identify traits: `marketplace_side`, `is_buyer`, `is_seller`,
123
+ `store_name`, `seller_id`, `payout_method` (ENUM
124
+ stripe|paypal|bank_transfer|other — never instrument details).
125
+ Roles are event-derived and append-only; dual-hat users carry both.