MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / registerWebhookTools

Function registerWebhookTools

mcp/src/tools/webhooks.ts:20–217  ·  view source on GitHub ↗
(server: McpServer, client: McpClient)

Source from the content-addressed store, hash-verified

18 * rotate-secret. Other reads scrub it.
19 */
20export function registerWebhookTools(server: McpServer, client: McpClient): void {
21 const filtersSchema = z
22 .object({
23 agent_ids: z.array(z.string()).optional(),
24 conversation_ids: z.array(z.string()).optional(),
25 labels: z.array(z.string()).optional(),
26 })
27 .strict()
28 .describe(
29 "Optional scope filters. Empty / missing keys mean 'no constraint of that type'. agent_ids must reference agents owned by the caller; cross-user ids are rejected. conversation_ids / labels are exact-match.",
30 );
31
32 // Map the snake_case tool filter shape to the SDK's camelCase
33 // WebhookFiltersView. Returns undefined for an absent filter so we
34 // don't send an empty object.
35 const mapFilters = (
36 f?: { agent_ids?: string[]; conversation_ids?: string[]; labels?: string[] },
37 ): { agentIds?: string[]; conversationIds?: string[]; labels?: string[] } | undefined => {
38 if (!f) return undefined;
39 return {
40 ...(f.agent_ids !== undefined ? { agentIds: f.agent_ids } : {}),
41 ...(f.conversation_ids !== undefined ? { conversationIds: f.conversation_ids } : {}),
42 ...(f.labels !== undefined ? { labels: f.labels } : {}),
43 };
44 };
45
46 server.registerTool(
47 "list_webhooks",
48 {
49 title: "List webhook subscribers",
50 annotations: { readOnlyHint: true },
51 description:
52 "Returns every webhook subscriber owned by the authenticated user, enabled + disabled, with their event subscriptions, filters, and last-delivered timestamp. signing_secret is omitted (it is only ever returned on create + rotate). Read-only; cheap.",
53 inputSchema: strictInputSchema({}),
54 },
55 async () => runTool(async () => ({ webhooks: await client.listWebhooks() })),
56 );
57
58 server.registerTool(
59 "get_webhook",
60 {
61 title: "Show one webhook subscriber",
62 annotations: { readOnlyHint: true },
63 description:
64 "Fetch a single webhook by id. signing_secret is omitted — use rotate_webhook_secret if the secret was lost.",
65 inputSchema: strictInputSchema({
66 id: z.string().min(1).describe("Webhook id (wh_…)."),
67 }),
68 },
69 async (args) => runTool(() => client.getWebhook(args.id)),
70 );
71
72 server.registerTool(
73 "create_webhook",
74 {
75 title: "Create a webhook subscriber (returns plaintext signing_secret ONCE)",
76 annotations: { destructiveHint: false },
77 description:

Callers 2

buildServerFunction · 0.85
tools.test.tsFile · 0.85

Calls 11

strictInputSchemaFunction · 0.85
runToolFunction · 0.85
mapFiltersFunction · 0.85
listWebhooksMethod · 0.45
getWebhookMethod · 0.45
createWebhookMethod · 0.45
updateWebhookMethod · 0.45
deleteWebhookMethod · 0.45
rotateWebhookSecretMethod · 0.45
testWebhookMethod · 0.45
listWebhookDeliveriesMethod · 0.45

Tested by

no test coverage detected