@centrali-io/centrali-mcp 9.0.2 → 9.1.1

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/README.md CHANGED
@@ -135,6 +135,7 @@ After connecting, call `describe_centrali` first — it returns the full capabil
135
135
  | `invoke_trigger` | Invoke an on-demand trigger (returns job ID — async) |
136
136
  | `pause_trigger` | Pause a trigger |
137
137
  | `resume_trigger` | Resume a paused trigger |
138
+ | `test_send_trigger` | Send a signed synthetic test event through an http-trigger's real verify/dispatch path |
138
139
  | `get_function_run` | Get execution result by run ID (status, output, errors) |
139
140
  | `list_function_runs` | List runs by trigger or function ID (execution history) |
140
141
  | `get_compute_job_status` | Check async job status by job ID (poll after invoke_trigger) |
@@ -366,6 +367,7 @@ With `consecutiveFailures` at `0`, a null or stale `lastEvaluatedAt` means the a
366
367
  | `update_webhook_subscription` | Update name, URL, events, recordSlugs, or active flag |
367
368
  | `delete_webhook_subscription` | Delete a subscription (delivery history retained) |
368
369
  | `rotate_webhook_subscription_secret` | Regenerate the signing secret (immediate cutover) |
370
+ | `publish_webhook_event` | Publish a named business event (e.g. `invoice.paid`) and fan it out to matching subscriptions |
369
371
  | `list_webhook_deliveries` | List delivery history for a subscription (trimmed rows) |
370
372
  | `get_webhook_delivery` | Get a single delivery with full payload and response body |
371
373
  | `retry_webhook_delivery` | Replay a delivery — reuses the original payload and signature |
@@ -520,6 +520,39 @@ function registerComputeTools(server, sdk, centraliUrl, workspaceId) {
520
520
  };
521
521
  }
522
522
  }));
523
+ (0, _register_js_1.registerTool)(server, "test_send_trigger", "Send a synthetic, correctly-signed test event through an http-trigger's real signature-verification, buffer-write, and dispatch path (CEN-1472) — proves the provider preset/secret configuration actually works without needing a real provider account or exposing a public URL. Only works when the trigger has validateSignature enabled; a verification failure (misconfigured secret/preset) is returned as a normal result, not an error. On success, a real inbound_events row is written and dispatched exactly like a live arrival, so it also shows up in list_events/get_event/trace_correlation and (if auto-persist is on) writes a record.", {
524
+ triggerId: zod_1.z.string().describe("The http-trigger ID (UUID) to test"),
525
+ payload: zod_1.z
526
+ .record(zod_1.z.string(), zod_1.z.any())
527
+ .optional()
528
+ .describe("Custom JSON payload to sign and send. Defaults to a small built-in sample payload."),
529
+ }, (_a) => __awaiter(this, [_a], void 0, function* ({ triggerId, payload }) {
530
+ try {
531
+ const token = yield ensureToken(sdk);
532
+ const url = new URL(centraliUrl);
533
+ const hostname = url.hostname.startsWith("api.")
534
+ ? url.hostname
535
+ : `api.${url.hostname}`;
536
+ const apiUrl = `${url.protocol}//${hostname}/data/workspace/${workspaceId}/api/v1/function-triggers/${encodeURIComponent(triggerId)}/test-send`;
537
+ const result = yield axios_1.default.post(apiUrl, payload !== undefined ? { payload } : {}, { headers: token ? { Authorization: `Bearer ${token}` } : {} });
538
+ return {
539
+ content: [
540
+ { type: "text", text: JSON.stringify(result.data, null, 2) },
541
+ ],
542
+ };
543
+ }
544
+ catch (error) {
545
+ return {
546
+ content: [
547
+ {
548
+ type: "text",
549
+ text: (0, _register_js_1.formatError)(error, `sending a test event to trigger '${triggerId}'`),
550
+ },
551
+ ],
552
+ isError: true,
553
+ };
554
+ }
555
+ }));
523
556
  // ── Function Runs tools ────────────────────────────────────────────
