@apex-inc/mcp-server 0.26.0 → 0.27.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.26.0",
3
+ "version": "0.27.0",
4
4
  "description": "MCP server for Apex \u2014 currently in private beta.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -56,19 +56,19 @@ A comm that's live in a published journey also needs `intent`, whatever its
56
56
 
57
57
  ### The two intents
58
58
 
59
- - **`intent: "compete"`** — *Add as a variant.* Your edit runs as an experiment
60
- against the current content. Nothing changes for recipients yet; Apex measures
61
- which one is better and tells you.
62
- - **`intent: "replace"`** — *Update for everyone.* Your edit becomes what
63
- everyone receives. Any prior win is superseded.
59
+ - **`intent: "compete"`** — *Start an experiment.* What's sending now stays
60
+ live. Publish creates a filled-in draft. Then `activate_experiment` after
61
+ the user confirms.
62
+ - **`intent: "replace"`** — *Replace what's sending.* Everyone gets this
63
+ version on the next send. No experiment row.
64
64
 
65
65
  ### When in doubt, compete
66
66
 
67
67
  This is the default, and it isn't a coin flip. The two mistakes are not
68
68
  symmetric:
69
69
 
70
- - Guessing `compete` when the user wanted `replace` costs **time** — they see
71
- an experiment start and can promote the winner immediately.
70
+ - Guessing `compete` when the user wanted `replace` costs **time** — they have
71
+ a draft to activate, or they can publish again with replace.
72
72
  - Guessing `replace` when the user wanted `compete` **destroys a measured
73
73
  result permanently**. There's no undo for evidence.
74
74
 
@@ -76,9 +76,9 @@ So: if the user explicitly said "just change it for everyone" / "replace the
76
76
  copy" / "roll this out," send `replace`. Otherwise send `compete`, and say what
77
77
  you did:
78
78
 
79
- > "That comm's control won an experiment, so I added your new copy as a variant
80
- > and started an experiment against it rather than overwriting the winner. Want
81
- > me to make it the control for everyone instead?"
79
+ > "That comm's control won an experiment, so I published your copy as a
80
+ > competing version and opened a filled-in draft. Want me to activate it, or
81
+ > make this the letter everyone gets instead?"
82
82
 
83
83
  ### Don't force through a running experiment
84
84
 
@@ -97,9 +97,10 @@ re-issue. Do not retry the identical call.
97
97
  ### Running experiments
98
98
 
99
99
  1. **`list_communications`** — find the communication to test.
100
- 2. **`create_comm_experiment`** — set up the A/B test with variants.
101
- 3. The experiment runs automatically via Thompson Sampling.
102
- 4. Check results via `list_communications` or the dashboard.
100
+ 2. **`edit_communication` / `add_communication_variant`** — write the versions.
101
+ 3. **`publish_communication`** with `intent: "compete"` creates a prefilled draft. Does not start the test.
102
+ 4. **`activate_experiment`** begins the test on the next send.
103
+ 5. Check results via `get_results` / `list_experiments`.
103
104
 
104
105
  ### Manual sends
105
106
 
@@ -157,15 +158,16 @@ hard-block**. For those journeys, filter to `pipeline="marketing"`.
157
158
  ```
158
159
  1. recommend_communications → look for retention/winback entries
159
160
  2. generate_communications for churn-related comms
160
- 3. create_comm_experiment to A/B test the messaging
161
+ 3. add_communication_variant, publish_communication (compete), then activate_experiment
161
162
  4. get_event_taxonomy to see what churn signals to track
162
163
  ```
163
164
 
164
165
  ### "How do I A/B test my emails?"
165
166
  ```
166
167
  1. list_communications → find the target
167
- 2. create_comm_experiment with subject or body split
168
- 3. Explain Thompson Sampling: traffic shifts automatically toward the winner
168
+ 2. add_communication_variant (or edit the second column)
169
+ 3. publish_communication intent=compete filled-in draft
170
+ 4. activate_experiment after the user confirms
169
171
  ```
170
172
 
171
173
  ### "Set up cart abandonment recovery"
@@ -72,7 +72,7 @@ Interactive flows: MCP prompts `new-experiment` and `experiment-review` orchestr
72
72
  - **Screenshots are first-class.** For public web URLs, `create_experiment` auto-captures control + variant screenshots and shows them on the dashboard experiment card + detail gallery. For localhost / auth-gated / mobile screens, capture the image yourself and call `attach_experiment_asset({ experimentId, variantKey, imageBase64 })`.
