@apex-inc/mcp-server 0.71.0 → 0.73.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/dist/setup-catchup-tools.d.ts +51 -14
- package/dist/setup-catchup-tools.d.ts.map +1 -1
- package/dist/setup-catchup-tools.js +146 -21
- package/dist/setup-catchup-tools.js.map +1 -1
- package/dist/setup-checklist.d.ts +1 -0
- package/dist/setup-checklist.d.ts.map +1 -1
- package/dist/setup-checklist.js +2 -1
- package/dist/setup-checklist.js.map +1 -1
- package/dist/smoke-tools.d.ts.map +1 -1
- package/dist/smoke-tools.js +2 -0
- package/dist/smoke-tools.js.map +1 -1
- package/dist/tool-catalog.js +1 -1
- package/dist/tool-catalog.js.map +1 -1
- package/dist/tool-groups.d.ts.map +1 -1
- package/dist/tool-groups.js +5 -0
- package/dist/tool-groups.js.map +1 -1
- package/dist/tools/experiments.js +1 -1
- package/dist/tools/experiments.js.map +1 -1
- package/dist/tools/letters.d.ts +200 -1
- package/dist/tools/letters.d.ts.map +1 -1
- package/dist/tools/letters.js +134 -6
- package/dist/tools/letters.js.map +1 -1
- package/dist/tools/measurement.d.ts +82 -6
- package/dist/tools/measurement.d.ts.map +1 -1
- package/dist/tools/measurement.js +164 -26
- package/dist/tools/measurement.js.map +1 -1
- package/dist/tools/partners.d.ts +14 -14
- package/dist/tools.d.ts +353 -28
- package/dist/tools.d.ts.map +1 -1
- package/dist/workspace-target-url.d.ts.map +1 -1
- package/dist/workspace-target-url.js +8 -3
- package/dist/workspace-target-url.js.map +1 -1
- package/package.json +1 -1
|
@@ -1818,7 +1818,7 @@ Events fired through this tool carry a stable synthetic visitorId (mcp-agent-*,
|
|
|
1818
1818
|
},
|
|
1819
1819
|
},
|
|
1820
1820
|
define_event: {
|
|
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. 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.`,
|
|
1822
1822
|
schema: z.object({
|
|
1823
1823
|
name: z.string().describe("snake_case event name, not already in the Apex Spec"),
|
|
1824
1824
|
description: z.string().describe("One sentence: when this event fires"),
|
|
@@ -1829,38 +1829,140 @@ Events fired through this tool carry a stable synthetic visitorId (mcp-agent-*,
|
|
|
1829
1829
|
.enum(["workspace", "org"])
|
|
1830
1830
|
.optional()
|
|
1831
1831
|
.describe("workspace (default) or org (shared across the org's workspaces)"),
|
|
1832
|
-
|
|
1832
|
+
primaryMetric: z
|
|
1833
1833
|
.boolean()
|
|
1834
1834
|
.optional()
|
|
1835
1835
|
.describe("True if this is a conversion/outcome that can be a journey goal"),
|
|
1836
|
-
|
|
1836
|
+
recommendedTransport: z
|
|
1837
1837
|
.enum(["client", "server", "either"])
|
|
1838
1838
|
.optional()
|
|
1839
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."),
|
|
1840
1844
|
}),
|
|
1841
1845
|
handler: async (args) => {
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1846
|
+
try {
|
|
1847
|
+
const res = await apiPost("/api/schema/events", {
|
|
1848
|
+
name: args.name,
|
|
1849
|
+
description: args.description,
|
|
1850
|
+
fields: args.fields,
|
|
1851
|
+
scope: args.scope,
|
|
1852
|
+
primaryMetric: args.primaryMetric,
|
|
1853
|
+
recommendedTransport: args.recommendedTransport,
|
|
1854
|
+
status: args.publish ? "published" : "draft",
|
|
1855
|
+
});
|
|
1856
|
+
if (res.error) {
|
|
1857
|
+
const hint = res.suggestion
|
|
1858
|
+
? ` Use the canonical event "${res.suggestion}" instead.`
|
|
1859
|
+
: res.code === "exists" || /already defined/i.test(res.error)
|
|
1860
|
+
? ` Use update_event({ name: "${args.name}", ... }) to update it.`
|
|
1861
|
+
: "";
|
|
1862
|
+
return { content: [{ type: "text", text: `Could not define "${args.name}": ${res.error}.${hint}` }] };
|
|
1863
|
+
}
|
|
1864
|
+
const schemaLink = appUrl("/dashboard/settings/workspace/schema");
|
|
1865
|
+
const status = res.status ?? (args.publish ? "published" : "draft");
|
|
1866
|
+
const msg = status === "published"
|
|
1867
|
+
? `Defined and published governed event "${res.name}" (SchemaVer ${res.schemaVer ?? "1-0-0"}, published). Manage governed events at ${schemaLink}.`
|
|
1868
|
+
: `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}.`;
|
|
1869
|
+
return {
|
|
1870
|
+
content: [
|
|
1871
|
+
{
|
|
1872
|
+
type: "text",
|
|
1873
|
+
text: msg,
|
|
1874
|
+
},
|
|
1875
|
+
],
|
|
1876
|
+
};
|
|
1877
|
+
}
|
|
1878
|
+
catch (err) {
|
|
1879
|
+
const msg = errMsg(err);
|
|
1880
|
+
const hint = /already defined|409/i.test(msg)
|
|
1881
|
+
? ` Use update_event({ name: "${args.name}", ... }) to update the existing definition.`
|
|
1853
1882
|
: "";
|
|
1854
|
-
return {
|
|
1883
|
+
return text(`${APEX} Could not define "${args.name}": ${msg}${hint}`, true);
|
|
1884
|
+
}
|
|
1885
|
+
},
|
|
1886
|
+
},
|
|
1887
|
+
update_event: {
|
|
1888
|
+
description: `${APEX} — Update an existing governed custom event in the workspace's Schema (PATCH /api/schema/events). SchemaVer bumps automatically when fields change (addition/revision/model) and the reply flags whether the change is breaking. Pass only the fields you want to change alongside the event name.`,
|
|
1889
|
+
schema: z.object({
|
|
1890
|
+
name: z.string().min(1).describe("snake_case name of the existing governed event to update."),
|
|
1891
|
+
description: z.string().optional().describe("Updated one-sentence description of when this event fires."),
|
|
1892
|
+
domain: z.string().optional().describe("Optional business domain tag for grouping events."),
|
|
1893
|
+
fields: z
|
|
1894
|
+
.record(z.string())
|
|
1895
|
+
.optional()
|
|
1896
|
+
.describe('Updated full field map (field name -> type, e.g. {"widget_id":"string","width":"number?"}).'),
|
|
1897
|
+
primaryMetric: z
|
|
1898
|
+
.boolean()
|
|
1899
|
+
.optional()
|
|
1900
|
+
.describe("True if this event is a business outcome / primary metric."),
|
|
1901
|
+
recommendedTransport: z
|
|
1902
|
+
.enum(["client", "server", "either"])
|
|
1903
|
+
.optional()
|
|
1904
|
+
.describe("Where to send this event: server for money-truth, client for browser intent, or either."),
|
|
1905
|
+
revenueRole: z
|
|
1906
|
+
.enum(["none", "primary", "supporting"])
|
|
1907
|
+
.optional()
|
|
1908
|
+
.describe("Optional revenue role for this event."),
|
|
1909
|
+
status: z
|
|
1910
|
+
.enum(["draft", "published"])
|
|
1911
|
+
.optional()
|
|
1912
|
+
.describe("Set to 'published' to publish or 'draft' to return to draft."),
|
|
1913
|
+
}),
|
|
1914
|
+
handler: async (args) => {
|
|
1915
|
+
try {
|
|
1916
|
+
const body = { name: args.name.trim() };
|
|
1917
|
+
if (args.description !== undefined)
|
|
1918
|
+
body.description = args.description;
|
|
1919
|
+
if (args.domain !== undefined)
|
|
1920
|
+
body.domain = args.domain;
|
|
1921
|
+
if (args.fields !== undefined)
|
|
1922
|
+
body.fields = args.fields;
|
|
1923
|
+
if (args.primaryMetric !== undefined)
|
|
1924
|
+
body.primaryMetric = args.primaryMetric;
|
|
1925
|
+
if (args.recommendedTransport !== undefined)
|
|
1926
|
+
body.recommendedTransport = args.recommendedTransport;
|
|
1927
|
+
if (args.revenueRole !== undefined)
|
|
1928
|
+
body.revenueRole = args.revenueRole;
|
|
1929
|
+
if (args.status !== undefined)
|
|
1930
|
+
body.status = args.status;
|
|
1931
|
+
const res = await apiPatch("/api/schema/events", body);
|
|
1932
|
+
if (res.error) {
|
|
1933
|
+
return text(`${APEX} Could not update "${args.name}": ${res.error}`, true);
|
|
1934
|
+
}
|
|
1935
|
+
const schemaLink = appUrl("/dashboard/settings/workspace/schema");
|
|
1936
|
+
const changeNote = res._change
|
|
1937
|
+
? ` Change: ${res._change}${res._breaking ? " (breaking)" : ""}.`
|
|
1938
|
+
: "";
|
|
1939
|
+
return text(`${APEX} Updated governed event "${res.name ?? args.name.trim()}" (SchemaVer ${res.schemaVer ?? "1-0-0"}, status: ${res.status ?? "draft"}).${changeNote} Manage governed events at ${schemaLink}.`);
|
|
1940
|
+
}
|
|
1941
|
+
catch (err) {
|
|
1942
|
+
return text(`${APEX} ${errMsg(err)}`, true);
|
|
1943
|
+
}
|
|
1944
|
+
},
|
|
1945
|
+
},
|
|
1946
|
+
publish_event_definition: {
|
|
1947
|
+
description: `${APEX} — Publish a draft governed custom event (previously defined via define_event) so its schema status becomes "published".`,
|
|
1948
|
+
schema: z.object({
|
|
1949
|
+
name: z.string().min(1).describe("snake_case name of the governed event to publish."),
|
|
1950
|
+
}),
|
|
1951
|
+
handler: async ({ name }) => {
|
|
1952
|
+
try {
|
|
1953
|
+
const res = await apiPatch("/api/schema/events", {
|
|
1954
|
+
name: name.trim(),
|
|
1955
|
+
status: "published",
|
|
1956
|
+
});
|
|
1957
|
+
if (res.error) {
|
|
1958
|
+
return text(`${APEX} Could not publish "${name}": ${res.error}`, true);
|
|
1959
|
+
}
|
|
1960
|
+
const schemaLink = appUrl("/dashboard/settings/workspace/schema");
|
|
1961
|
+
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}.`);
|
|
1962
|
+
}
|
|
1963
|
+
catch (err) {
|
|
1964
|
+
return text(`${APEX} ${errMsg(err)}`, true);
|
|
1855
1965
|
}
|
|
1856
|
-
return {
|
|
1857
|
-
content: [
|
|
1858
|
-
{
|
|
1859
|
-
type: "text",
|
|
1860
|
-
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.`,
|
|
1861
|
-
},
|
|
1862
|
-
],
|
|
1863
|
-
};
|
|
1864
1966
|
},
|
|
1865
1967
|
},
|
|
1866
1968
|
log_prediction: {
|
|
@@ -2297,7 +2399,7 @@ Events fired through this tool carry a stable synthetic visitorId (mcp-agent-*,
|
|
|
2297
2399
|
},
|
|
2298
2400
|
},
|
|
2299
2401
|
create_conversion: {
|
|
2300
|
-
description: `${APEX} —
|
|
2402
|
+
description: `${APEX} — Legacy conversion-goal tool. Prefer create_key_event for new Key Events. Every conversion goal created here is automatically mirrored as a Key Event (id: conv-from-cg-<id>). To prevent double-counting, this tool checks active Key Events first and refuses by default if one already counts the same event, selector, or URL (pass allow_duplicate: true only if you intentionally want a second Key Event).`,
|
|
2301
2403
|
schema: z.object({
|
|
2302
2404
|
name: z.string().describe('Human label, e.g. "Purchase" or "Signup"'),
|
|
2303
2405
|
type: z
|
|
@@ -2325,9 +2427,41 @@ Events fired through this tool carry a stable synthetic visitorId (mcp-agent-*,
|
|
|
2325
2427
|
isPrimary: z
|
|
2326
2428
|
.boolean()
|
|
2327
2429
|
.optional()
|
|
2328
|
-
.describe("Make this the primary conversion (only one can be primary)."),
|
|
2430
|
+
.describe("Make this the primary conversion / main goal (only one can be primary)."),
|
|
2431
|
+
allowDuplicate: z
|
|
2432
|
+
.boolean()
|
|
2433
|
+
.optional()
|
|
2434
|
+
.describe("Set true only if you intentionally want to create a second Key Event even when one already counts the same event/target."),
|
|
2329
2435
|
}),
|
|
2330
2436
|
handler: async (args) => {
|
|
2437
|
+
if (!args.allowDuplicate) {
|
|
2438
|
+
try {
|
|
2439
|
+
const existingRes = await apiGet("/api/key-events");
|
|
2440
|
+
const existing = (existingRes.data?.keyEvents ?? []).filter((k) => !k.archivedAt);
|
|
2441
|
+
const wantedEvent = args.eventName?.trim().toLowerCase();
|
|
2442
|
+
const wantedSelector = args.selector?.trim();
|
|
2443
|
+
const wantedUrl = args.targetUrl?.trim().toLowerCase();
|
|
2444
|
+
const matches = existing.filter((k) => (k.sources ?? []).some((s) => {
|
|
2445
|
+
if (args.type === "custom_event" && wantedEvent) {
|
|
2446
|
+
return s.type === "custom_event" && s.eventName?.trim().toLowerCase() === wantedEvent;
|
|
2447
|
+
}
|
|
2448
|
+
if ((args.type === "form_submit" || args.type === "click") && wantedSelector) {
|
|
2449
|
+
return s.type === args.type && s.selector?.trim() === wantedSelector;
|
|
2450
|
+
}
|
|
2451
|
+
if (args.type === "pageview" && wantedUrl) {
|
|
2452
|
+
return s.type === "pageview" && s.targetUrl?.trim().toLowerCase() === wantedUrl;
|
|
2453
|
+
}
|
|
2454
|
+
return false;
|
|
2455
|
+
}));
|
|
2456
|
+
if (matches.length > 0) {
|
|
2457
|
+
const list = matches.map((m) => `"${m.name}" (${m.id})`).join(", ");
|
|
2458
|
+
return text(`${APEX} Stopped to avoid double-counting: an active Key Event already counts this ${args.type === "custom_event" ? `event ("${args.eventName}")` : "target"}: ${list}. Because create_conversion also creates a mirrored Key Event (conv-from-cg-<id>), creating another would count it twice. Use update_key_event or set_primary_conversion on the existing Key Event instead, or re-run with allow_duplicate: true if you intentionally want a second one.`, true);
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
catch {
|
|
2462
|
+
// Best-effort duplicate check — proceed if /api/key-events is unreachable.
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2331
2465
|
const payload = {
|
|
2332
2466
|
name: args.name,
|
|
2333
2467
|
type: args.type,
|
|
@@ -2338,11 +2472,15 @@ Events fired through this tool carry a stable synthetic visitorId (mcp-agent-*,
|
|
|
2338
2472
|
...(args.targetUrl ? { targetUrl: args.targetUrl } : {}),
|
|
2339
2473
|
};
|
|
2340
2474
|
const data = await apiPost("/api/conversion-goals", payload);
|
|
2475
|
+
const mirroredKeyEventId = data.id ? `conv-from-cg-${data.id}` : undefined;
|
|
2476
|
+
const mirrorNote = mirroredKeyEventId
|
|
2477
|
+
? ` Note: Apex also mirrored this as Key Event "${mirroredKeyEventId}" (prefer create_key_event for new Key Events, or update_key_event to edit it).`
|
|
2478
|
+
: " Note: Apex automatically mirrors conversion goals as Key Events (prefer create_key_event for new Key Events).";
|
|
2341
2479
|
return {
|
|
2342
2480
|
content: [
|
|
2343
2481
|
{
|
|
2344
2482
|
type: "text",
|
|
2345
|
-
text: `Conversion created
|
|
2483
|
+
text: `Conversion created.${mirrorNote}\n\n${JSON.stringify(mirroredKeyEventId ? { ...data, mirroredKeyEventId } : data, null, 2)}`,
|
|
2346
2484
|
},
|
|
2347
2485
|
],
|
|
2348
2486
|
};
|