paygate-mcp 0.6.0 → 0.7.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 +84 -28
- package/dist/cli.d.ts +1 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +76 -39
- package/dist/cli.js.map +1 -1
- package/dist/gate.d.ts +12 -0
- package/dist/gate.d.ts.map +1 -1
- package/dist/gate.js +44 -11
- package/dist/gate.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +14 -3
- package/dist/proxy.js.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +61 -64
- package/dist/server.js.map +1 -1
- package/dist/store.d.ts +2 -34
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +5 -103
- package/dist/store.js.map +1 -1
- package/dist/types.d.ts +6 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -1
- package/dist/webhook.d.ts +21 -0
- package/dist/webhook.d.ts.map +1 -0
- package/dist/webhook.js +89 -0
- package/dist/webhook.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,6 +31,10 @@ Agent → PayGate (auth + billing) → Your MCP Server (stdio or HTTP)
|
|
|
31
31
|
- **Rate Limiting** — Sliding window per-key rate limits
|
|
32
32
|
- **Usage Metering** — Track who called what, when, and how much they spent
|
|
33
33
|
- **Two Transports** — Wrap local servers via stdio or remote servers via Streamable HTTP
|
|
34
|
+
- **Spending Limits** — Cap total spend per API key to prevent runaway costs
|
|
35
|
+
- **Refund on Failure** — Automatically refund credits when downstream tool calls fail
|
|
36
|
+
- **Webhook Events** — POST batched usage events to any URL for external billing/alerting
|
|
37
|
+
- **Config File Mode** — Load all settings from a JSON file (`--config`)
|
|
34
38
|
- **Shadow Mode** — Log everything without enforcing payment (for testing)
|
|
35
39
|
- **Persistent Storage** — Keys and credits survive restarts with `--state-file`
|
|
36
40
|
- **Zero Dependencies** — No external npm packages. Uses only Node.js built-ins.
|
|
@@ -123,28 +127,7 @@ curl http://localhost:3402/balance \
|
|
|
123
127
|
-H "X-API-Key: CLIENT_API_KEY"
|
|
124
128
|
```
|
|
125
129
|
|
|
126
|
-
Returns credits, total spent, call count, and last used timestamp.
|
|
127
|
-
|
|
128
|
-
### Set Spending Limits (Admin)
|
|
129
|
-
|
|
130
|
-
```bash
|
|
131
|
-
# Set daily and monthly credit caps for a key
|
|
132
|
-
curl -X POST http://localhost:3402/keys/limits \
|
|
133
|
-
-H "Content-Type: application/json" \
|
|
134
|
-
-H "X-Admin-Key: YOUR_ADMIN_KEY" \
|
|
135
|
-
-d '{"key": "CLIENT_API_KEY", "dailyLimit": 50, "monthlyLimit": 500}'
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
Prevents runaway AI agents from draining credits. When a key's daily or monthly spend reaches its cap, further tool calls are denied until the next day/month (UTC). Set to 0 for unlimited.
|
|
139
|
-
|
|
140
|
-
You can also set limits when creating a key:
|
|
141
|
-
|
|
142
|
-
```bash
|
|
143
|
-
curl -X POST http://localhost:3402/keys \
|
|
144
|
-
-H "Content-Type: application/json" \
|
|
145
|
-
-H "X-Admin-Key: YOUR_ADMIN_KEY" \
|
|
146
|
-
-d '{"name": "agent-key", "credits": 1000, "dailyLimit": 50, "monthlyLimit": 500}'
|
|
147
|
-
```
|
|
130
|
+
Returns credits, total spent, call count, and last used timestamp. Clients can check their own balance without needing admin access.
|
|
148
131
|
|
|
149
132
|
### Export Usage Data (Admin)
|
|
150
133
|
|
|
@@ -193,10 +176,10 @@ A real-time admin UI for managing keys, viewing usage, and monitoring tool calls
|
|
|
193
176
|
| `/keys` | GET | `X-Admin-Key` | List all keys (masked) |
|
|
194
177
|
| `/topup` | POST | `X-Admin-Key` | Add credits to an existing key |
|
|
195
178
|
| `/keys/revoke` | POST | `X-Admin-Key` | Revoke an API key |
|
|
196
|
-
| `/keys/limits` | POST | `X-Admin-Key` | Set daily/monthly spending limits |
|
|
197
179
|
| `/usage` | GET | `X-Admin-Key` | Export usage data (JSON or CSV) |
|
|
198
180
|
| `/status` | GET | `X-Admin-Key` | Full dashboard with usage stats |
|
|
199
181
|
| `/dashboard` | GET | None (admin key in-browser) | Real-time admin web dashboard |
|
|
182
|
+
| `/limits` | POST | `X-Admin-Key` | Set spending limit on a key |
|
|
200
183
|
| `/stripe/webhook` | POST | Stripe Signature | Auto-top-up credits on payment |
|
|
201
184
|
| `/` | GET | None | Health check |
|
|
202
185
|
|
|
@@ -220,8 +203,9 @@ These MCP methods pass through without auth or billing:
|
|
|
220
203
|
--import-key <k:c> Import existing key with credits (e.g. "pg_abc:100")
|
|
221
204
|
--state-file <path> Persist keys/credits to a JSON file (survives restarts)
|
|
222
205
|
--stripe-secret <s> Stripe webhook signing secret (enables /stripe/webhook)
|
|
223
|
-
--
|
|
224
|
-
--
|
|
206
|
+
--webhook-url <url> POST batched usage events to this URL
|
|
207
|
+
--refund-on-failure Refund credits when downstream tool call fails
|
|
208
|
+
--config <path> Load settings from a JSON config file
|
|
225
209
|
```
|
|
226
210
|
|
|
227
211
|
> **Note:** Use `--server` OR `--remote-url`, not both.
|
|
@@ -261,6 +245,74 @@ When a customer completes payment, credits are automatically added to their API
|
|
|
261
245
|
- Payment status verification (only `paid` triggers credits)
|
|
262
246
|
- Zero dependencies — uses Node.js built-in `crypto`
|
|
263
247
|
|
|
248
|
+
### Spending Limits
|
|
249
|
+
|
|
250
|
+
Cap the total credits any API key can spend:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
# Set a spending limit on a key (admin only)
|
|
254
|
+
curl -X POST http://localhost:3402/limits \
|
|
255
|
+
-H "Content-Type: application/json" \
|
|
256
|
+
-H "X-Admin-Key: YOUR_ADMIN_KEY" \
|
|
257
|
+
-d '{"key": "CLIENT_API_KEY", "spendingLimit": 500}'
|
|
258
|
+
|
|
259
|
+
# Check remaining budget
|
|
260
|
+
curl http://localhost:3402/balance -H "X-API-Key: CLIENT_API_KEY"
|
|
261
|
+
# → { "spendingLimit": 500, "remainingBudget": 350, ... }
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Set `spendingLimit` to `0` for unlimited. When a key hits its limit, tool calls are denied with a clear error.
|
|
265
|
+
|
|
266
|
+
### Refund on Failure
|
|
267
|
+
|
|
268
|
+
Automatically return credits when a downstream tool call fails:
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
npx paygate-mcp wrap --server "node server.js" --refund-on-failure
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Credits are deducted before the tool call. If the wrapped server returns an error, credits are refunded and `totalSpent` / `totalCalls` are rolled back. Prevents charging users for failed operations.
|
|
275
|
+
|
|
276
|
+
### Webhook Events
|
|
277
|
+
|
|
278
|
+
POST usage events to any external URL for billing, alerting, or analytics:
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
npx paygate-mcp wrap --server "node server.js" --webhook-url "https://billing.example.com/events"
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Events are batched (up to 10 per POST) and flushed every 5 seconds. Each event includes tool name, credits charged, API key, and timestamp. Fire-and-forget with one retry on failure.
|
|
285
|
+
|
|
286
|
+
### Config File Mode
|
|
287
|
+
|
|
288
|
+
Load all settings from a JSON file instead of CLI flags:
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
npx paygate-mcp wrap --config paygate.json
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Example `paygate.json`:
|
|
295
|
+
```json
|
|
296
|
+
{
|
|
297
|
+
"serverCommand": "npx",
|
|
298
|
+
"serverArgs": ["@modelcontextprotocol/server-filesystem", "/tmp"],
|
|
299
|
+
"port": 3402,
|
|
300
|
+
"defaultCreditsPerCall": 2,
|
|
301
|
+
"globalRateLimitPerMin": 30,
|
|
302
|
+
"webhookUrl": "https://billing.example.com/events",
|
|
303
|
+
"refundOnFailure": true,
|
|
304
|
+
"stateFile": "~/.paygate/state.json",
|
|
305
|
+
"toolPricing": {
|
|
306
|
+
"premium_analyze": { "creditsPerCall": 10 }
|
|
307
|
+
},
|
|
308
|
+
"importKeys": {
|
|
309
|
+
"pg_abc123def456": 500
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
CLI flags override config file values when both are specified.
|
|
315
|
+
|
|
264
316
|
## Programmatic API
|
|
265
317
|
|
|
266
318
|
```typescript
|
|
@@ -298,9 +350,10 @@ const { port, adminKey } = await server.start();
|
|
|
298
350
|
- API keys never forwarded to remote servers (HTTP transport)
|
|
299
351
|
- Rate limiting is per-key, concurrent-safe
|
|
300
352
|
- Stripe webhook signature verification (HMAC-SHA256, timing-safe)
|
|
301
|
-
- Per-key daily/monthly spending caps (budget protection)
|
|
302
353
|
- Dashboard uses safe DOM methods (textContent/createElement) — no innerHTML
|
|
303
|
-
-
|
|
354
|
+
- Webhook URLs masked in status output
|
|
355
|
+
- Spending limits enforced with integer arithmetic (no float bypass)
|
|
356
|
+
- Red-teamed with 84 adversarial security tests across 11 passes
|
|
304
357
|
|
|
305
358
|
## Current Limitations
|
|
306
359
|
|
|
@@ -315,7 +368,10 @@ const { port, adminKey } = await server.start();
|
|
|
315
368
|
- [x] Client self-service balance check (`/balance`)
|
|
316
369
|
- [x] Usage data export — JSON and CSV (`/usage`)
|
|
317
370
|
- [x] Admin web dashboard (`/dashboard`)
|
|
318
|
-
- [x] Per-key spending limits
|
|
371
|
+
- [x] Per-key spending limits (`/limits`)
|
|
372
|
+
- [x] Webhook events (`--webhook-url`)
|
|
373
|
+
- [x] Refund on failure (`--refund-on-failure`)
|
|
374
|
+
- [x] Config file mode (`--config`)
|
|
319
375
|
- [ ] Multi-tenant mode
|
|
320
376
|
|
|
321
377
|
## Requirements
|
package/dist/cli.d.ts
CHANGED
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
* Usage:
|
|
6
6
|
* npx paygate-mcp wrap --server "npx my-mcp-server" --port 3402
|
|
7
7
|
* npx paygate-mcp wrap --server "python server.py" --price 2 --rate-limit 30
|
|
8
|
-
* npx paygate-mcp
|
|
9
|
-
* npx paygate-mcp status
|
|
8
|
+
* npx paygate-mcp wrap --config paygate.json
|
|
10
9
|
*/
|
|
11
10
|
export {};
|
|
12
11
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG"}
|
package/dist/cli.js
CHANGED
|
@@ -6,11 +6,21 @@
|
|
|
6
6
|
* Usage:
|
|
7
7
|
* npx paygate-mcp wrap --server "npx my-mcp-server" --port 3402
|
|
8
8
|
* npx paygate-mcp wrap --server "python server.py" --price 2 --rate-limit 30
|
|
9
|
-
* npx paygate-mcp
|
|
10
|
-
* npx paygate-mcp status
|
|
9
|
+
* npx paygate-mcp wrap --config paygate.json
|
|
11
10
|
*/
|
|
12
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
12
|
const server_1 = require("./server");
|
|
13
|
+
const fs_1 = require("fs");
|
|
14
|
+
const path_1 = require("path");
|
|
15
|
+
const PKG_VERSION = (() => {
|
|
16
|
+
try {
|
|
17
|
+
const pkg = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '..', 'package.json'), 'utf-8'));
|
|
18
|
+
return pkg.version || '0.0.0';
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return '0.0.0';
|
|
22
|
+
}
|
|
23
|
+
})();
|
|
14
24
|
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
|
15
25
|
function parseArgs(argv) {
|
|
16
26
|
const command = argv[2] || 'help';
|
|
@@ -38,24 +48,26 @@ function printUsage() {
|
|
|
38
48
|
USAGE:
|
|
39
49
|
paygate-mcp wrap --server <command> [options] # stdio transport
|
|
40
50
|
paygate-mcp wrap --remote-url <url> [options] # Streamable HTTP transport
|
|
51
|
+
paygate-mcp wrap --config <path> [options] # load from config file
|
|
41
52
|
|
|
42
53
|
OPTIONS:
|
|
43
|
-
--server <cmd>
|
|
44
|
-
|
|
45
|
-
--remote-url <url>
|
|
46
|
-
|
|
47
|
-
--
|
|
48
|
-
--
|
|
49
|
-
--
|
|
50
|
-
--
|
|
51
|
-
--
|
|
52
|
-
--
|
|
53
|
-
--
|
|
54
|
-
--
|
|
55
|
-
--
|
|
56
|
-
--
|
|
57
|
-
--
|
|
58
|
-
--
|
|
54
|
+
--server <cmd> MCP server command to wrap via stdio (required unless --remote-url or --config)
|
|
55
|
+
e.g. "npx @modelcontextprotocol/server-filesystem /"
|
|
56
|
+
--remote-url <url> Remote MCP server URL (Streamable HTTP transport)
|
|
57
|
+
e.g. "https://my-mcp-server.example.com/mcp"
|
|
58
|
+
--config <path> Load all settings from a JSON file
|
|
59
|
+
--port <n> HTTP port (default: 3402)
|
|
60
|
+
--price <n> Default credits per tool call (default: 1)
|
|
61
|
+
--rate-limit <n> Max calls/min per key (default: 60, 0=unlimited)
|
|
62
|
+
--name <s> Server display name (default: "PayGate MCP Server")
|
|
63
|
+
--shadow Shadow mode — log but don't enforce payment
|
|
64
|
+
--admin-key <s> Set admin key (default: auto-generated)
|
|
65
|
+
--tool-price <t:n> Per-tool price override (e.g. "search:5,generate:10")
|
|
66
|
+
--import-key <k:c> Import an existing API key with credits (e.g. "pg_abc123:100")
|
|
67
|
+
--state-file <path> Persist keys/credits to a JSON file (survives restarts)
|
|
68
|
+
--stripe-secret <s> Stripe webhook signing secret (enables /stripe/webhook endpoint)
|
|
69
|
+
--webhook-url <url> POST usage events to this URL (batched)
|
|
70
|
+
--refund-on-failure Refund credits when downstream tool call fails
|
|
59
71
|
|
|
60
72
|
EXAMPLES:
|
|
61
73
|
# Wrap a local MCP server (stdio transport)
|
|
@@ -70,8 +82,8 @@ function printUsage() {
|
|
|
70
82
|
# Shadow mode (observe without enforcing)
|
|
71
83
|
paygate-mcp wrap --server "node server.js" --shadow
|
|
72
84
|
|
|
73
|
-
#
|
|
74
|
-
paygate-mcp wrap --
|
|
85
|
+
# Load config from file
|
|
86
|
+
paygate-mcp wrap --config paygate.json
|
|
75
87
|
`);
|
|
76
88
|
}
|
|
77
89
|
function parseToolPricing(input) {
|
|
@@ -90,10 +102,22 @@ async function main() {
|
|
|
90
102
|
const { command, flags } = parseArgs(process.argv);
|
|
91
103
|
switch (command) {
|
|
92
104
|
case 'wrap': {
|
|
93
|
-
|
|
94
|
-
|
|
105
|
+
// Load config file if specified
|
|
106
|
+
let fileConfig = {};
|
|
107
|
+
if (flags['config']) {
|
|
108
|
+
try {
|
|
109
|
+
const raw = (0, fs_1.readFileSync)(flags['config'], 'utf-8');
|
|
110
|
+
fileConfig = JSON.parse(raw);
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
console.error(`Error loading config file: ${err.message}`);
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const serverCmd = flags['server'] || (fileConfig.serverCommand ? [fileConfig.serverCommand, ...(fileConfig.serverArgs || [])].join(' ') : '');
|
|
118
|
+
const remoteUrl = flags['remote-url'] || fileConfig.remoteUrl;
|
|
95
119
|
if (!serverCmd && !remoteUrl) {
|
|
96
|
-
console.error('Error: --server
|
|
120
|
+
console.error('Error: --server, --remote-url, or --config is required.\n');
|
|
97
121
|
printUsage();
|
|
98
122
|
process.exit(1);
|
|
99
123
|
}
|
|
@@ -102,22 +126,24 @@ async function main() {
|
|
|
102
126
|
process.exit(1);
|
|
103
127
|
}
|
|
104
128
|
// Parse server command into command + args (stdio mode)
|
|
105
|
-
let serverCommand = '';
|
|
106
|
-
let serverArgs = [];
|
|
107
|
-
if (
|
|
108
|
-
const parts =
|
|
129
|
+
let serverCommand = fileConfig.serverCommand || '';
|
|
130
|
+
let serverArgs = fileConfig.serverArgs || [];
|
|
131
|
+
if (flags['server']) {
|
|
132
|
+
const parts = flags['server'].split(/\s+/);
|
|
109
133
|
serverCommand = parts[0];
|
|
110
134
|
serverArgs = parts.slice(1);
|
|
111
135
|
}
|
|
112
|
-
const port = parseInt(flags['port'] ||
|
|
113
|
-
const price = parseInt(flags['price'] ||
|
|
114
|
-
const rateLimit = parseInt(flags['rate-limit'] ||
|
|
115
|
-
const name = flags['name'] || 'PayGate MCP Server';
|
|
116
|
-
const shadowMode = flags['shadow'] === 'true' || flags['shadow'] === undefined
|
|
117
|
-
const adminKey = flags['admin-key'];
|
|
118
|
-
const toolPricing = flags['tool-price'] ? parseToolPricing(flags['tool-price']) : {};
|
|
119
|
-
const stateFile = flags['state-file'];
|
|
120
|
-
const stripeSecret = flags['stripe-secret'];
|
|
136
|
+
const port = parseInt(flags['port'] || String(fileConfig.port || 3402), 10);
|
|
137
|
+
const price = parseInt(flags['price'] || String(fileConfig.defaultCreditsPerCall || 1), 10);
|
|
138
|
+
const rateLimit = parseInt(flags['rate-limit'] || String(fileConfig.globalRateLimitPerMin || 60), 10);
|
|
139
|
+
const name = flags['name'] || fileConfig.serverCommand && 'PayGate MCP Server' || 'PayGate MCP Server';
|
|
140
|
+
const shadowMode = flags['shadow'] === 'true' || ('shadow' in flags && flags['shadow'] === undefined) || fileConfig.shadowMode || false;
|
|
141
|
+
const adminKey = flags['admin-key'] || fileConfig.adminKey;
|
|
142
|
+
const toolPricing = flags['tool-price'] ? parseToolPricing(flags['tool-price']) : (fileConfig.toolPricing || {});
|
|
143
|
+
const stateFile = flags['state-file'] || fileConfig.stateFile;
|
|
144
|
+
const stripeSecret = flags['stripe-secret'] || fileConfig.stripeWebhookSecret;
|
|
145
|
+
const webhookUrl = flags['webhook-url'] || fileConfig.webhookUrl || null;
|
|
146
|
+
const refundOnFailure = flags['refund-on-failure'] === 'true' || 'refund-on-failure' in flags || fileConfig.refundOnFailure || false;
|
|
121
147
|
const server = new server_1.PayGateServer({
|
|
122
148
|
serverCommand,
|
|
123
149
|
serverArgs,
|
|
@@ -127,8 +153,10 @@ async function main() {
|
|
|
127
153
|
name,
|
|
128
154
|
shadowMode: !!shadowMode,
|
|
129
155
|
toolPricing,
|
|
156
|
+
webhookUrl,
|
|
157
|
+
refundOnFailure: !!refundOnFailure,
|
|
130
158
|
}, adminKey, stateFile, remoteUrl, stripeSecret);
|
|
131
|
-
// Import keys
|
|
159
|
+
// Import keys from CLI flags
|
|
132
160
|
if (flags['import-key']) {
|
|
133
161
|
const pairs = flags['import-key'].split(',');
|
|
134
162
|
for (const pair of pairs) {
|
|
@@ -138,6 +166,12 @@ async function main() {
|
|
|
138
166
|
}
|
|
139
167
|
}
|
|
140
168
|
}
|
|
169
|
+
// Import keys from config file
|
|
170
|
+
if (fileConfig.importKeys) {
|
|
171
|
+
for (const [key, credits] of Object.entries(fileConfig.importKeys)) {
|
|
172
|
+
server.gate.store.importKey(key, 'imported', credits);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
141
175
|
// Handle graceful shutdown
|
|
142
176
|
const shutdown = async () => {
|
|
143
177
|
console.log('\nShutting down...');
|
|
@@ -155,13 +189,15 @@ async function main() {
|
|
|
155
189
|
║ ║
|
|
156
190
|
║ Endpoint: http://localhost:${String(result.port).padEnd(5)} ║
|
|
157
191
|
║ Admin Key: ${result.adminKey.slice(0, 20)}... ║
|
|
158
|
-
║ Backend: ${(remoteUrl ? 'HTTP → ' + remoteUrl.slice(0, 28) : 'stdio → ' + (serverCmd ||
|
|
192
|
+
║ Backend: ${(remoteUrl ? 'HTTP → ' + remoteUrl.slice(0, 28) : 'stdio → ' + (serverCmd || serverCommand).slice(0, 27)).padEnd(35)}║
|
|
159
193
|
║ ║
|
|
160
194
|
║ Pricing: ${String(price).padEnd(3)} credit(s) per tool call ║
|
|
161
195
|
║ Rate Limit: ${String(rateLimit).padEnd(3)} calls/min per key ║
|
|
162
196
|
║ Shadow: ${String(!!shadowMode).padEnd(5)} ║
|
|
163
197
|
║ Persist: ${(stateFile ? stateFile.slice(0, 33) : 'off (in-memory)').padEnd(35)}║
|
|
164
198
|
║ Stripe: ${(stripeSecret ? 'enabled (/stripe/webhook)' : 'off').padEnd(35)}║
|
|
199
|
+
║ Refund: ${String(!!refundOnFailure).padEnd(35)}║
|
|
200
|
+
║ Webhook: ${(webhookUrl ? webhookUrl.slice(0, 33) : 'off').padEnd(35)}║
|
|
165
201
|
║ ║
|
|
166
202
|
╠══════════════════════════════════════════════════╣
|
|
167
203
|
║ POST /mcp — JSON-RPC (X-API-Key header) ║
|
|
@@ -169,6 +205,7 @@ async function main() {
|
|
|
169
205
|
║ GET /balance — Client balance (X-API-Key) ║
|
|
170
206
|
║ POST /keys — Create key (X-Admin-Key) ║
|
|
171
207
|
║ POST /topup — Add credits (X-Admin-Key) ║
|
|
208
|
+
║ POST /limits — Set spending limit (Admin) ║
|
|
172
209
|
╚══════════════════════════════════════════════════╝
|
|
173
210
|
`);
|
|
174
211
|
console.log(` Admin key (save this): ${result.adminKey}\n`);
|
|
@@ -187,7 +224,7 @@ async function main() {
|
|
|
187
224
|
case 'version':
|
|
188
225
|
case '--version':
|
|
189
226
|
case '-v':
|
|
190
|
-
console.log(
|
|
227
|
+
console.log(`paygate-mcp v${PKG_VERSION}`);
|
|
191
228
|
break;
|
|
192
229
|
default:
|
|
193
230
|
console.error(`Unknown command: ${command}\n`);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AACA
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AACA;;;;;;;GAOG;;AAEH,qCAAyC;AAEzC,2BAAkC;AAClC,+BAA4B;AAE5B,MAAM,WAAW,GAAG,CAAC,GAAG,E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|
|
10
11
|
* Shadow mode: log but don't enforce (always ALLOW).
|
|
@@ -13,10 +14,12 @@ import { PayGateConfig, GateDecision, ToolCallParams } from './types';
|
|
|
13
14
|
import { KeyStore } from './store';
|
|
14
15
|
import { RateLimiter } from './rate-limiter';
|
|
15
16
|
import { UsageMeter } from './meter';
|
|
17
|
+
import { WebhookEmitter } from './webhook';
|
|
16
18
|
export declare class Gate {
|
|
17
19
|
readonly store: KeyStore;
|
|
18
20
|
readonly rateLimiter: RateLimiter;
|
|
19
21
|
readonly meter: UsageMeter;
|
|
22
|
+
readonly webhook: WebhookEmitter | null;
|
|
20
23
|
private readonly config;
|
|
21
24
|
constructor(config: PayGateConfig, statePath?: string);
|
|
22
25
|
/**
|
|
@@ -47,8 +50,17 @@ export declare class Gate {
|
|
|
47
50
|
defaultCreditsPerCall: number;
|
|
48
51
|
globalRateLimitPerMin: number;
|
|
49
52
|
toolPricing: Record<string, import("./types").ToolPricing>;
|
|
53
|
+
refundOnFailure: boolean;
|
|
54
|
+
webhookUrl: string | null;
|
|
50
55
|
};
|
|
51
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* Refund credits for a failed tool call.
|
|
59
|
+
* Only used when refundOnFailure is enabled.
|
|
60
|
+
*/
|
|
61
|
+
refund(apiKey: string, toolName: string, credits: number): void;
|
|
62
|
+
/** Whether refund-on-failure is enabled */
|
|
63
|
+
get refundOnFailure(): boolean;
|
|
52
64
|
destroy(): void;
|
|
53
65
|
private recordEvent;
|
|
54
66
|
}
|
package/dist/gate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../src/gate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../src/gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAc,cAAc,EAAE,MAAM,SAAS,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,qBAAa,IAAI;IACf,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;gBAE3B,MAAM,EAAE,aAAa,EAAE,SAAS,CAAC,EAAE,MAAM;IAQrD;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,cAAc,GAAG,YAAY;IAyEvE;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAIrC;;OAEG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAMtC;;OAEG;IACH,SAAS;;;;;;;;;;;;;;;;;IAkBT;;;OAGG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAW/D,2CAA2C;IAC3C,IAAI,eAAe,IAAI,OAAO,CAE7B;IAED,OAAO,IAAI,IAAI;IAKf,OAAO,CAAC,WAAW;CAgBpB"}
|
package/dist/gate.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* 1. API key validity
|
|
7
7
|
* 2. Credit balance
|
|
8
8
|
* 3. Rate limit
|
|
9
|
+
* 4. Spending limit
|
|
9
10
|
*
|
|
10
11
|
* Fail-closed: any check failure => DENY.
|
|
11
12
|
* Shadow mode: log but don't enforce (always ALLOW).
|
|
@@ -15,16 +16,19 @@ exports.Gate = void 0;
|
|
|
15
16
|
const store_1 = require("./store");
|
|
16
17
|
const rate_limiter_1 = require("./rate-limiter");
|
|
17
18
|
const meter_1 = require("./meter");
|
|
19
|
+
const webhook_1 = require("./webhook");
|
|
18
20
|
class Gate {
|
|
19
21
|
store;
|
|
20
22
|
rateLimiter;
|
|
21
23
|
meter;
|
|
24
|
+
webhook;
|
|
22
25
|
config;
|
|
23
26
|
constructor(config, statePath) {
|
|
24
27
|
this.config = config;
|
|
25
28
|
this.store = new store_1.KeyStore(statePath);
|
|
26
29
|
this.rateLimiter = new rate_limiter_1.RateLimiter(config.globalRateLimitPerMin);
|
|
27
30
|
this.meter = new meter_1.UsageMeter();
|
|
31
|
+
this.webhook = config.webhookUrl ? new webhook_1.WebhookEmitter(config.webhookUrl) : null;
|
|
28
32
|
}
|
|
29
33
|
/**
|
|
30
34
|
* Evaluate a tool call request.
|
|
@@ -71,18 +75,24 @@ class Gate {
|
|
|
71
75
|
remainingCredits: keyRecord.credits,
|
|
72
76
|
};
|
|
73
77
|
}
|
|
74
|
-
// Step 5: Spending
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
// Step 5: Spending limit?
|
|
79
|
+
if (keyRecord.spendingLimit > 0) {
|
|
80
|
+
const wouldSpend = keyRecord.totalSpent + creditsRequired;
|
|
81
|
+
if (wouldSpend > keyRecord.spendingLimit) {
|
|
82
|
+
this.recordEvent(apiKey, keyRecord.name, toolName, 0, false, 'spending_limit_exceeded');
|
|
83
|
+
if (this.config.shadowMode) {
|
|
84
|
+
return { allowed: true, reason: 'shadow:spending_limit_exceeded', creditsCharged: 0, remainingCredits: keyRecord.credits };
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
allowed: false,
|
|
88
|
+
reason: `spending_limit_exceeded: limit ${keyRecord.spendingLimit}, spent ${keyRecord.totalSpent}, need ${creditsRequired}`,
|
|
89
|
+
creditsCharged: 0,
|
|
90
|
+
remainingCredits: keyRecord.credits,
|
|
91
|
+
};
|
|
80
92
|
}
|
|
81
|
-
return { allowed: false, reason: spendCheck.reason, creditsCharged: 0, remainingCredits: keyRecord.credits };
|
|
82
93
|
}
|
|
83
|
-
// Step 6: ALLOW — deduct credits
|
|
94
|
+
// Step 6: ALLOW — deduct credits and record
|
|
84
95
|
this.store.deductCredits(apiKey, creditsRequired);
|
|
85
|
-
this.store.recordSpending(apiKey, creditsRequired);
|
|
86
96
|
this.rateLimiter.record(apiKey);
|
|
87
97
|
const remaining = this.store.getKey(apiKey)?.credits ?? 0;
|
|
88
98
|
this.recordEvent(apiKey, keyRecord.name, toolName, creditsRequired, true);
|
|
@@ -118,14 +128,35 @@ class Gate {
|
|
|
118
128
|
defaultCreditsPerCall: this.config.defaultCreditsPerCall,
|
|
119
129
|
globalRateLimitPerMin: this.config.globalRateLimitPerMin,
|
|
120
130
|
toolPricing: this.config.toolPricing,
|
|
131
|
+
refundOnFailure: this.config.refundOnFailure,
|
|
132
|
+
webhookUrl: this.config.webhookUrl ? '***' : null,
|
|
121
133
|
},
|
|
122
134
|
};
|
|
123
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Refund credits for a failed tool call.
|
|
138
|
+
* Only used when refundOnFailure is enabled.
|
|
139
|
+
*/
|
|
140
|
+
refund(apiKey, toolName, credits) {
|
|
141
|
+
this.store.addCredits(apiKey, credits);
|
|
142
|
+
const keyRecord = this.store.getKey(apiKey);
|
|
143
|
+
if (keyRecord) {
|
|
144
|
+
keyRecord.totalSpent = Math.max(0, keyRecord.totalSpent - credits);
|
|
145
|
+
keyRecord.totalCalls = Math.max(0, keyRecord.totalCalls - 1);
|
|
146
|
+
this.store.save();
|
|
147
|
+
}
|
|
148
|
+
this.recordEvent(apiKey, keyRecord?.name || 'unknown', toolName, -credits, true, 'refund');
|
|
149
|
+
}
|
|
150
|
+
/** Whether refund-on-failure is enabled */
|
|
151
|
+
get refundOnFailure() {
|
|
152
|
+
return this.config.refundOnFailure;
|
|
153
|
+
}
|
|
124
154
|
destroy() {
|
|
125
155
|
this.rateLimiter.destroy();
|
|
156
|
+
this.webhook?.destroy();
|
|
126
157
|
}
|
|
127
158
|
recordEvent(apiKey, keyName, tool, creditsCharged, allowed, denyReason) {
|
|
128
|
-
|
|
159
|
+
const event = {
|
|
129
160
|
timestamp: new Date().toISOString(),
|
|
130
161
|
apiKey: apiKey.slice(0, 10),
|
|
131
162
|
keyName,
|
|
@@ -133,7 +164,9 @@ class Gate {
|
|
|
133
164
|
creditsCharged,
|
|
134
165
|
allowed,
|
|
135
166
|
denyReason,
|
|
136
|
-
}
|
|
167
|
+
};
|
|
168
|
+
this.meter.record(event);
|
|
169
|
+
this.webhook?.emit(event);
|
|
137
170
|
}
|
|
138
171
|
}
|
|
139
172
|
exports.Gate = Gate;
|
package/dist/gate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gate.js","sourceRoot":"","sources":["../src/gate.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"gate.js","sourceRoot":"","sources":["../src/gate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAGH,mCAAmC;AACnC,iDAA6C;AAC7C,mCAAqC;AACrC,uCAA2C;AAE3C,MAAa,IAAI;IACN,KAAK,CAAW;IAChB,WAAW,CAAc;IACzB,KAAK,CAAa;IAClB,OAAO,CAAwB;IACvB,MAAM,CAAgB;IAEvC,YAAY,MAAqB,EAAE,SAAkB;QACnD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,IAAI,gBAAQ,CAAC,SAAS,CAAC,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,IAAI,0BAAW,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;QACjE,IAAI,CAAC,KAAK,GAAG,IAAI,kBAAU,EAAE,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,UAA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,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;CACF;AAzKD,oBAyKC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,8 @@ export { KeyStore } from './store';
|
|
|
22
22
|
export { UsageMeter } from './meter';
|
|
23
23
|
export { RateLimiter } from './rate-limiter';
|
|
24
24
|
export { StripeWebhookHandler } from './stripe';
|
|
25
|
+
export { WebhookEmitter } from './webhook';
|
|
25
26
|
export { getDashboardHtml } from './dashboard';
|
|
26
|
-
export type { PayGateConfig, JsonRpcRequest, JsonRpcResponse, JsonRpcError, ToolCallParams, ToolInfo, ToolPricing, ApiKeyRecord,
|
|
27
|
+
export type { PayGateConfig, JsonRpcRequest, JsonRpcResponse, JsonRpcError, ToolCallParams, ToolInfo, ToolPricing, ApiKeyRecord, UsageEvent, UsageSummary, GateDecision, } from './types';
|
|
27
28
|
export { DEFAULT_CONFIG } from './types';
|
|
28
29
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,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,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,YAAY,EACV,aAAa,EACb,cAAc,EACd,eAAe,EACf,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,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,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,YAAY,EACV,aAAa,EACb,cAAc,EACd,eAAe,EACf,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,YAAY,GACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.DEFAULT_CONFIG = exports.getDashboardHtml = exports.StripeWebhookHandler = exports.RateLimiter = exports.UsageMeter = exports.KeyStore = exports.HttpMcpProxy = exports.McpProxy = exports.Gate = exports.PayGateServer = void 0;
|
|
19
|
+
exports.DEFAULT_CONFIG = exports.getDashboardHtml = exports.WebhookEmitter = exports.StripeWebhookHandler = exports.RateLimiter = exports.UsageMeter = exports.KeyStore = exports.HttpMcpProxy = exports.McpProxy = exports.Gate = exports.PayGateServer = void 0;
|
|
20
20
|
var server_1 = require("./server");
|
|
21
21
|
Object.defineProperty(exports, "PayGateServer", { enumerable: true, get: function () { return server_1.PayGateServer; } });
|
|
22
22
|
var gate_1 = require("./gate");
|
|
@@ -33,6 +33,8 @@ var rate_limiter_1 = require("./rate-limiter");
|
|
|
33
33
|
Object.defineProperty(exports, "RateLimiter", { enumerable: true, get: function () { return rate_limiter_1.RateLimiter; } });
|
|
34
34
|
var stripe_1 = require("./stripe");
|
|
35
35
|
Object.defineProperty(exports, "StripeWebhookHandler", { enumerable: true, get: function () { return stripe_1.StripeWebhookHandler; } });
|
|
36
|
+
var webhook_1 = require("./webhook");
|
|
37
|
+
Object.defineProperty(exports, "WebhookEmitter", { enumerable: true, get: function () { return webhook_1.WebhookEmitter; } });
|
|
36
38
|
var dashboard_1 = require("./dashboard");
|
|
37
39
|
Object.defineProperty(exports, "getDashboardHtml", { enumerable: true, get: function () { return dashboard_1.getDashboardHtml; } });
|
|
38
40
|
var types_1 = require("./types");
|