MCPcopy
hub / github.com/benjitaylor/agentation / sendWebhooks

Function sendWebhooks

mcp/src/server/http.ts:136–168  ·  view source on GitHub ↗

* Send webhook notification for an action request. * Fire-and-forget: doesn't wait for response, logs errors but doesn't throw.

(actionRequest: ActionRequest)

Source from the content-addressed store, hash-verified

134 * Fire-and-forget: doesn't wait for response, logs errors but doesn't throw.
135 */
136function sendWebhooks(actionRequest: ActionRequest): void {
137 const webhookUrls = getWebhookUrls();
138
139 if (webhookUrls.length === 0) {
140 return;
141 }
142
143 const payload = JSON.stringify(actionRequest);
144
145 for (const url of webhookUrls) {
146 // Fire and forget - use .then().catch() instead of await
147 fetch(url, {
148 method: "POST",
149 headers: {
150 "Content-Type": "application/json",
151 "User-Agent": "Agentation-Webhook/1.0",
152 },
153 body: payload,
154 })
155 .then((res) => {
156 log(
157 `[Webhook] POST ${url} -> ${res.status} ${res.statusText}`
158 );
159 })
160 .catch((err) => {
161 console.error(`[Webhook] POST ${url} failed:`, (err as Error).message);
162 });
163 }
164
165 log(
166 `[Webhook] Fired ${webhookUrls.length} webhook(s) for session ${actionRequest.sessionId}`
167 );
168}
169
170// -----------------------------------------------------------------------------
171// Request Helpers

Callers 1

requestActionHandlerFunction · 0.85

Calls 2

getWebhookUrlsFunction · 0.85
logFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…