paygate-mcp 4.7.0 → 4.8.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/README.md +37 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +46 -0
- package/dist/server.js.map +1 -1
- package/dist/webhook.d.ts +48 -0
- package/dist/webhook.d.ts.map +1 -1
- package/dist/webhook.js +132 -1
- package/dist/webhook.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -74,6 +74,7 @@ Agent → PayGate (auth + billing) → Your MCP Server (stdio or HTTP)
|
|
|
74
74
|
- **Key Suspension** — Temporarily disable API keys without revoking them — suspended keys are denied at the gate but can be resumed, and admin operations (topup, ACL, etc.) still work on suspended keys
|
|
75
75
|
- **Per-Key Usage** — `GET /keys/usage?key=...` returns detailed usage breakdown for a specific key: per-tool stats, hourly time-series, deny reasons, recent events, and key metadata
|
|
76
76
|
- **Webhook Test** — `POST /webhooks/test` sends a test event to your configured webhook URL with synchronous response including status code, response time, and delivery success/failure — verifies webhook connectivity without generating real events
|
|
77
|
+
- **Webhook Delivery Log** — `GET /webhooks/log` returns a queryable log of all webhook delivery attempts with timestamps, HTTP status codes, response times, success/failure, retry attempts, event counts, and event types — filter by success status, time range, and limit
|
|
77
78
|
- **Config Hot Reload** — `POST /config/reload` reloads pricing, rate limits, webhooks, quotas, and behavior flags from config file without server restart
|
|
78
79
|
- **Webhook Events** — POST batched usage events to any URL for external billing/alerting
|
|
79
80
|
- **Config File Mode** — Load all settings from a JSON file (`--config`)
|
|
@@ -352,6 +353,7 @@ A real-time admin UI for managing keys, viewing usage, and monitoring tool calls
|
|
|
352
353
|
| `/webhooks/filters/delete` | POST | `X-Admin-Key` | Delete a webhook filter rule |
|
|
353
354
|
| `/webhooks/replay` | POST | `X-Admin-Key` | Replay dead letter webhook events (all or by index) |
|
|
354
355
|
| `/webhooks/test` | POST | `X-Admin-Key` | Send test event to configured webhook URL (synchronous) |
|
|
356
|
+
| `/webhooks/log` | GET | `X-Admin-Key` | Webhook delivery log with status, timing, and filters |
|
|
355
357
|
| `/config/reload` | POST | `X-Admin-Key` | Hot-reload config file (pricing, rate limits, webhooks, quotas) |
|
|
356
358
|
| `/health` | GET | None | Health check (status, uptime, version, in-flight, Redis/webhook status) |
|
|
357
359
|
| `/` | GET | None | Root endpoint (endpoint list) |
|
|
@@ -1134,6 +1136,41 @@ Response:
|
|
|
1134
1136
|
|
|
1135
1137
|
The test event includes `X-PayGate-Test: 1` header and `X-PayGate-Signature` when a webhook secret is configured. Returns 400 if no webhook URL is configured. Creates an audit trail entry (`webhook.test`).
|
|
1136
1138
|
|
|
1139
|
+
### Webhook Delivery Log
|
|
1140
|
+
|
|
1141
|
+
Query the log of all webhook delivery attempts — successes, failures, and retries:
|
|
1142
|
+
|
|
1143
|
+
```bash
|
|
1144
|
+
# Get recent deliveries (default: last 50, newest first)
|
|
1145
|
+
curl http://localhost:3402/webhooks/log \
|
|
1146
|
+
-H "X-Admin-Key: YOUR_ADMIN_KEY"
|
|
1147
|
+
|
|
1148
|
+
# Filter by success/failure
|
|
1149
|
+
curl "http://localhost:3402/webhooks/log?success=false" \
|
|
1150
|
+
-H "X-Admin-Key: YOUR_ADMIN_KEY"
|
|
1151
|
+
|
|
1152
|
+
# Filter by time and limit
|
|
1153
|
+
curl "http://localhost:3402/webhooks/log?since=2025-01-01T00:00:00Z&limit=10" \
|
|
1154
|
+
-H "X-Admin-Key: YOUR_ADMIN_KEY"
|
|
1155
|
+
```
|
|
1156
|
+
|
|
1157
|
+
Each entry includes:
|
|
1158
|
+
|
|
1159
|
+
| Field | Description |
|
|
1160
|
+
|-------|-------------|
|
|
1161
|
+
| `id` | Auto-incrementing delivery ID |
|
|
1162
|
+
| `timestamp` | When the delivery attempt was made |
|
|
1163
|
+
| `url` | Webhook URL (credentials masked) |
|
|
1164
|
+
| `statusCode` | HTTP status code (0 for connection errors) |
|
|
1165
|
+
| `success` | `true` if webhook returned 2xx |
|
|
1166
|
+
| `responseTime` | Round-trip time in milliseconds |
|
|
1167
|
+
| `attempt` | Retry attempt number (0 = first attempt) |
|
|
1168
|
+
| `error` | Error message (only on failure) |
|
|
1169
|
+
| `eventCount` | Number of events in the batch |
|
|
1170
|
+
| `eventTypes` | Distinct event types (e.g. `["usage"]`, `["key.created"]`) |
|
|
1171
|
+
|
|
1172
|
+
Query parameters: `limit` (default 50, max 200), `since` (ISO 8601), `success` (`true` or `false`). Entries are capped at 500 in memory. Use alongside `/webhooks/stats` for aggregate counters.
|
|
1173
|
+
|
|
1137
1174
|
### IP Allowlisting
|
|
1138
1175
|
|
|
1139
1176
|
Restrict API keys to specific IP addresses or CIDR ranges:
|
package/dist/server.d.ts
CHANGED
|
@@ -176,6 +176,7 @@ export declare class PayGateServer {
|
|
|
176
176
|
private handleWebhookReplay;
|
|
177
177
|
private handleConfigReload;
|
|
178
178
|
private handleWebhookStats;
|
|
179
|
+
private handleWebhookLog;
|
|
179
180
|
private handleWebhookTest;
|
|
180
181
|
private handleListWebhookFilters;
|
|
181
182
|
private handleCreateWebhookFilter;
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,OAAO,EAAE,aAAa,EAAkB,mBAAmB,EAAkB,MAAM,SAAS,CAAC;AAU7F,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,cAAc,EAAqD,MAAM,WAAW,CAAC;AAC9F,OAAO,EAAE,WAAW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oB;IAsDlC;;;;OAIG;IACH;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,QAAQ;IAkBV,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB3B;;;;;;;OAOG;IACG,YAAY,CAAC,SAAS,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CA4CtD"}
|
package/dist/server.js
CHANGED
|
@@ -434,6 +434,8 @@ class PayGateServer {
|
|
|
434
434
|
return this.handleWebhookReplay(req, res);
|
|
435
435
|
case '/webhooks/stats':
|
|
436
436
|
return this.handleWebhookStats(req, res);
|
|
437
|
+
case '/webhooks/log':
|
|
438
|
+
return this.handleWebhookLog(req, res);
|
|
437
439
|
case '/webhooks/test':
|
|
438
440
|
return this.handleWebhookTest(req, res);
|
|
439
441
|
case '/webhooks/filters':
|
|
@@ -911,6 +913,7 @@ class PayGateServer {
|
|
|
911
913
|
webhookReplay: 'POST /webhooks/replay — Replay dead letter webhook events (requires X-Admin-Key)',
|
|
912
914
|
webhookTest: 'POST /webhooks/test — Send test event to webhook URL and return result (requires X-Admin-Key)',
|
|
913
915
|
webhookStats: 'GET /webhooks/stats — Webhook delivery statistics (requires X-Admin-Key)',
|
|
916
|
+
webhookLog: 'GET /webhooks/log — Webhook delivery log with status, timing, and filters (requires X-Admin-Key)',
|
|
914
917
|
webhookFilters: 'GET|POST /webhooks/filters — List or create webhook filter rules (requires X-Admin-Key)',
|
|
915
918
|
updateWebhookFilter: 'POST /webhooks/filters/update — Update a webhook filter rule (requires X-Admin-Key)',
|
|
916
919
|
deleteWebhookFilter: 'POST /webhooks/filters/delete — Delete a webhook filter rule (requires X-Admin-Key)',
|
|
@@ -2937,6 +2940,49 @@ class PayGateServer {
|
|
|
2937
2940
|
...(routerStats ? { filters: routerStats } : {}),
|
|
2938
2941
|
}));
|
|
2939
2942
|
}
|
|
2943
|
+
// ─── /webhooks/log — Webhook delivery log ───────────────────────────────
|
|
2944
|
+
handleWebhookLog(req, res) {
|
|
2945
|
+
if (req.method !== 'GET') {
|
|
2946
|
+
res.writeHead(405, { 'Content-Type': 'application/json' });
|
|
2947
|
+
res.end(JSON.stringify({ error: 'Method not allowed' }));
|
|
2948
|
+
return;
|
|
2949
|
+
}
|
|
2950
|
+
if (!this.checkAdmin(req, res))
|
|
2951
|
+
return;
|
|
2952
|
+
if (!this.gate.webhook) {
|
|
2953
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
2954
|
+
res.end(JSON.stringify({
|
|
2955
|
+
configured: false,
|
|
2956
|
+
message: 'No webhook configured',
|
|
2957
|
+
entries: [],
|
|
2958
|
+
}));
|
|
2959
|
+
return;
|
|
2960
|
+
}
|
|
2961
|
+
// Parse query params
|
|
2962
|
+
const url = new URL(req.url || '/', `http://${req.headers.host || 'localhost'}`);
|
|
2963
|
+
const limitParam = url.searchParams.get('limit');
|
|
2964
|
+
const sinceParam = url.searchParams.get('since');
|
|
2965
|
+
const successParam = url.searchParams.get('success');
|
|
2966
|
+
const options = {};
|
|
2967
|
+
if (limitParam) {
|
|
2968
|
+
const n = parseInt(limitParam, 10);
|
|
2969
|
+
if (!isNaN(n) && n > 0)
|
|
2970
|
+
options.limit = n;
|
|
2971
|
+
}
|
|
2972
|
+
if (sinceParam)
|
|
2973
|
+
options.since = sinceParam;
|
|
2974
|
+
if (successParam === 'true')
|
|
2975
|
+
options.success = true;
|
|
2976
|
+
else if (successParam === 'false')
|
|
2977
|
+
options.success = false;
|
|
2978
|
+
const entries = this.gate.webhook.getDeliveryLog(options);
|
|
2979
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
2980
|
+
res.end(JSON.stringify({
|
|
2981
|
+
configured: true,
|
|
2982
|
+
total: entries.length,
|
|
2983
|
+
entries,
|
|
2984
|
+
}));
|
|
2985
|
+
}
|
|
2940
2986
|
// ─── /webhooks/test — Send test event ────────────────────────────────────
|
|
2941
2987
|
async handleWebhookTest(req, res) {
|
|
2942
2988
|
if (req.method !== 'POST') {
|