73
73
  - **Mobile/Capacitor experiments capture on-device.** When the experiment runs on an authed in-app screen (servers can't reach it), tell the dev to call `Apex.captureVariantScreenshot({ experimentId, variantKey })` on the variant's screen, keyed to the resolved variant in a `useEffect`, in a debug build (`Apex.initialize({ ..., debug: true })`). It no-ops in production and lands the shot on the dashboard card + gallery like web/agent captures.
74
74
  - **Exposure auto-fires.** When a variant resolves via `useApexVariant` (web) or `Apex.getVariant()` (mobile), the SDK fires the canonical `experiment_exposure` event — the denominator for results. You don't fire it manually.
75
- - **Don't launch a dead experiment.** `activate_experiment` is gated on `verify_experiment_wiring`. Code-wired (SDK-hook) web experiments are safe to activate before their code ships: the server holds them in `pending_deployment` ("Waiting on deploy"). The 14-day clock starts at the first **live customer** exposure — not merge, not activate, not TestFlight. Testers can still get an arm while waiting. Assign with no Origin is Unclassified (no enrollment). Backend assign must send `environment` or `x-apex-web-environment`. Non-SDK experiments with unwired arms are refused (pass `force: true` to override). Run `verify_experiment_wiring({ experimentId })` after the deploy lands to confirm both arms are live.
75
+ - **Don't launch a dead experiment.** `activate_experiment` is gated on `verify_experiment_wiring`. Code-wired (SDK-hook) web experiments are safe to activate before their code ships: the server holds them in `pending_deployment` ("Waiting on deploy"). The 14-day clock starts at the first **recorded** visit (a tester on a named Beta site, or a live visit) — not merge, not activate, not localhost. Testers on a named Beta site count in the winner. Localhost does not. Assign with no Origin is Unclassified (no enrollment). Backend assign must send `environment` or `x-apex-web-environment`. Non-SDK experiments with unwired arms are refused (pass `force: true` to override). Run `verify_experiment_wiring({ experimentId })` after the deploy lands to confirm both arms are live.
76
76
 
77
77
  ### Journey-arm experiments (any surface)
78
78
 
@@ -95,18 +95,28 @@ Do NOT describe this as champion versus challenger, and do not try to run "the o
95
95
 
96
96
  ### Starting an experiment from the communication side
97
97
 
98
- `publish_communication` is the other way an experiment starts. Publishing a communication that has variants starts the experiment measuring them against the control, on the published journey that sends it. Preconditions, each reported rather than guessed:
98
+ Write the letter with `edit_communication` / `add_communication_variant`. Then:
99
+
100
+ 1. `publish_communication` with `intent: "compete"` (or when variants already exist). This creates a **prefilled draft** on the same experiment page as web tests. It does **not** start the test.
101
+ 2. Show the user the draft. They can edit window, hypothesis, belief.
102
+ 3. `activate_experiment` starts it. People on that journey get control or the variant on the next send. Screenshots are captured on activate — do not call `attach_experiment_asset` for a letter unless capture failed.
103
+
104
+ `intent: "replace"` publishes the letter for everyone. Leftover variant columns leave. No experiment row.
105
+
106
+ Preconditions for a draft, each reported rather than guessed:
99
107
 
100
108
  - **A host** — some published journey must send the communication. `no_host` means there is no traffic to measure.
101
109
  - **A goal** — the host step's own goal event, or the journey's. `no_goal` means there is nothing to optimize toward; set the journey's goal event first.
102
110
  - **One host** — 409 `ambiguous_experiment_host` lists the candidates when several journeys send it. Ask the user which, then re-issue with `host_journey_id`.
103
111
 
112
+ When in doubt, compete. The cheap mistake is now "they have a draft to activate," not "they already have a live test."
113
+
104
114
  ### Editing a control that won
105
115
 
106
116
  `edit_communication` and `publish_communication` both take `intent` when the control is protected (it won an experiment, or a published journey is sending it):
107
117
 
108
- - `"compete"` — the current content keeps sending and your change runs against it as an experiment. **This is the default when the user hasn't said otherwise**; it is recoverable.
109
- - `"replace"` — your change becomes what everyone receives, superseding the prior win. This permanently discards a measured result.
118
+ - `"compete"` — the current content keeps sending. Publish opens a filled-in draft. Then `activate_experiment`. **This is the default when the user hasn't said otherwise**; it is recoverable.
119
+ - `"replace"` — your change becomes what everyone receives, superseding the prior win. No experiment row.
110
120
 
111
121
  Omitting `intent` when it's required returns 409 `intent_required` naming both. Do not pick `replace` to clear the error.
112
122
 
@@ -160,7 +170,7 @@ Editability is gated by lifecycle, keyed to DATA:
160
170
 
161
171
  - **Draft, no exposures yet:** fully editable. Use `update_experiment({ experimentId, ... })` to fix a mislabeled surface, rename, or correct the hypothesis/metric/guardrail. This is where typo and surface fixes belong.
162
172
  - **Running, or any exposures recorded:** the pre-registration (hypothesis, metric, guardrails) and bucketing (surface, variants) FREEZE. `update_experiment` returns `experiment_locked` with the reason — that's intentional, so results stay valid. Do not fight it.
163
- - **After freeze:** call `fork_experiment({ experimentId })`. It duplicates the design into a fresh draft (no data carries over, lineage recorded), which you then edit and activate.
173
+ - **After freeze:** call `fork_experiment({ experimentId })`. It duplicates the design into a fresh draft (no data carries over, lineage recorded). A copy gets a new id — replace `useApexVariant("<old id>")` with the new id, deploy, then activate. Preview still works via `_apex_exp`; a normal visit shows control until the new id is shipped.
164
174
 
165
175
  Surface specifically: `create_experiment` auto-detects mobile vs web from repo signals (capacitor.config.* / @apex-inc/capacitor-plugin) and the workspace's registered data sources when you omit `surface`; if a Capacitor app got mislabeled `web`, fix it on the draft with `update_experiment({ experiment_id, surface: "mobile" })` before the first exposure, or fork if it's already running.
166
176
 
@@ -20,7 +20,7 @@ Apex ingests **events** and **identities** so experiments, attribution, and inte
20
20
  ## Event naming
21
21
 
22
22
  - Use **snake_case** or **dot-separated** consistent verbs: `page_viewed`, `signup_started`, `trial_started`, `notification_clicked`.
23
- - Include **context** in properties, not in the event name explosion: `track("button_clicked", { surface: "pricing", label: "start_trial" })` vs dozens of `pricing_start_trial_clicked` events.
23
+ - Include **context** in properties, not in the event name explosion: `track("ui_action", { action: "click", name: "Start trial", location: "pricing" })` vs dozens of `pricing_start_trial_clicked` events.
24
24
  - For experiments, include **`experimentId`** and **`variant`** when the event is relevant to that exposure.
25
25
 
26
26
  ## Canonical attributes (the Schema)
@@ -118,7 +118,7 @@ For agent-driven testing through MCP, use the **`send_server_event`** tool — s
118
118
  ## Event naming conventions
119
119
 
120
120
  - **snake_case**: `signup_completed`, `feature_used`, `invoice_paid`
121
- - Context in **properties**: `track("button_clicked", { surface: "pricing", label: "start_trial" })`
121
+ - Context in **properties**: `track("ui_action", { action: "click", name: "Start trial", location: "pricing" })`
122
122
  - For experiments, include `experimentId` and `variant` in properties
123
123
  - One primary metric per experiment; secondary metrics as properties
124
124
 
@@ -94,6 +94,12 @@ find where each business truth already lives and instrument it there.
94
94
  - Revenue events MUST carry `value` + `currency`, and a stable
95
95
  external id when one exists (order id, invoice id) — dedupe depends
96
96
  on it.
97
+ - Do **not** invent one event per button. In-product chrome (named
98
+ buttons, widget close/minimize/move, nav picks) is `ui_action` with
99
+ `action` + `name` + optional `location`. Outcomes stay semantic:
100
+ `integration_selected`, `setup_step_continued`, `integration_connected`.
101
+ `click` is the snippet's outbound-link auto-event; do not use it for
102
+ dashboard buttons.
97
103
 
98
104
  ## Vertical event sets (Vertical Widget Packs, 2026-07)
99
105