MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / normalizeAlertKey

Function normalizeAlertKey

server/src/middleware/slow-response.ts:28–32  ·  view source on GitHub ↗

Collapse UUIDs and numeric IDs so distinct paths share a cooldown key.

(method: string, path: string)

Source from the content-addressed store, hash-verified

26
27/** Collapse UUIDs and numeric IDs so distinct paths share a cooldown key. */
28function normalizeAlertKey(method: string, path: string): string {
29 return `${method}:${path
30 .replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, ":id")
31 .replace(/\/\d+\b/g, "/:n")}`;
32}
33
34function shouldAlert(key: string): boolean {
35 const now = Date.now();

Callers 1

slowResponseTrackerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected