@apex-inc/mcp-server 0.70.0 → 0.72.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.
Files changed (40) hide show
  1. package/dist/api-client.d.ts +11 -0
  2. package/dist/api-client.d.ts.map +1 -1
  3. package/dist/api-client.js +38 -0
  4. package/dist/api-client.js.map +1 -1
  5. package/dist/index.js +2 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/letter-blocks.d.ts +2 -2
  8. package/dist/setup-catchup-tools.d.ts +24 -15
  9. package/dist/setup-catchup-tools.d.ts.map +1 -1
  10. package/dist/setup-catchup-tools.js +122 -53
  11. package/dist/setup-catchup-tools.js.map +1 -1
  12. package/dist/setup-checklist.d.ts +1 -0
  13. package/dist/setup-checklist.d.ts.map +1 -1
  14. package/dist/setup-checklist.js +2 -1
  15. package/dist/setup-checklist.js.map +1 -1
  16. package/dist/tool-groups.d.ts.map +1 -1
  17. package/dist/tool-groups.js +3 -0
  18. package/dist/tool-groups.js.map +1 -1
  19. package/dist/tools/experiments.d.ts +2 -2
  20. package/dist/tools/experiments.js +1 -1
  21. package/dist/tools/experiments.js.map +1 -1
  22. package/dist/tools/letters.d.ts +208 -17
  23. package/dist/tools/letters.d.ts.map +1 -1
  24. package/dist/tools/letters.js +170 -51
  25. package/dist/tools/letters.js.map +1 -1
  26. package/dist/tools/measurement.d.ts +43 -12
  27. package/dist/tools/measurement.d.ts.map +1 -1
  28. package/dist/tools/measurement.js +49 -5
  29. package/dist/tools/measurement.js.map +1 -1
  30. package/dist/tools/partners.d.ts +17 -14
  31. package/dist/tools/partners.d.ts.map +1 -1
  32. package/dist/tools/partners.js +30 -5
  33. package/dist/tools/partners.js.map +1 -1
  34. package/dist/tools.d.ts +296 -53
  35. package/dist/tools.d.ts.map +1 -1
  36. package/dist/workspace-target-url.d.ts.map +1 -1
  37. package/dist/workspace-target-url.js +8 -3
  38. package/dist/workspace-target-url.js.map +1 -1
  39. package/package.json +1 -1
  40. package/skills/apex-setup/SKILL.md +6 -1
@@ -42,6 +42,7 @@ const keyEventCategorySchema = z
42
42
  "retention",
43
43
  "advocacy",
44
44
  "churn",
45
+ "reactivation",
45
46
  "other",
46
47
  ])
47
48
  .describe("What kind of step it is; sets its place in the funnel.");
@@ -643,7 +644,11 @@ export const measurementTools = {
643
644
  funnelRole: z
644
645
  .enum(["stage", "off_ramp", "return", "milestone"])
645
646
  .optional()
646
- .describe("Role in the workspace funnel & contact lifecycle: stage (advances contact lifecycle), off_ramp (churn/lost), return (win-back), or milestone (does not change stage)."),
647
+ .describe("Role in the workspace funnel & contact lifecycle: stage (advances contact lifecycle), off_ramp (churn/lost), return (reactivation), or milestone (does not change stage)."),
648
+ reactivatesChurned: z
649
+ .boolean()
650
+ .optional()
651
+ .describe("Whether reaching this key event brings a churned person back to active (defaults to true for purchase, subscribe, and reactivation)."),
647
652
  }),
648
653
  handler: async (args) => {
649
654
  try {
@@ -656,6 +661,7 @@ export const measurementTools = {
656
661
  ...(args.template ? { template: args.template } : {}),
657
662
  ...(typeof args.position === "number" ? { position: args.position } : {}),
658
663
  ...(args.funnelRole ? { funnel_role: args.funnelRole } : {}),
664
+ ...(typeof args.reactivatesChurned === "boolean" ? { reactivates_churned: args.reactivatesChurned } : {}),
659
665
  });
660
666
  const k = res.data?.keyEvent;
661
667
  const note = await revenueOverlapNoteFor(k?.category ?? args.category);
@@ -684,6 +690,11 @@ export const measurementTools = {
684
690
  .nullable()
685
691
  .optional()
686
692
  .describe("Role in the workspace funnel & contact lifecycle, or null to reset to category default."),
693
+ reactivatesChurned: z
694
+ .boolean()
695
+ .nullable()
696
+ .optional()
697
+ .describe("Whether reaching this key event brings a churned person back to active, or null to reset to default."),
687
698
  isCurrentGoal: z.literal(true).optional().describe("Make it the workspace's main goal, in place of the one before."),
688
699
  }),
689
700
  handler: async (args) => {
@@ -696,6 +707,7 @@ export const measurementTools = {
696
707
  ...(args.description !== undefined ? { description: args.description } : {}),
697
708
  ...(args.position !== undefined ? { position: args.position } : {}),
698
709
  ...(args.funnelRole !== undefined ? { funnel_role: args.funnelRole } : {}),
710
+ ...(args.reactivatesChurned !== undefined ? { reactivates_churned: args.reactivatesChurned } : {}),
699
711
  ...(args.isCurrentGoal ? { is_current_goal: true } : {}),
700
712
  });
701
713
  const k = res.data?.keyEvent;
@@ -1806,7 +1818,7 @@ Events fired through this tool carry a stable synthetic visitorId (mcp-agent-*,
1806
1818
  },
1807
1819
  },
