@apex-inc/mcp-server 0.72.0 → 0.74.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 +29 -5
- package/dist/setup-catchup-tools.d.ts.map +1 -1
- package/dist/setup-catchup-tools.js +40 -6
- package/dist/setup-catchup-tools.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 +2 -0
- package/dist/tool-groups.js.map +1 -1
- package/dist/tools/letters.js +2 -2
- package/dist/tools/letters.js.map +1 -1
- package/dist/tools/measurement.d.ts +53 -0
- package/dist/tools/measurement.d.ts.map +1 -1
- package/dist/tools/measurement.js +135 -29
- package/dist/tools/measurement.js.map +1 -1
- package/dist/tools.d.ts +86 -5
- package/dist/tools.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1843,34 +1843,104 @@ Events fired through this tool carry a stable synthetic visitorId (mcp-agent-*,
|
|
|
1843
1843
|
.describe("Set true to publish immediately (status: 'published'). Default false creates a draft that still works in journeys, key events, and experiments."),
|
|
1844
1844
|
}),
|
|
1845
1845
|
handler: async (args) => {
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
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.`
|
|
1858
1882
|
: "";
|
|
1859
|
-
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);
|
|
1860
1943
|
}
|
|
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}.`;
|
|
1866
|
-
return {
|
|
1867
|
-
content: [
|
|
1868
|
-
{
|
|
1869
|
-
type: "text",
|
|
1870
|
-
text: msg,
|
|
1871
|
-
},
|
|
1872
|
-
],
|
|
1873
|
-
};
|
|
1874
1944
|
},
|
|
1875
1945
|
},
|
|
1876
1946
|
publish_event_definition: {
|
|
@@ -2329,7 +2399,7 @@ Events fired through this tool carry a stable synthetic visitorId (mcp-agent-*,
|
|
|
2329
2399
|
},
|
|
2330
2400
|
},
|
|
2331
2401
|
create_conversion: {
|
|
2332
|
-
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).`,
|
|
2333
2403
|
schema: z.object({
|
|
2334
2404
|
name: z.string().describe('Human label, e.g. "Purchase" or "Signup"'),
|
|
2335
2405
|
type: z
|
|
@@ -2357,9 +2427,41 @@ Events fired through this tool carry a stable synthetic visitorId (mcp-agent-*,
|
|
|
2357
2427
|
isPrimary: z
|
|
2358
2428
|
.boolean()
|
|
2359
2429
|
.optional()
|
|
2360
|
-
.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."),
|
|
2361
2435
|
}),
|
|
2362
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
|
+
}
|
|
2363
2465
|
const payload = {
|
|
2364
2466
|
name: args.name,
|
|
2365
2467
|
type: args.type,
|
|
@@ -2370,11 +2472,15 @@ Events fired through this tool carry a stable synthetic visitorId (mcp-agent-*,
|
|
|
2370
2472
|
...(args.targetUrl ? { targetUrl: args.targetUrl } : {}),
|
|
2371
2473
|
};
|
|
2372
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).";
|
|
2373
2479
|
return {
|
|
2374
2480
|
content: [
|
|
2375
2481
|
{
|
|
2376
2482
|
type: "text",
|
|
2377
|
-
text: `Conversion created
|
|
2483
|
+
text: `Conversion created.${mirrorNote}\n\n${JSON.stringify(mirroredKeyEventId ? { ...data, mirroredKeyEventId } : data, null, 2)}`,
|
|
2378
2484
|
},
|
|
2379
2485
|
],
|
|
2380
2486
|
};
|