524
557
  (0, _register_js_1.registerTool)(server, "get_function_run", "Get a function run by ID. Returns status, output, error, timing, and execution metadata. Use this to check the result of an async trigger invocation or test execution.", {
525
558
  runId: zod_1.z.string().describe("The function run ID (UUID)"),
@@ -161,7 +161,7 @@ function registerDescribeTools(server) {
161
161
  ],
162
162
  },
163
163
  webhooks: {
164
- summary: "Outbound webhook subscriptions for record events. Centrali POSTs a signed JSON payload to your URL on record_created, record_updated, record_deleted, and records_bulk_created. Each dispatch is signed with HMAC-SHA256 under the subscription's whsec_ secret and every attempt is recorded in the delivery log for inspection and replay.",
164
+ summary: "Outbound webhook subscriptions. Centrali POSTs a signed JSON payload to your URL on record lifecycle events (record_created, record_updated, record_deleted, records_bulk_created) and on named business events published via publish_webhook_event. Each dispatch is signed with HMAC-SHA256 under the subscription's whsec_ secret and every attempt is recorded in the delivery log for inspection and replay.",
165
165
  describeWith: "describe_webhooks",
166
166
  tools: [
167
167
  "list_webhook_subscriptions",
@@ -170,6 +170,7 @@ function registerDescribeTools(server) {
170
170
  "update_webhook_subscription",
171
171
  "delete_webhook_subscription",
172
172
  "rotate_webhook_subscription_secret",
173
+ "publish_webhook_event",
173
174
  "list_webhook_deliveries",
174
175
  "get_webhook_delivery",
175
176
  "retry_webhook_delivery",
@@ -1342,7 +1343,7 @@ function registerDescribeTools(server) {
1342
1343
  id: "UUID",
1343
1344
  name: "string",
1344
1345
  url: "string — HTTPS URL that receives the POSTed payload",
1345
- events: "RecordEventType[] — subscribed events",
1346
+ events: "string[] — subscribed events: record-lifecycle events (see event_types) and/or named business events like 'invoice.paid' (see named_event_publishing)",
1346
1347
  recordSlugs: "string[] — restrict to these collections. An empty array (or null on a read from an older row) means the subscription receives events for all collections. On update_webhook_subscription, pass [] to clear the restriction; omit the field to leave scope unchanged.",
1347
1348
  active: "boolean — when false, dispatches are skipped",
1348
1349
  secret: "string | undefined — `whsec_<base64url>` signing secret. Returned ONLY on create_webhook_subscription and rotate_webhook_subscription_secret; omitted on list/get.",
@@ -1355,6 +1356,14 @@ function registerDescribeTools(server) {
1355
1356
  record_deleted: "A record was deleted (soft or hard)",
1356
1357
  records_bulk_created: "Multiple records were inserted in a batch",
1357
1358
  },
1359
+ named_event_publishing: {
1360
+ description: "publish_webhook_event emits an arbitrary named business event (e.g. 'invoice.paid') and fans it out to every active subscription that lists that event name. Distinct from record lifecycle events — the workspace decides the vocabulary.",
1361
+ params: { event: "string — printable ASCII, no spaces, max 128 chars, cannot start with 'record.'", data: "object | undefined — max 256 KB serialized" },
1362
+ response: "202 { correlationId, event, deliveries: [{ id, subscriptionId, status: 'retrying' | 'filtered' | 'failed' }] }",
1363
+ empty_deliveries: "An empty deliveries array is a SUCCESS — nothing in the workspace subscribes to that event name.",
1364
+ filtered_deliveries: "A published event carries no collection, so a subscription with a recordSlugs scope cannot match it — those are recorded as status 'filtered' rather than dropped silently, so the skip is visible in the delivery log.",
1365
+ idempotency: "publish_webhook_event sends a fresh Idempotency-Key per call, so an ambiguous transport retry of one tool invocation is deduped by the server rather than fanning the event out twice.",
1366
+ },
1358
1367
  outbound_payload_shape: {
1359
1368
  description: "Body shape Centrali POSTs to the subscribed URL. JSON-serialized; the raw bytes of this body are what gets HMAC-signed into X-Signature.",
1360
1369
  event: "string — one of 'record_created' | 'record_updated' | 'record_deleted' | 'records_bulk_created'",
@@ -1447,6 +1456,12 @@ function registerDescribeTools(server) {
1447
1456
  description: "Cancel a delivery that is currently retrying. Returns 409 if the row is not retrying or is mid-dispatch.",
1448
1457
  required_params: ["deliveryId"],
1449
1458
  },
1459
+ publish_webhook_event: {
1460
+ description: "Publish a named business event and fan it out to matching subscriptions. See named_event_publishing above.",
1461
+ required_params: ["event"],
1462
+ optional_params: ["data"],
1463
+ example: { event: "invoice.paid", data: { invoiceId: "inv_123", amount: 4200 } },
1464
+ },
1450
1465
  },
1451
1466
  tips: [
1452
1467
  "Store the `whsec_` secret the moment create_webhook_subscription or rotate_webhook_subscription_secret returns it — it is not retrievable afterwards.",
@@ -1456,6 +1471,7 @@ function registerDescribeTools(server) {
1456
1471
  "Use since/until on list_webhook_deliveries to scope a forensic pass to a time window.",
1457
1472
  "retry_webhook_delivery preserves the original signature — pair it with a fixed bug on the receiver's side instead of regenerating payloads.",
1458
1473
  "cancel_webhook_delivery only works while the row is 'retrying'. If the dispatcher has already claimed the row the call returns 409; wait a second and try again.",
1474
+ "publish_webhook_event with an empty deliveries[] response is not an error — it means no subscription lists that event name yet. Add the name to a subscription's events to route it.",
1459
1475
  ],
1460
1476
  }, null, 2),
1461
1477
  },
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.registerWebhookSubscriptionTools = registerWebhookSubscriptionTools;
13
+ const node_crypto_1 = require("node:crypto");
13
14
  const zod_1 = require("zod");
14
15
  const _register_js_1 = require("./_register.js");
15
16
  const RECORD_EVENT_VALUES = [
@@ -19,6 +20,11 @@ const RECORD_EVENT_VALUES = [
19
20
  "records_bulk_created",
20
21
  ];
21
22
  const DELIVERY_STATUS_VALUES = ["success", "failed", "retrying"];
23
+ // Subscriptions accept the four record-lifecycle events AND arbitrary named
24
+ // business events (e.g. `invoice.paid`) — the backend validator is
25
+ // `z.array(z.string().min(1))` and `publish_webhook_event` fans those out.
26
+ const EVENTS_DESCRIPTION = `Events to subscribe to. Either a record-lifecycle event (${RECORD_EVENT_VALUES.join(", ")}) ` +
27
+ `or a named business event such as 'invoice.paid' (any printable string, no spaces).`;
22
28
  function registerWebhookSubscriptionTools(server, sdk) {
23
29
  // ── Subscription CRUD ──────────────────────────────────────────
24
30
  (0, _register_js_1.registerTool)(server, "list_webhook_subscriptions", "List all webhook subscriptions in the workspace. Subscriptions deliver record events to an external URL, signed with HMAC-SHA256 under the subscription's `whsec_` secret.", {}, () => __awaiter(this, void 0, void 0, function* () {
@@ -56,9 +62,7 @@ function registerWebhookSubscriptionTools(server, sdk) {
56
62
  (0, _register_js_1.registerTool)(server, "create_webhook_subscription", "Create a webhook subscription. The response includes the signing secret (whsec_...) — capture it immediately, it is not returned on subsequent reads.", {
57
63
  name: zod_1.z.string().describe("Display name for the subscription"),
58
64
  url: zod_1.z.string().describe("HTTPS URL that will receive POSTed event payloads"),
59
- events: zod_1.z
60
- .array(zod_1.z.enum(RECORD_EVENT_VALUES))
61
- .describe("Record events to subscribe to: record_created, record_updated, record_deleted, records_bulk_created"),
65
+ events: zod_1.z.array(zod_1.z.string().min(1)).describe(EVENTS_DESCRIPTION),
62
66
  recordSlugs: zod_1.z
63
67
  .array(zod_1.z.string())
64
68
  .optional()
@@ -93,9 +97,9 @@ function registerWebhookSubscriptionTools(server, sdk) {
93
97
  name: zod_1.z.string().optional().describe("Updated display name"),
94
98
  url: zod_1.z.string().optional().describe("Updated HTTPS URL"),
95
99
  events: zod_1.z
96
- .array(zod_1.z.enum(RECORD_EVENT_VALUES))
100
+ .array(zod_1.z.string().min(1))
97
101
  .optional()
98
- .describe("Updated list of subscribed events"),
102
+ .describe(`Updated list of subscribed events. ${EVENTS_DESCRIPTION}`),
99
103
  recordSlugs: zod_1.z
100
104
  .array(zod_1.z.string())
101
105
  .optional()
@@ -178,6 +182,33 @@ function registerWebhookSubscriptionTools(server, sdk) {
178
182
  };
179
183
  }
180
184
  }));
185
+ (0, _register_js_1.registerTool)(server, "publish_webhook_event", "Publish a named business event (e.g. 'invoice.paid') and fan it out to every active subscription that lists that event and has no collection scope. Returns 202 with a correlationId and one delivery row per matched subscription. An empty deliveries array is a success — nothing subscribes to that event name. Event names must be printable ASCII with no spaces, max 128 chars; names beginning with 'record.' are reserved and rejected.", {
186
+ event: zod_1.z
187
+ .string()
188
+ .describe("Event name subscriptions match on, e.g. 'invoice.paid'. Printable ASCII, no spaces, max 128 chars. Cannot start with 'record.'."),
189
+ data: zod_1.z
190
+ .record(zod_1.z.string(), zod_1.z.unknown())
191
+ .optional()
192
+ .describe("Arbitrary JSON object delivered as the event's data body. Max 256 KB serialized."),
193
+ }, (_a) => __awaiter(this, [_a], void 0, function* ({ event, data }) {
194
+ try {
195
+ // One stable key per tool invocation so an ambiguous transport retry of
196
+ // this call is deduped by the route's `withIdempotency` middleware
197
+ // rather than fanning the business event out twice.
198
+ const result = yield sdk.webhookSubscriptions.publish(data !== undefined ? { event, data } : { event }, { idempotencyKey: (0, node_crypto_1.randomUUID)() });
199
+ return {
200
+ content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
201
+ };
202
+ }
203
+ catch (error) {
204
+ return {
205
+ content: [
206
+ { type: "text", text: (0, _register_js_1.formatError)(error, `publishing webhook event '${event}'`) },
207
+ ],
208
+ isError: true,
209
+ };
210
+ }
211
+ }));
181
212
  // ── Delivery history + replay ──────────────────────────────────
182
213
  (0, _register_js_1.registerTool)(server, "list_webhook_deliveries", "List delivery history for a webhook subscription. Rows omit requestPayload and responseBody — use get_webhook_delivery to fetch full payload and response body for a specific delivery.", {
183
214
  subscriptionId: zod_1.z.string().describe("The webhook subscription UUID"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centrali-io/centrali-mcp",
3
- "version": "9.0.2",
3
+ "version": "9.1.1",
4
4
  "description": "Centrali MCP Server - AI assistant integration for Centrali workspaces",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",
@@ -25,7 +25,7 @@
25
25
  "author": "Blueinit",
26
26
  "license": "ISC",
27
27
  "dependencies": {
28
- "@centrali-io/centrali-sdk": "^9.0.2",
28
+ "@centrali-io/centrali-sdk": "^9.1.1",
29
29
  "@modelcontextprotocol/sdk": "^1.28.0"
30
30
  },
31
31
  "devDependencies": {
@@ -580,6 +580,49 @@ export function registerComputeTools(server: McpServer, sdk: CentraliSDK, centra
580
580
  }
581
581
  );
582
582
 
583
+ registerTool<any>(server,
584
+ "test_send_trigger",
585
+ "Send a synthetic, correctly-signed test event through an http-trigger's real signature-verification, buffer-write, and dispatch path (CEN-1472) — proves the provider preset/secret configuration actually works without needing a real provider account or exposing a public URL. Only works when the trigger has validateSignature enabled; a verification failure (misconfigured secret/preset) is returned as a normal result, not an error. On success, a real inbound_events row is written and dispatched exactly like a live arrival, so it also shows up in list_events/get_event/trace_correlation and (if auto-persist is on) writes a record.",
586
+ {
587
+ triggerId: z.string().describe("The http-trigger ID (UUID) to test"),
588
+ payload: z
589
+ .record(z.string(), z.any())
590
+ .optional()
591
+ .describe("Custom JSON payload to sign and send. Defaults to a small built-in sample payload."),
592
+ },
593
+ async ({ triggerId, payload }) => {
594
+ try {
595
+ const token = await ensureToken(sdk);
596
+ const url = new URL(centraliUrl);
597
+ const hostname = url.hostname.startsWith("api.")
598
+ ? url.hostname
599
+ : `api.${url.hostname}`;
600
+ const apiUrl = `${url.protocol}//${hostname}/data/workspace/${workspaceId}/api/v1/function-triggers/${encodeURIComponent(triggerId)}/test-send`;
601
+
602
+ const result = await axios.post(
603
+ apiUrl,
604
+ payload !== undefined ? { payload } : {},
605
+ { headers: token ? { Authorization: `Bearer ${token}` } : {} }
606
+ );
607
+ return {
608
+ content: [
609
+ { type: "text", text: JSON.stringify(result.data, null, 2) },
610
+ ],
611
+ };
612
+ } catch (error: unknown) {
613
+ return {
614
+ content: [
615
+ {
616
+ type: "text",
617
+ text: formatError(error, `sending a test event to trigger '${triggerId}'`),
618
+ },
619
+ ],
620
+ isError: true,
621
+ };
622
+ }
623
+ }
624
+ );
625
+
583
626
  // ── Function Runs tools ────────────────────────────────────────────
584
627
 
585
628
  registerTool<any>(server,
@@ -167,7 +167,7 @@ export function registerDescribeTools(server: McpServer) {
167
167
  },
168
168
  webhooks: {
169
169
  summary:
170
- "Outbound webhook subscriptions for record events. Centrali POSTs a signed JSON payload to your URL on record_created, record_updated, record_deleted, and records_bulk_created. Each dispatch is signed with HMAC-SHA256 under the subscription's whsec_ secret and every attempt is recorded in the delivery log for inspection and replay.",
170
+ "Outbound webhook subscriptions. Centrali POSTs a signed JSON payload to your URL on record lifecycle events (record_created, record_updated, record_deleted, records_bulk_created) and on named business events published via publish_webhook_event. Each dispatch is signed with HMAC-SHA256 under the subscription's whsec_ secret and every attempt is recorded in the delivery log for inspection and replay.",
171
171
  describeWith: "describe_webhooks",
172
172
  tools: [
173
173
  "list_webhook_subscriptions",
@@ -176,6 +176,7 @@ export function registerDescribeTools(server: McpServer) {
176
176
  "update_webhook_subscription",
177
177
  "delete_webhook_subscription",
178
178
  "rotate_webhook_subscription_secret",
179
+ "publish_webhook_event",
179
180
  "list_webhook_deliveries",
180
181
  "get_webhook_delivery",
181
182
  "retry_webhook_delivery",
@@ -1456,7 +1457,7 @@ export function registerDescribeTools(server: McpServer) {
1456
1457
  id: "UUID",
1457
1458
  name: "string",
1458
1459
  url: "string — HTTPS URL that receives the POSTed payload",
1459
- events: "RecordEventType[] — subscribed events",
1460
+ events: "string[] — subscribed events: record-lifecycle events (see event_types) and/or named business events like 'invoice.paid' (see named_event_publishing)",
1460
1461
  recordSlugs: "string[] — restrict to these collections. An empty array (or null on a read from an older row) means the subscription receives events for all collections. On update_webhook_subscription, pass [] to clear the restriction; omit the field to leave scope unchanged.",
1461
1462
  active: "boolean — when false, dispatches are skipped",
1462
1463
  secret: "string | undefined — `whsec_<base64url>` signing secret. Returned ONLY on create_webhook_subscription and rotate_webhook_subscription_secret; omitted on list/get.",
@@ -1469,6 +1470,18 @@ export function registerDescribeTools(server: McpServer) {
1469
1470
  record_deleted: "A record was deleted (soft or hard)",
1470
1471
  records_bulk_created: "Multiple records were inserted in a batch",
1471
1472
  },
1473
+ named_event_publishing: {
1474
+ description:
1475
+ "publish_webhook_event emits an arbitrary named business event (e.g. 'invoice.paid') and fans it out to every active subscription that lists that event name. Distinct from record lifecycle events — the workspace decides the vocabulary.",
1476
+ params: { event: "string — printable ASCII, no spaces, max 128 chars, cannot start with 'record.'", data: "object | undefined — max 256 KB serialized" },
1477
+ response: "202 { correlationId, event, deliveries: [{ id, subscriptionId, status: 'retrying' | 'filtered' | 'failed' }] }",
1478
+ empty_deliveries:
1479
+ "An empty deliveries array is a SUCCESS — nothing in the workspace subscribes to that event name.",
1480
+ filtered_deliveries:
1481
+ "A published event carries no collection, so a subscription with a recordSlugs scope cannot match it — those are recorded as status 'filtered' rather than dropped silently, so the skip is visible in the delivery log.",
1482
+ idempotency:
1483
+ "publish_webhook_event sends a fresh Idempotency-Key per call, so an ambiguous transport retry of one tool invocation is deduped by the server rather than fanning the event out twice.",
1484
+ },
1472
1485
  outbound_payload_shape: {
1473
1486
  description:
1474
1487
  "Body shape Centrali POSTs to the subscribed URL. JSON-serialized; the raw bytes of this body are what gets HMAC-signed into X-Signature.",
@@ -1576,6 +1589,13 @@ export function registerDescribeTools(server: McpServer) {
1576
1589
  "Cancel a delivery that is currently retrying. Returns 409 if the row is not retrying or is mid-dispatch.",
1577
1590
  required_params: ["deliveryId"],
1578
1591
  },
1592
+ publish_webhook_event: {
1593
+ description:
1594
+ "Publish a named business event and fan it out to matching subscriptions. See named_event_publishing above.",
1595
+ required_params: ["event"],
1596
+ optional_params: ["data"],
1597
+ example: { event: "invoice.paid", data: { invoiceId: "inv_123", amount: 4200 } },
1598
+ },
1579
1599
  },
1580
1600
  tips: [
1581
1601
  "Store the `whsec_` secret the moment create_webhook_subscription or rotate_webhook_subscription_secret returns it — it is not retrievable afterwards.",
@@ -1585,6 +1605,7 @@ export function registerDescribeTools(server: McpServer) {
1585
1605
  "Use since/until on list_webhook_deliveries to scope a forensic pass to a time window.",
1586
1606
  "retry_webhook_delivery preserves the original signature — pair it with a fixed bug on the receiver's side instead of regenerating payloads.",
1587
1607
  "cancel_webhook_delivery only works while the row is 'retrying'. If the dispatcher has already claimed the row the call returns 409; wait a second and try again.",
1608
+ "publish_webhook_event with an empty deliveries[] response is not an error — it means no subscription lists that event name yet. Add the name to a subscription's events to route it.",
1588
1609
  ],
1589
1610
  },
1590
1611
  null,
@@ -1,3 +1,4 @@
1
+ import { randomUUID } from "node:crypto";
1
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
3
  import { CentraliSDK } from "@centrali-io/centrali-sdk";
3
4
  import { z } from "zod";
@@ -12,7 +13,13 @@ const RECORD_EVENT_VALUES = [
12
13
 
13
14
  const DELIVERY_STATUS_VALUES = ["success", "failed", "retrying"] as const;
14
15
 
15
- type RecordEventValue = (typeof RECORD_EVENT_VALUES)[number];
16
+ // Subscriptions accept the four record-lifecycle events AND arbitrary named
17
+ // business events (e.g. `invoice.paid`) — the backend validator is
18
+ // `z.array(z.string().min(1))` and `publish_webhook_event` fans those out.
19
+ const EVENTS_DESCRIPTION =
20
+ `Events to subscribe to. Either a record-lifecycle event (${RECORD_EVENT_VALUES.join(", ")}) ` +
21
+ `or a named business event such as 'invoice.paid' (any printable string, no spaces).`;
22
+
16
23
  type DeliveryStatusValue = (typeof DELIVERY_STATUS_VALUES)[number];
17
24
 
18
25
  export function registerWebhookSubscriptionTools(server: McpServer, sdk: CentraliSDK) {
@@ -65,7 +72,7 @@ export function registerWebhookSubscriptionTools(server: McpServer, sdk: Central
65
72
  registerTool<{
66
73
  name: string;
67
74
  url: string;
68
- events: RecordEventValue[];
75
+ events: string[];
69
76
  recordSlugs?: string[];
70
77
  active?: boolean;
71
78
  }>(
@@ -75,9 +82,7 @@ export function registerWebhookSubscriptionTools(server: McpServer, sdk: Central
75
82
  {
76
83
  name: z.string().describe("Display name for the subscription"),
77
84
  url: z.string().describe("HTTPS URL that will receive POSTed event payloads"),
78
- events: z
79
- .array(z.enum(RECORD_EVENT_VALUES))
80
- .describe("Record events to subscribe to: record_created, record_updated, record_deleted, records_bulk_created"),
85
+ events: z.array(z.string().min(1)).describe(EVENTS_DESCRIPTION),
81
86
  recordSlugs: z
82
87
  .array(z.string())
83
88
  .optional()
@@ -112,7 +117,7 @@ export function registerWebhookSubscriptionTools(server: McpServer, sdk: Central
112
117
  subscriptionId: string;
113
118
  name?: string;
114
119
  url?: string;
115
- events?: RecordEventValue[];
120
+ events?: string[];
116
121
  recordSlugs?: string[];
117
122
  active?: boolean;
118
123
  }>(
@@ -124,9 +129,9 @@ export function registerWebhookSubscriptionTools(server: McpServer, sdk: Central
124
129
  name: z.string().optional().describe("Updated display name"),
125
130
  url: z.string().optional().describe("Updated HTTPS URL"),
126
131
  events: z
127
- .array(z.enum(RECORD_EVENT_VALUES))
132
+ .array(z.string().min(1))
128
133
  .optional()
129
- .describe("Updated list of subscribed events"),
134
+ .describe(`Updated list of subscribed events. ${EVENTS_DESCRIPTION}`),
130
135
  recordSlugs: z
131
136
  .array(z.string())
132
137
  .optional()
@@ -219,6 +224,42 @@ export function registerWebhookSubscriptionTools(server: McpServer, sdk: Central
219
224
  }
220
225
  );
221
226
 
227
+ registerTool<{ event: string; data?: Record<string, unknown> }>(
228
+ server,
229
+ "publish_webhook_event",
230
+ "Publish a named business event (e.g. 'invoice.paid') and fan it out to every active subscription that lists that event and has no collection scope. Returns 202 with a correlationId and one delivery row per matched subscription. An empty deliveries array is a success — nothing subscribes to that event name. Event names must be printable ASCII with no spaces, max 128 chars; names beginning with 'record.' are reserved and rejected.",
231
+ {
232
+ event: z
233
+ .string()
234
+ .describe("Event name subscriptions match on, e.g. 'invoice.paid'. Printable ASCII, no spaces, max 128 chars. Cannot start with 'record.'."),
235
+ data: z
236
+ .record(z.string(), z.unknown())
237
+ .optional()
238
+ .describe("Arbitrary JSON object delivered as the event's data body. Max 256 KB serialized."),
239
+ },
240
+ async ({ event, data }) => {
241
+ try {
242
+ // One stable key per tool invocation so an ambiguous transport retry of
243
+ // this call is deduped by the route's `withIdempotency` middleware
244
+ // rather than fanning the business event out twice.
245
+ const result = await sdk.webhookSubscriptions.publish(
246
+ data !== undefined ? { event, data } : { event },
247
+ { idempotencyKey: randomUUID() }
248
+ );
249
+ return {
250
+ content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }],
251
+ };
252
+ } catch (error: unknown) {
253
+ return {
254
+ content: [
255
+ { type: "text", text: formatError(error, `publishing webhook event '${event}'`) },
256
+ ],
257
+ isError: true,
258
+ };
259
+ }
260
+ }
261
+ );
262
+
222
263
  // ── Delivery history + replay ──────────────────────────────────
223
264
 
224
265
  registerTool<{