1808
1820
  define_event: {
1809
- description: `${APEX} — Define a governed custom event in the workspace's Schema (the customer-extensible registry). Promotes one of the merchant's own events to a first-class, typed, versioned definition that behaves like a canonical Apex Spec event (selectable as a journey trigger/goal, resolvable as comm tokens, validated at ingest). Name it the way Apex Spec events are named: the thing, then a past-tense verb (report_exported, never export_report). Names must be snake_case and CANNOT shadow a canonical Apex Spec event — call get_event_spec first and reuse the canonical event when one fits. Propose the schema from the merchant's observed payloads (get_schema) and codebase, then confirm with them before defining.`,
1821
+ description: `${APEX} — Define a governed custom event in the workspace's Schema (the customer-extensible registry). Promotes one of the merchant's own events to a first-class, typed, versioned definition that behaves like a canonical Apex Spec event (selectable as a journey trigger/goal, resolvable as comm tokens, validated at ingest). Name it the way Apex Spec events are named: the thing, then a past-tense verb (report_exported, never export_report). Names must be snake_case and CANNOT shadow a canonical Apex Spec event — call get_event_spec first and reuse the canonical event when one fits. Pass publish: true to publish immediately, or omit it to create a draft (drafts already work in journeys, key events, and experiments, and can be published later with publish_event_definition). Propose the schema from the merchant's observed payloads (get_schema) and codebase, then confirm with them before defining.`,
1810
1822
  schema: z.object({
1811
1823
  name: z.string().describe("snake_case event name, not already in the Apex Spec"),
1812
1824
  description: z.string().describe("One sentence: when this event fires"),
@@ -1817,14 +1829,18 @@ Events fired through this tool carry a stable synthetic visitorId (mcp-agent-*,
1817
1829
  .enum(["workspace", "org"])
1818
1830
  .optional()
1819
1831
  .describe("workspace (default) or org (shared across the org's workspaces)"),
1820
- primary_metric: z
1832
+ primaryMetric: z
1821
1833
  .boolean()
1822
1834
  .optional()
1823
1835
  .describe("True if this is a conversion/outcome that can be a journey goal"),
1824
- recommended_transport: z
1836
+ recommendedTransport: z
1825
1837
  .enum(["client", "server", "either"])
1826
1838
  .optional()
1827
1839
  .describe("Where to fire it: server for money-truth, client for intent/engagement"),
1840
+ publish: z
1841
+ .boolean()
1842
+ .optional()
1843
+ .describe("Set true to publish immediately (status: 'published'). Default false creates a draft that still works in journeys, key events, and experiments."),
1828
1844
  }),
1829
1845
  handler: async (args) => {
1830
1846
  const res = await apiPost("/api/schema/events", {
@@ -1834,6 +1850,7 @@ Events fired through this tool carry a stable synthetic visitorId (mcp-agent-*,
1834
1850
  scope: args.scope,
1835
1851
  primaryMetric: args.primaryMetric,
1836
1852
  recommendedTransport: args.recommendedTransport,
1853
+ status: args.publish ? "published" : "draft",
1837
1854
  });
1838
1855
  if (res.error) {
1839
1856
  const hint = res.suggestion
@@ -1841,16 +1858,43 @@ Events fired through this tool carry a stable synthetic visitorId (mcp-agent-*,
1841
1858
  : "";
1842
1859
  return { content: [{ type: "text", text: `Could not define "${args.name}": ${res.error}.${hint}` }] };
1843
1860
  }
1861
+ const schemaLink = appUrl("/dashboard/settings/workspace/schema");
1862
+ const status = res.status ?? (args.publish ? "published" : "draft");
1863
+ const msg = status === "published"
1864
+ ? `Defined and published governed event "${res.name}" (SchemaVer ${res.schemaVer ?? "1-0-0"}, published). Manage governed events at ${schemaLink}.`
1865
+ : `Defined governed event "${res.name}" (SchemaVer ${res.schemaVer ?? "1-0-0"}, draft). Draft definitions already work in journeys, key events, and experiments. Call publish_event_definition({ name: "${res.name}" }) when ready to publish, or manage it at ${schemaLink}.`;
1844
1866
  return {
1845
1867
  content: [
1846
1868
  {
1847
1869
  type: "text",
1848
- text: `Defined governed event "${res.name}" (SchemaVer ${res.schemaVer ?? "1-0-0"}, draft). It's now selectable as a trigger/goal and resolvable as comm tokens once published.`,
1870
+ text: msg,
1849
1871
  },
1850
1872
  ],
1851
1873
  };
1852
1874
  },
1853
1875
  },
1876
+ publish_event_definition: {
1877
+ description: `${APEX} — Publish a draft governed custom event (previously defined via define_event) so its schema status becomes "published".`,
1878
+ schema: z.object({
1879
+ name: z.string().min(1).describe("snake_case name of the governed event to publish."),
1880
+ }),
1881
+ handler: async ({ name }) => {
1882
+ try {
1883
+ const res = await apiPatch("/api/schema/events", {
1884
+ name: name.trim(),
1885
+ status: "published",
1886
+ });
1887
+ if (res.error) {
1888
+ return text(`${APEX} Could not publish "${name}": ${res.error}`, true);
1889
+ }
1890
+ const schemaLink = appUrl("/dashboard/settings/workspace/schema");
1891
+ return text(`${APEX} Published governed event "${res.name ?? name.trim()}" (SchemaVer ${res.schemaVer ?? "1-0-0"}, status: ${res.status ?? "published"}). Manage governed events at ${schemaLink}.`);
1892
+ }
1893
+ catch (err) {
1894
+ return text(`${APEX} ${errMsg(err)}`, true);
1895
+ }
1896
+ },
1897
+ },
1854
1898
  log_prediction: {
1855
1899
  description: `${APEX} — Log a prediction about a metric change. Feeds the calibration loop. Before calling, present the metric, expected change, and confidence as options the user can pick from or adjust.`,
1856
1900
  schema: z.object({