@arispay/payagent-mcp 2.6.4 → 2.7.1
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/dist/index.js +350 -207
- package/dist/index.js.map +1 -1
- package/package.json +11 -4
package/dist/index.js
CHANGED
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
5
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
|
-
import { z } from "zod";
|
|
7
6
|
import {
|
|
7
|
+
BootstrapError,
|
|
8
8
|
DelegationClient,
|
|
9
9
|
HostedTopupNotConfiguredError,
|
|
10
10
|
bootstrapAgent,
|
|
11
|
-
BootstrapError,
|
|
12
11
|
formatUSDC,
|
|
13
12
|
getAgent,
|
|
14
13
|
getApiKey,
|
|
@@ -16,8 +15,11 @@ import {
|
|
|
16
15
|
getUSDCBalance,
|
|
17
16
|
launchAgent,
|
|
18
17
|
listAgents,
|
|
19
|
-
payFetchDelegated
|
|
18
|
+
payFetchDelegated,
|
|
19
|
+
renameStoredAgent,
|
|
20
|
+
syncAgents
|
|
20
21
|
} from "payagent";
|
|
22
|
+
import { z } from "zod";
|
|
21
23
|
|
|
22
24
|
// src/pay-api-helpers.ts
|
|
23
25
|
function looksLikeInsufficientFunds(message) {
|
|
@@ -27,6 +29,11 @@ function looksLikeInsufficientFunds(message) {
|
|
|
27
29
|
);
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
// src/profile.ts
|
|
33
|
+
function platformToolsEnabled(raw = process.env.PAYAGENT_MCP_PROFILE) {
|
|
34
|
+
return (raw ?? "all").trim().toLowerCase() !== "core";
|
|
35
|
+
}
|
|
36
|
+
|
|
30
37
|
// src/index.ts
|
|
31
38
|
var arispayUrl = getArispayUrl(process.env.ARISPAY_URL);
|
|
32
39
|
var legacyAgentKey = process.env.ARISPAY_AGENT_KEY;
|
|
@@ -68,12 +75,15 @@ var server = new McpServer({
|
|
|
68
75
|
});
|
|
69
76
|
server.tool(
|
|
70
77
|
"pay_api",
|
|
78
|
+
"Make an HTTP request to a paid API, transparently paying any x402 (HTTP 402) challenge with USDC under the agent's spend limits. THE tool for fetching paid resources \u2014 never bypass a 402 or hand-roll payment.",
|
|
71
79
|
{
|
|
72
80
|
url: z.string().describe("The full URL of the API endpoint to call"),
|
|
73
81
|
method: z.enum(["GET", "POST", "PUT", "DELETE", "PATCH"]).default("GET").describe("HTTP method"),
|
|
74
82
|
headers: z.record(z.string(), z.string()).optional().describe("Additional HTTP headers"),
|
|
75
83
|
body: z.string().optional().describe("Request body (for POST/PUT/PATCH)"),
|
|
76
|
-
agent: z.string().optional().describe(
|
|
84
|
+
agent: z.string().optional().describe(
|
|
85
|
+
"Optional: name of a locally-stored agent to pay with. Defaults to ARISPAY_AGENT_KEY or the first stored agent."
|
|
86
|
+
)
|
|
77
87
|
},
|
|
78
88
|
async ({ url, method, headers, body, agent }) => {
|
|
79
89
|
const resolved = resolveAgentKey(agent);
|
|
@@ -92,12 +102,18 @@ server.tool(
|
|
|
92
102
|
);
|
|
93
103
|
}
|
|
94
104
|
try {
|
|
95
|
-
|
|
105
|
+
let paymentInfo;
|
|
106
|
+
const fetch402 = payFetchDelegated({
|
|
107
|
+
arispayUrl,
|
|
108
|
+
apiKey: resolved.key,
|
|
109
|
+
onPayment: (info) => {
|
|
110
|
+
paymentInfo = info;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
96
113
|
const response = await fetch402(url, { method, headers, body });
|
|
97
114
|
const responseBody = await response.text();
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
);
|
|
115
|
+
const statusLine = paymentInfo ? `HTTP ${response.status} (paid ${paymentInfo.amountCents}\xA2 via ${resolved.source} \u2014 budget left: ${paymentInfo.remainingDaily}\xA2 today, ${paymentInfo.remainingMonthly}\xA2 this month)` : `HTTP ${response.status} (paid via ${resolved.source})`;
|
|
116
|
+
return textResult([statusLine, "", responseBody].join("\n"));
|
|
101
117
|
} catch (err) {
|
|
102
118
|
const message = err instanceof Error ? err.message : String(err);
|
|
103
119
|
if (looksLikeInsufficientFunds(message)) {
|
|
@@ -139,8 +155,11 @@ async function tryGetOnrampHint(agentName) {
|
|
|
139
155
|
}
|
|
140
156
|
server.tool(
|
|
141
157
|
"check_wallet",
|
|
158
|
+
`Show the current agent's credentials, wallet address, and on-chain USDC balance \u2014 the quick "what state am I in" probe.`,
|
|
142
159
|
{
|
|
143
|
-
agent: z.string().optional().describe(
|
|
160
|
+
agent: z.string().optional().describe(
|
|
161
|
+
"Optional: name of a locally-stored agent. Defaults to legacy ARISPAY_WALLET mode."
|
|
162
|
+
)
|
|
144
163
|
},
|
|
145
164
|
async ({ agent }) => {
|
|
146
165
|
const resolved = resolveAgent(agent);
|
|
@@ -155,7 +174,9 @@ server.tool(
|
|
|
155
174
|
const raw = await getUSDCBalance(walletAddress, resolved?.network ?? "base");
|
|
156
175
|
lines.push(`Balance: ${formatUSDC(raw)} USDC on ${resolved?.network ?? "base"}`);
|
|
157
176
|
} catch (err) {
|
|
158
|
-
lines.push(
|
|
177
|
+
lines.push(
|
|
178
|
+
`Balance: unavailable (${err instanceof Error ? err.message : String(err)})`
|
|
179
|
+
);
|
|
159
180
|
}
|
|
160
181
|
} else {
|
|
161
182
|
lines.push("", "No wallet known. Use `create_agent` or set PAYAGENT_WALLET for legacy mode.");
|
|
@@ -166,6 +187,7 @@ server.tool(
|
|
|
166
187
|
);
|
|
167
188
|
server.tool(
|
|
168
189
|
"create_agent",
|
|
190
|
+
"Provision an additional x402 payment agent (wallet + spend limits) under the already-paired developer account.",
|
|
169
191
|
{
|
|
170
192
|
name: z.string().describe("Local identifier for this agent. Used by later tools."),
|
|
171
193
|
perTx: z.number().int().positive().describe("Per-transaction spend cap in cents."),
|
|
@@ -196,12 +218,16 @@ server.tool(
|
|
|
196
218
|
];
|
|
197
219
|
return textResult(lines.join("\n"));
|
|
198
220
|
} catch (err) {
|
|
199
|
-
return textResult(
|
|
221
|
+
return textResult(
|
|
222
|
+
`create_agent failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
223
|
+
true
|
|
224
|
+
);
|
|
200
225
|
}
|
|
201
226
|
}
|
|
202
227
|
);
|
|
203
228
|
server.tool(
|
|
204
229
|
"fund_agent",
|
|
230
|
+
"Get funding instructions for an agent's wallet \u2014 the USDC deposit address, or a hosted Coinbase Onramp URL with `hosted: true`.",
|
|
205
231
|
{
|
|
206
232
|
name: z.string().describe("Name of a locally-stored agent."),
|
|
207
233
|
hosted: z.boolean().optional().describe(
|
|
@@ -215,10 +241,7 @@ server.tool(
|
|
|
215
241
|
if (hosted) {
|
|
216
242
|
const devKey = getApiKey();
|
|
217
243
|
if (!devKey) {
|
|
218
|
-
return textResult(
|
|
219
|
-
"No ArisPay developer key found. Run `npx payagent init` first.",
|
|
220
|
-
true
|
|
221
|
-
);
|
|
244
|
+
return textResult("No ArisPay developer key found. Run `npx payagent init` first.", true);
|
|
222
245
|
}
|
|
223
246
|
const client = new DelegationClient(arispayUrl, devKey);
|
|
224
247
|
try {
|
|
@@ -267,6 +290,7 @@ server.tool(
|
|
|
267
290
|
);
|
|
268
291
|
server.tool(
|
|
269
292
|
"get_balance",
|
|
293
|
+
"Server-side USDC balance + funding status for one named agent.",
|
|
270
294
|
{
|
|
271
295
|
name: z.string().describe("Name of a locally-stored agent.")
|
|
272
296
|
},
|
|
@@ -284,200 +308,228 @@ server.tool(
|
|
|
284
308
|
` Wallet: ${balance.walletAddress}`
|
|
285
309
|
];
|
|
286
310
|
return textResult(lines.join("\n"));
|
|
287
|
-
} catch (err) {
|
|
288
|
-
return textResult(`get_balance failed: ${err instanceof Error ? err.message : String(err)}`, true);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
);
|
|
292
|
-
server.tool(
|
|
293
|
-
"create_enduser",
|
|
294
|
-
{
|
|
295
|
-
externalId: z.string().describe("Your own stable id for this customer (e.g. `tg:12345`)."),
|
|
296
|
-
email: z.string().optional().describe("Optional email for compliance / receipts."),
|
|
297
|
-
findOrCreate: z.boolean().optional().describe("If true, return the existing user instead of erroring on externalId collision.")
|
|
298
|
-
},
|
|
299
|
-
async ({ externalId, email, findOrCreate }) => {
|
|
300
|
-
try {
|
|
301
|
-
const devKey = requireDevKey();
|
|
302
|
-
const client = new DelegationClient(arispayUrl, devKey);
|
|
303
|
-
const user = await client.createEndUser({ externalId, email, findOrCreate });
|
|
304
|
-
const lines = [
|
|
305
|
-
`\u2713 End-user \`${externalId}\` ready.`,
|
|
306
|
-
` ArisPay id: ${user.id}`,
|
|
307
|
-
` Has card: ${user.hasPaymentMethod ? "yes" : "no"}`,
|
|
308
|
-
` Has wallet: ${user.hasWallet ? "yes" : "no"}`
|
|
309
|
-
];
|
|
310
|
-
return textResult(lines.join("\n"));
|
|
311
311
|
} catch (err) {
|
|
312
312
|
return textResult(
|
|
313
|
-
`
|
|
313
|
+
`get_balance failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
314
314
|
true
|
|
315
315
|
);
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
);
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
);
|
|
319
|
+
if (platformToolsEnabled()) {
|
|
320
|
+
server.tool(
|
|
321
|
+
"create_enduser",
|
|
322
|
+
"Platform mode: register an end-customer (EndUser) under your account, keyed by your own externalId.",
|
|
323
|
+
{
|
|
324
|
+
externalId: z.string().describe("Your own stable id for this customer (e.g. `tg:12345`)."),
|
|
325
|
+
email: z.string().optional().describe("Optional email for compliance / receipts."),
|
|
326
|
+
findOrCreate: z.boolean().optional().describe("If true, return the existing user instead of erroring on externalId collision.")
|
|
327
|
+
},
|
|
328
|
+
async ({ externalId, email, findOrCreate }) => {
|
|
329
|
+
try {
|
|
330
|
+
const devKey = requireDevKey();
|
|
331
|
+
const client = new DelegationClient(arispayUrl, devKey);
|
|
332
|
+
const user = await client.createEndUser({ externalId, email, findOrCreate });
|
|
333
|
+
const lines = [
|
|
334
|
+
`\u2713 End-user \`${externalId}\` ready.`,
|
|
335
|
+
` ArisPay id: ${user.id}`,
|
|
336
|
+
` Has card: ${user.hasPaymentMethod ? "yes" : "no"}`,
|
|
337
|
+
` Has wallet: ${user.hasWallet ? "yes" : "no"}`
|
|
338
|
+
];
|
|
339
|
+
return textResult(lines.join("\n"));
|
|
340
|
+
} catch (err) {
|
|
341
|
+
return textResult(
|
|
342
|
+
`create_enduser failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
343
|
+
true
|
|
344
|
+
);
|
|
345
|
+
}
|
|
347
346
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
347
|
+
);
|
|
348
|
+
server.tool(
|
|
349
|
+
"attach_card_for_user",
|
|
350
|
+
"Platform mode: mint a hosted card-entry URL for an end-user (ArisPay handles tokenization + 3DS).",
|
|
351
|
+
{
|
|
352
|
+
userId: z.string().describe("The ArisPay-internal end-user id (not externalId)."),
|
|
353
|
+
agentName: z.string().optional().describe("Optional locally-stored agent name to scope the card-setup session to.")
|
|
354
|
+
},
|
|
355
|
+
async ({ userId, agentName }) => {
|
|
356
|
+
try {
|
|
357
|
+
const devKey = requireDevKey();
|
|
358
|
+
const client = new DelegationClient(arispayUrl, devKey);
|
|
359
|
+
const agentId = agentName ? getAgent(agentName)?.agentId : void 0;
|
|
360
|
+
const session = await client.createCardSetupSession({ endUserId: userId, agentId });
|
|
361
|
+
const lines = [
|
|
362
|
+
`Card-entry URL for user \`${userId}\`:`,
|
|
363
|
+
"",
|
|
364
|
+
` ${session.setupUrl}`,
|
|
365
|
+
"",
|
|
366
|
+
` Expires at: ${session.expiresAt}`,
|
|
367
|
+
"",
|
|
368
|
+
"Share this URL with the end-user. They enter the card on ArisPay's hosted page; we handle tokenization + 3DS.",
|
|
369
|
+
"Call `get_user_status` afterwards to confirm the card is attached."
|
|
370
|
+
];
|
|
371
|
+
return textResult(lines.join("\n"));
|
|
372
|
+
} catch (err) {
|
|
373
|
+
return textResult(
|
|
374
|
+
`attach_card_for_user failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
375
|
+
true
|
|
376
|
+
);
|
|
366
377
|
}
|
|
367
|
-
const devKey = requireDevKey();
|
|
368
|
-
const client = new DelegationClient(arispayUrl, devKey);
|
|
369
|
-
const limit = await client.setUserLimits(userId, {
|
|
370
|
-
agentId: stored.agentId,
|
|
371
|
-
maxPerTransaction: perTx ?? null,
|
|
372
|
-
maxDaily: daily ?? null,
|
|
373
|
-
maxMonthly: monthly ?? null,
|
|
374
|
-
allowedMerchantCategories: allowedMcc,
|
|
375
|
-
blockedMerchantCategories: blockedMcc
|
|
376
|
-
});
|
|
377
|
-
return textResult(
|
|
378
|
-
[
|
|
379
|
-
`\u2713 Limits set for \`${userId}\` on agent \`${agentName}\`.`,
|
|
380
|
-
` per-tx ${limit.maxPerTransaction ?? "inherit"}\xA2, daily ${limit.maxDaily ?? "inherit"}\xA2, monthly ${limit.maxMonthly ?? "inherit"}\xA2`
|
|
381
|
-
].join("\n")
|
|
382
|
-
);
|
|
383
|
-
} catch (err) {
|
|
384
|
-
return textResult(
|
|
385
|
-
`set_user_limits failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
386
|
-
true
|
|
387
|
-
);
|
|
388
378
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
if (user.hasWallet) {
|
|
408
|
-
try {
|
|
409
|
-
const w = await client.getWalletStatus(userId);
|
|
410
|
-
lines.push(` balance: ${w.usdcBalance} USDC base units`);
|
|
411
|
-
lines.push(` allowance: ${w.usdcAllowance} (${w.allowanceSufficient ? "ok" : "insufficient"})`);
|
|
412
|
-
lines.push(` ready: ${w.ready}`);
|
|
413
|
-
} catch {
|
|
379
|
+
);
|
|
380
|
+
server.tool(
|
|
381
|
+
"set_user_limits",
|
|
382
|
+
"Platform mode: set per-(user, agent) spend caps in integer cents plus MCC allow/block rules.",
|
|
383
|
+
{
|
|
384
|
+
userId: z.string().describe("ArisPay-internal end-user id."),
|
|
385
|
+
agentName: z.string().describe("Locally-stored agent name."),
|
|
386
|
+
perTx: z.number().int().optional().describe("Per-transaction cap in cents. Omit to inherit agent defaults."),
|
|
387
|
+
daily: z.number().int().optional().describe("Daily cap in cents."),
|
|
388
|
+
monthly: z.number().int().optional().describe("Monthly cap in cents."),
|
|
389
|
+
allowedMcc: z.array(z.string()).optional().describe("Allowed Merchant Category Codes."),
|
|
390
|
+
blockedMcc: z.array(z.string()).optional().describe("Blocked MCCs.")
|
|
391
|
+
},
|
|
392
|
+
async ({ userId, agentName, perTx, daily, monthly, allowedMcc, blockedMcc }) => {
|
|
393
|
+
try {
|
|
394
|
+
const stored = getAgent(agentName);
|
|
395
|
+
if (!stored) {
|
|
396
|
+
return textResult(`No locally-stored agent named \`${agentName}\`.`, true);
|
|
414
397
|
}
|
|
398
|
+
const devKey = requireDevKey();
|
|
399
|
+
const client = new DelegationClient(arispayUrl, devKey);
|
|
400
|
+
const limit = await client.setUserLimits(userId, {
|
|
401
|
+
agentId: stored.agentId,
|
|
402
|
+
maxPerTransaction: perTx ?? null,
|
|
403
|
+
maxDaily: daily ?? null,
|
|
404
|
+
maxMonthly: monthly ?? null,
|
|
405
|
+
allowedMerchantCategories: allowedMcc,
|
|
406
|
+
blockedMerchantCategories: blockedMcc
|
|
407
|
+
});
|
|
408
|
+
return textResult(
|
|
409
|
+
[
|
|
410
|
+
`\u2713 Limits set for \`${userId}\` on agent \`${agentName}\`.`,
|
|
411
|
+
` per-tx ${limit.maxPerTransaction ?? "inherit"}\xA2, daily ${limit.maxDaily ?? "inherit"}\xA2, monthly ${limit.maxMonthly ?? "inherit"}\xA2`
|
|
412
|
+
].join("\n")
|
|
413
|
+
);
|
|
414
|
+
} catch (err) {
|
|
415
|
+
return textResult(
|
|
416
|
+
`set_user_limits failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
417
|
+
true
|
|
418
|
+
);
|
|
415
419
|
}
|
|
416
|
-
return textResult(lines.join("\n"));
|
|
417
|
-
} catch (err) {
|
|
418
|
-
return textResult(
|
|
419
|
-
`get_user_status failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
420
|
-
true
|
|
421
|
-
);
|
|
422
420
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
userId,
|
|
452
|
-
rail
|
|
453
|
-
});
|
|
454
|
-
const lines = [
|
|
455
|
-
`Payment ${payment.id}: ${payment.status}`,
|
|
456
|
-
` rail: ${payment.rail}`,
|
|
457
|
-
` amount: ${payment.amount}\xA2 ${payment.currency}`
|
|
458
|
-
];
|
|
459
|
-
if (payment.merchantName) lines.push(` merchant: ${payment.merchantName}`);
|
|
460
|
-
if (payment.txHash) lines.push(` tx hash: ${payment.txHash}`);
|
|
461
|
-
if (payment.nextAction) {
|
|
462
|
-
lines.push(` next action: ${payment.nextAction.type}`);
|
|
463
|
-
if (payment.nextAction.challengeUrl) {
|
|
464
|
-
lines.push(` 3DS challenge URL: ${payment.nextAction.challengeUrl}`);
|
|
421
|
+
);
|
|
422
|
+
server.tool(
|
|
423
|
+
"get_user_status",
|
|
424
|
+
"Platform mode: report an end-user's card, wallet, and payment readiness.",
|
|
425
|
+
{
|
|
426
|
+
userId: z.string().describe("ArisPay-internal end-user id.")
|
|
427
|
+
},
|
|
428
|
+
async ({ userId }) => {
|
|
429
|
+
try {
|
|
430
|
+
const devKey = requireDevKey();
|
|
431
|
+
const client = new DelegationClient(arispayUrl, devKey);
|
|
432
|
+
const user = await client.getEndUser(userId);
|
|
433
|
+
const lines = [
|
|
434
|
+
`${user.externalId} (${user.id})`,
|
|
435
|
+
` email: ${user.email ?? "\u2014"}`,
|
|
436
|
+
` card: ${user.hasPaymentMethod ? `${user.cardBrand ?? "card"} \u2026${user.cardLast4 ?? "????"}` : "\u2014"}`,
|
|
437
|
+
` wallet: ${user.walletAddress ?? "\u2014"}${user.walletChain ? ` on ${user.walletChain}` : ""}`
|
|
438
|
+
];
|
|
439
|
+
if (user.hasWallet) {
|
|
440
|
+
try {
|
|
441
|
+
const w = await client.getWalletStatus(userId);
|
|
442
|
+
lines.push(` balance: ${w.usdcBalance} USDC base units`);
|
|
443
|
+
lines.push(
|
|
444
|
+
` allowance: ${w.usdcAllowance} (${w.allowanceSufficient ? "ok" : "insufficient"})`
|
|
445
|
+
);
|
|
446
|
+
lines.push(` ready: ${w.ready}`);
|
|
447
|
+
} catch {
|
|
448
|
+
}
|
|
465
449
|
}
|
|
450
|
+
return textResult(lines.join("\n"));
|
|
451
|
+
} catch (err) {
|
|
452
|
+
return textResult(
|
|
453
|
+
`get_user_status failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
454
|
+
true
|
|
455
|
+
);
|
|
466
456
|
}
|
|
467
|
-
|
|
468
|
-
|
|
457
|
+
}
|
|
458
|
+
);
|
|
459
|
+
server.tool(
|
|
460
|
+
"pay_merchant",
|
|
461
|
+
"Direct payment to a known merchant via ArisPay rails (card / crypto / balance / MPP) when you already know the amount. For x402-protected HTTP resources use `pay_api` instead.",
|
|
462
|
+
{
|
|
463
|
+
agentName: z.string().describe("Name of the locally-stored agent making the payment."),
|
|
464
|
+
merchantUrl: z.string().describe("Canonical merchant URL (stored on the payment record)."),
|
|
465
|
+
amount: z.number().int().positive().describe("Amount in cents."),
|
|
466
|
+
memo: z.string().describe("Human-readable memo attached to the payment."),
|
|
467
|
+
userId: z.string().optional().describe("Optional ArisPay end-user id. Required when the agent is in platform mode."),
|
|
468
|
+
rail: z.enum(["card", "crypto", "balance", "mpp"]).optional().describe("Force a specific rail. Default: server-picked based on agent mode + userId."),
|
|
469
|
+
merchantName: z.string().optional().describe("Optional human-readable merchant name."),
|
|
470
|
+
merchantCategoryCode: z.string().optional().describe("MCC for spend-limit enforcement.")
|
|
471
|
+
},
|
|
472
|
+
async ({
|
|
473
|
+
agentName,
|
|
474
|
+
merchantUrl,
|
|
475
|
+
amount,
|
|
476
|
+
memo,
|
|
477
|
+
userId,
|
|
478
|
+
rail,
|
|
479
|
+
merchantName,
|
|
480
|
+
merchantCategoryCode
|
|
481
|
+
}) => {
|
|
482
|
+
try {
|
|
483
|
+
const stored = getAgent(agentName);
|
|
484
|
+
if (!stored) {
|
|
485
|
+
return textResult(`No locally-stored agent named \`${agentName}\`.`, true);
|
|
486
|
+
}
|
|
487
|
+
const devKey = requireDevKey();
|
|
488
|
+
const client = new DelegationClient(arispayUrl, devKey);
|
|
489
|
+
const payment = await client.createPayment(stored.agentId, {
|
|
490
|
+
amount,
|
|
491
|
+
memo,
|
|
492
|
+
merchantUrl,
|
|
493
|
+
merchantName,
|
|
494
|
+
merchantCategoryCode,
|
|
495
|
+
userId,
|
|
496
|
+
rail
|
|
497
|
+
});
|
|
498
|
+
const lines = [
|
|
499
|
+
`Payment ${payment.id}: ${payment.status}`,
|
|
500
|
+
` rail: ${payment.rail}`,
|
|
501
|
+
` amount: ${payment.amount}\xA2 ${payment.currency}`
|
|
502
|
+
];
|
|
503
|
+
if (payment.merchantName) lines.push(` merchant: ${payment.merchantName}`);
|
|
504
|
+
if (payment.txHash) lines.push(` tx hash: ${payment.txHash}`);
|
|
505
|
+
if (payment.spend) {
|
|
506
|
+
const fmtCap = (v) => v == null ? "no cap" : `${v}\xA2`;
|
|
507
|
+
lines.push(
|
|
508
|
+
` budget: ${fmtCap(payment.spend.remainingDaily)} left today, ${fmtCap(payment.spend.remainingMonthly)} this month`
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
if (payment.nextAction) {
|
|
512
|
+
lines.push(` next action: ${payment.nextAction.type}`);
|
|
513
|
+
if (payment.nextAction.challengeUrl) {
|
|
514
|
+
lines.push(` 3DS challenge URL: ${payment.nextAction.challengeUrl}`);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
if (payment.error) {
|
|
518
|
+
lines.push(` error: ${payment.error.code} \u2014 ${payment.error.message}`);
|
|
519
|
+
}
|
|
520
|
+
return textResult(lines.join("\n"), payment.status === "failed");
|
|
521
|
+
} catch (err) {
|
|
522
|
+
return textResult(
|
|
523
|
+
`pay_merchant failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
524
|
+
true
|
|
525
|
+
);
|
|
469
526
|
}
|
|
470
|
-
return textResult(lines.join("\n"), payment.status === "failed");
|
|
471
|
-
} catch (err) {
|
|
472
|
-
return textResult(
|
|
473
|
-
`pay_merchant failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
474
|
-
true
|
|
475
|
-
);
|
|
476
527
|
}
|
|
477
|
-
|
|
478
|
-
|
|
528
|
+
);
|
|
529
|
+
}
|
|
479
530
|
server.tool(
|
|
480
531
|
"bootstrap_agent",
|
|
532
|
+
"Cold-start in one call: create (or recover) an ArisPay account plus a payment agent from just an email. Run this first on a fresh machine; safe to re-run \u2014 it recovers the existing agent and wallet set instead of creating duplicates.",
|
|
481
533
|
{
|
|
482
534
|
email: z.string().describe("Email for the new ArisPay developer account."),
|
|
483
535
|
name: z.string().optional().describe("Human name. Falls back to the email local-part."),
|
|
@@ -518,11 +570,19 @@ server.tool(
|
|
|
518
570
|
if (result.fundingUrlError) {
|
|
519
571
|
lines.push(`Onramp not available (${result.fundingUrlError}).`);
|
|
520
572
|
}
|
|
521
|
-
lines.push(
|
|
573
|
+
lines.push(
|
|
574
|
+
`Fund the wallet by sending USDC on ${result.network} to ${result.walletAddress}.`
|
|
575
|
+
);
|
|
522
576
|
lines.push(
|
|
523
577
|
`Or call \`fund_agent\` with name="${result.agentName}", hosted=true to mint a Coinbase Onramp URL on demand.`
|
|
524
578
|
);
|
|
525
579
|
}
|
|
580
|
+
if (result.pairing) {
|
|
581
|
+
lines.push("");
|
|
582
|
+
lines.push("\u{1F4F1} Open BuyForMe on your phone (signs you into the same account):");
|
|
583
|
+
lines.push(` ${result.pairing.url}`);
|
|
584
|
+
lines.push(` Link expires: ${result.pairing.expiresAt}`);
|
|
585
|
+
}
|
|
526
586
|
return textResult(lines.join("\n"));
|
|
527
587
|
} catch (err) {
|
|
528
588
|
if (err instanceof BootstrapError) {
|
|
@@ -537,23 +597,106 @@ server.tool(
|
|
|
537
597
|
);
|
|
538
598
|
server.tool(
|
|
539
599
|
"list_agents",
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
600
|
+
"List all wallets under this account (server-authoritative; rehydrates the local cache).",
|
|
601
|
+
{
|
|
602
|
+
withBalance: z.boolean().optional().describe(
|
|
603
|
+
"When true, fetch on-chain USDC balance per agent (adds one round-trip per wallet)."
|
|
604
|
+
)
|
|
605
|
+
},
|
|
606
|
+
async ({ withBalance }) => {
|
|
607
|
+
const devKey = getApiKey();
|
|
608
|
+
if (!devKey) {
|
|
609
|
+
const local = listAgents();
|
|
610
|
+
if (!local.length) {
|
|
611
|
+
return textResult(
|
|
612
|
+
"No developer key set and no agents cached locally. Run `bootstrap_agent` or set ARISPAY_API_KEY."
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
const lines = local.map(
|
|
616
|
+
(a) => [
|
|
617
|
+
a.name,
|
|
618
|
+
` agent id: ${a.agentId}`,
|
|
619
|
+
` wallet: ${a.walletAddress}`,
|
|
620
|
+
` network: ${a.network ?? "base"}`,
|
|
621
|
+
` limits: ${a.limits.perTx}\xA2 / tx, ${a.limits.daily}\xA2 / day, ${a.limits.monthly}\xA2 / month`,
|
|
622
|
+
` created: ${a.createdAt}`,
|
|
623
|
+
" (local cache only \u2014 set ARISPAY_API_KEY to sync from the server)"
|
|
624
|
+
].join("\n")
|
|
625
|
+
);
|
|
626
|
+
return textResult(lines.join("\n\n"));
|
|
627
|
+
}
|
|
628
|
+
try {
|
|
629
|
+
const result = await syncAgents({ includeBalance: withBalance === true });
|
|
630
|
+
if (!result.agents.length) {
|
|
631
|
+
return textResult(
|
|
632
|
+
"No wallets found under this developer key. Create one with `create_agent` or `bootstrap_agent`."
|
|
633
|
+
);
|
|
634
|
+
}
|
|
635
|
+
const lines = result.agents.map((a) => {
|
|
636
|
+
const balanceLine = a.usdcBalance !== void 0 ? ` balance: ${formatUSDC(BigInt(a.usdcBalance || "0"))} USDC` : null;
|
|
637
|
+
const fundedLine = a.fundedAt ? ` funded: ${a.fundedAt}` : " funded: not yet";
|
|
638
|
+
const domainsLine = a.allowedDomains.length ? ` domains: ${a.allowedDomains.join(", ")}` : " domains: (unrestricted)";
|
|
639
|
+
const suspendedLine = a.suspended ? " status: SUSPENDED" : null;
|
|
640
|
+
return [
|
|
641
|
+
a.name,
|
|
642
|
+
` agent id: ${a.agentId}`,
|
|
643
|
+
` wallet: ${a.walletAddress}`,
|
|
644
|
+
` network: ${a.network}`,
|
|
645
|
+
` limits: ${a.limits.maxPerTx}\xA2 / tx, ${a.limits.maxDaily}\xA2 / day, ${a.limits.maxMonthly}\xA2 / month`,
|
|
646
|
+
domainsLine,
|
|
647
|
+
fundedLine,
|
|
648
|
+
...balanceLine ? [balanceLine] : [],
|
|
649
|
+
...suspendedLine ? [suspendedLine] : [],
|
|
650
|
+
` created: ${a.createdAt}`
|
|
651
|
+
].join("\n");
|
|
652
|
+
});
|
|
653
|
+
return textResult(
|
|
654
|
+
`${result.agents.length} wallet${result.agents.length === 1 ? "" : "s"} under this account (synced from server):
|
|
655
|
+
|
|
656
|
+
${lines.join("\n\n")}`
|
|
657
|
+
);
|
|
658
|
+
} catch (err) {
|
|
659
|
+
return textResult(
|
|
660
|
+
`list_agents failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
661
|
+
true
|
|
662
|
+
);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
);
|
|
666
|
+
server.tool(
|
|
667
|
+
"rename_agent",
|
|
668
|
+
"Rename an agent on the server and in the local cache (names are unique per account).",
|
|
669
|
+
{
|
|
670
|
+
name: z.string().describe("Current local name of the agent to rename."),
|
|
671
|
+
newName: z.string().describe(
|
|
672
|
+
"New name. Letters, numbers, spaces, hyphens, underscores, dots. 1-64 chars. Must be unique per account."
|
|
673
|
+
)
|
|
674
|
+
},
|
|
675
|
+
async ({ name, newName }) => {
|
|
676
|
+
if (name === newName) {
|
|
677
|
+
return textResult(`Agent \`${name}\` already has that name \u2014 nothing to do.`);
|
|
678
|
+
}
|
|
679
|
+
const stored = getAgent(name);
|
|
680
|
+
if (!stored) {
|
|
681
|
+
return textResult(
|
|
682
|
+
`No locally-cached agent named \`${name}\`. Run \`list_agents\` first to sync, or check the spelling.`,
|
|
683
|
+
true
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
try {
|
|
687
|
+
const devKey = requireDevKey();
|
|
688
|
+
const client = new DelegationClient(arispayUrl, devKey);
|
|
689
|
+
const result = await client.renameAgent(stored.agentId, newName);
|
|
690
|
+
renameStoredAgent(name, result.name);
|
|
691
|
+
return textResult(
|
|
692
|
+
`\u2713 Renamed \`${name}\` \u2192 \`${result.name}\`. Wallet ${result.walletAddress ?? stored.walletAddress} is unchanged.`
|
|
693
|
+
);
|
|
694
|
+
} catch (err) {
|
|
695
|
+
return textResult(
|
|
696
|
+
`rename_agent failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
697
|
+
true
|
|
698
|
+
);
|
|
545
699
|
}
|
|
546
|
-
const lines = agents.map(
|
|
547
|
-
(a) => [
|
|
548
|
-
a.name,
|
|
549
|
-
` agent id: ${a.agentId}`,
|
|
550
|
-
` wallet: ${a.walletAddress}`,
|
|
551
|
-
` network: ${a.network ?? "base"}`,
|
|
552
|
-
` limits: ${a.limits.perTx}\xA2 / tx, ${a.limits.daily}\xA2 / day, ${a.limits.monthly}\xA2 / month`,
|
|
553
|
-
` created: ${a.createdAt}`
|
|
554
|
-
].join("\n")
|
|
555
|
-
);
|
|
556
|
-
return textResult(lines.join("\n\n"));
|
|
557
700
|
}
|
|
558
701
|
);
|
|
559
702
|
async function main() {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/pay-api-helpers.ts"],"sourcesContent":["/**\n * payagent-mcp — MCP server for agent-side x402 payments + headless launch.\n *\n * Six tools over stdio:\n * - pay_api(url, ...) — paid HTTP request via delegated signing\n * - check_wallet() — report current agent credentials + on-chain balance\n * - create_agent(...) — provision a new x402 agent (calls /v1/agents/x402)\n * - fund_agent({ name }) — return the wallet address + instructions for deposit\n * - get_balance({ name }) — on-server USDC balance + fundedAt latch\n * - list_agents() — enumerate locally-cached agents\n *\n * Config store lives at ~/.payagent/config.json (shared with the `payagent`\n * CLI). Credentials created via `npx payagent init` + `payagent agent create`\n * are immediately available here; equally, agents created via\n * `create_agent` are immediately visible to the CLI.\n *\n * Two auth modes, picked at request time:\n * 1. Legacy single-agent: ARISPAY_AGENT_KEY set → pay_api + check_wallet use it directly.\n * 2. Multi-agent: no env var, credentials come from the shared config store.\n * Management tools (create / fund / get_balance / list) always use the\n * developer key from the config store (or ARISPAY_API_KEY env).\n */\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { z } from 'zod';\nimport {\n DelegationClient,\n HostedTopupNotConfiguredError,\n bootstrapAgent,\n BootstrapError,\n formatUSDC,\n getAgent,\n getApiKey,\n getArispayUrl,\n getUSDCBalance,\n launchAgent,\n listAgents,\n payFetchDelegated,\n type StoredAgent,\n} from 'payagent';\nimport { looksLikeInsufficientFunds } from './pay-api-helpers.js';\n\n// ── Configuration ─────────────────────────────────────\n\nconst arispayUrl = getArispayUrl(process.env.ARISPAY_URL);\n/** Legacy single-agent key (kept for backwards compatibility). */\nconst legacyAgentKey = process.env.ARISPAY_AGENT_KEY;\nconst legacyWalletAddress = process.env.PAYAGENT_WALLET;\n\nfunction resolveAgent(name?: string): StoredAgent | undefined {\n if (name) return getAgent(name);\n const agents = listAgents();\n return agents[0];\n}\n\n/**\n * Look up the agent-scoped key to use for paid requests.\n * Priority: explicit agent name → legacy env var → first stored agent.\n */\nfunction resolveAgentKey(name?: string): { key: string; source: string } | undefined {\n if (name) {\n const stored = getAgent(name);\n if (stored) return { key: stored.apiKey, source: `agent \\`${name}\\`` };\n return undefined;\n }\n if (legacyAgentKey) return { key: legacyAgentKey, source: 'ARISPAY_AGENT_KEY' };\n const first = listAgents()[0];\n if (first) return { key: first.apiKey, source: `agent \\`${first.name}\\`` };\n return undefined;\n}\n\nfunction requireDevKey(): string {\n const key = getApiKey();\n if (!key) {\n throw new Error(\n 'No ArisPay developer key found. Run `npx payagent init` or set ARISPAY_API_KEY.',\n );\n }\n return key;\n}\n\nfunction textResult(text: string, isError = false) {\n return {\n content: [{ type: 'text' as const, text }],\n ...(isError ? { isError } : {}),\n };\n}\n\n// ── MCP Server ────────────────────────────────────────\n\nconst server = new McpServer({\n name: 'payagent',\n version: '2.1.0',\n});\n\n// --- pay_api ----------------------------------------------------------------\n\nserver.tool(\n 'pay_api',\n {\n url: z.string().describe('The full URL of the API endpoint to call'),\n method: z\n .enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH'])\n .default('GET')\n .describe('HTTP method'),\n headers: z.record(z.string(), z.string()).optional().describe('Additional HTTP headers'),\n body: z.string().optional().describe('Request body (for POST/PUT/PATCH)'),\n agent: z\n .string()\n .optional()\n .describe('Optional: name of a locally-stored agent to pay with. Defaults to ARISPAY_AGENT_KEY or the first stored agent.'),\n },\n async ({ url, method, headers, body, agent }) => {\n const resolved = resolveAgentKey(agent);\n if (!resolved) {\n return textResult(\n [\n 'No agent available. Cold-start in one call:',\n ' bootstrap_agent({ email: \"you@example.com\", name: \"<your-name>\" })',\n '',\n 'Or, if a developer key is already paired (`npx payagent init`):',\n ' create_agent({ name, perTx, daily, monthly })',\n '',\n 'Or set ARISPAY_AGENT_KEY for legacy single-agent mode.',\n ].join('\\n'),\n true,\n );\n }\n try {\n const fetch402 = payFetchDelegated({ arispayUrl, apiKey: resolved.key });\n const response = await fetch402(url, { method, headers, body });\n const responseBody = await response.text();\n return textResult(\n [`HTTP ${response.status} (paid via ${resolved.source})`, '', responseBody].join('\\n'),\n );\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n // Detect \"agent wallet has no USDC\" — surface a Coinbase Onramp URL\n // inline so Claude / the host doesn't have to make a second tool\n // call to figure out the recovery path. We're conservative about\n // the trigger: only do this on a 402-after-signed-payment with a\n // funds-shaped error in the seller response. Other failures\n // (allowed-domain block, agent suspended, network) propagate as-is.\n if (looksLikeInsufficientFunds(message)) {\n const onrampHint = await tryGetOnrampHint(agent);\n return textResult(\n [\n `Error: ${message}`,\n '',\n 'This looks like the agent wallet is out of USDC. Fund it and retry:',\n ...(onrampHint ?? [\n ' Use the `fund_agent` tool with hosted=true to mint a Coinbase Onramp URL,',\n ' or send USDC on Base directly to the wallet address from `check_wallet`.',\n ]),\n ].join('\\n'),\n true,\n );\n }\n return textResult(`Error: ${message}`, true);\n }\n },\n);\n\n/**\n * Best-effort: mint an Onramp URL for the named agent (or the first one\n * in the local store). Returns the lines to append to the error message,\n * or `undefined` if we can't get one (no dev key, no Onramp configured,\n * no agent name resolvable).\n */\nasync function tryGetOnrampHint(agentName?: string): Promise<string[] | undefined> {\n const stored = resolveAgent(agentName);\n if (!stored) return undefined;\n const devKey = getApiKey();\n if (!devKey) return undefined;\n try {\n const client = new DelegationClient(arispayUrl, devKey);\n const link = await client.getHostedTopup(stored.agentId, {});\n return [\n ` Coinbase Onramp: ${link.fundingUrl}`,\n ` URL valid until: ${link.expiresAt}`,\n ` Or send USDC on ${link.network} directly to ${link.walletAddress}`,\n ];\n } catch (err) {\n if (err instanceof HostedTopupNotConfiguredError) return undefined;\n return undefined;\n }\n}\n\n// --- check_wallet ----------------------------------------------------------\n\nserver.tool(\n 'check_wallet',\n {\n agent: z\n .string()\n .optional()\n .describe('Optional: name of a locally-stored agent. Defaults to legacy ARISPAY_WALLET mode.'),\n },\n async ({ agent }) => {\n const resolved = resolveAgent(agent);\n const walletAddress = resolved?.walletAddress ?? legacyWalletAddress;\n const keyTail = resolved?.apiKey.slice(-4) ?? (legacyAgentKey ? legacyAgentKey.slice(-4) : undefined);\n\n const lines = [`ArisPay URL: ${arispayUrl}`];\n if (resolved) lines.push(`Agent: ${resolved.name} (${resolved.agentId})`);\n if (keyTail) lines.push(`Agent key: ap_…${keyTail}`);\n\n if (walletAddress) {\n lines.push(`Wallet: ${walletAddress}`);\n try {\n const raw = await getUSDCBalance(walletAddress, (resolved?.network as 'base') ?? 'base');\n lines.push(`Balance: ${formatUSDC(raw)} USDC on ${resolved?.network ?? 'base'}`);\n } catch (err) {\n lines.push(`Balance: unavailable (${err instanceof Error ? err.message : String(err)})`);\n }\n } else {\n lines.push('', 'No wallet known. Use `create_agent` or set PAYAGENT_WALLET for legacy mode.');\n }\n\n lines.push('', 'Manage limits + full history: https://arispay.app/dashboard');\n return textResult(lines.join('\\n'));\n },\n);\n\n// --- create_agent ----------------------------------------------------------\n\nserver.tool(\n 'create_agent',\n {\n name: z.string().describe('Local identifier for this agent. Used by later tools.'),\n perTx: z.number().int().positive().describe('Per-transaction spend cap in cents.'),\n daily: z.number().int().positive().describe('Daily spend cap in cents.'),\n monthly: z.number().int().positive().describe('Monthly spend cap in cents.'),\n allowedDomains: z\n .array(z.string())\n .optional()\n .describe('If provided, restrict this agent to paying only these domains.'),\n network: z\n .enum(['base', 'base-sepolia', 'ethereum', 'polygon'])\n .default('base')\n .describe('EVM network the agent pays on.'),\n agentType: z.string().optional().describe('Optional metadata label (e.g. \"hermes\").'),\n },\n async ({ name, perTx, daily, monthly, allowedDomains, network, agentType }) => {\n try {\n requireDevKey(); // fail fast with a helpful message if not signed in\n const agent = await launchAgent({\n name,\n limits: { perTx, daily, monthly },\n allowedDomains,\n network,\n agentType,\n });\n const lines = [\n `✓ Agent \\`${name}\\` created.`,\n ` Agent ID: ${agent.agentId}`,\n ` Wallet: ${agent.walletAddress}`,\n ` Network: ${agent.network}`,\n ` Limits: ${perTx}¢ / tx, ${daily}¢ / day, ${monthly}¢ / month`,\n '',\n ` Fund the wallet with USDC on ${agent.network}, then call \\`get_balance\\` with name=\"${name}\".`,\n ];\n return textResult(lines.join('\\n'));\n } catch (err) {\n return textResult(`create_agent failed: ${err instanceof Error ? err.message : String(err)}`, true);\n }\n },\n);\n\n// --- fund_agent ------------------------------------------------------------\n\nserver.tool(\n 'fund_agent',\n {\n name: z.string().describe('Name of a locally-stored agent.'),\n hosted: z\n .boolean()\n .optional()\n .describe(\n 'If true, request a provider-hosted onramp URL (Coinbase, etc.) instead of the plain wallet address. Requires ARISPAY_ONRAMP_PROVIDER on the API deployment.',\n ),\n amount: z\n .number()\n .optional()\n .describe('Preset top-up amount in dollars. Only meaningful with `hosted: true`.'),\n },\n async ({ name, hosted, amount }) => {\n const stored = getAgent(name);\n if (!stored) return textResult(`No locally-stored agent named \\`${name}\\`.`, true);\n\n if (hosted) {\n const devKey = getApiKey();\n if (!devKey) {\n return textResult(\n 'No ArisPay developer key found. Run `npx payagent init` first.',\n true,\n );\n }\n const client = new DelegationClient(arispayUrl, devKey);\n try {\n const link = await client.getHostedTopup(stored.agentId, { amount });\n const lines = [\n `Top up \\`${name}\\` via ${link.provider}:`,\n '',\n ` ${link.fundingUrl}`,\n '',\n ` Wallet: ${link.walletAddress}`,\n ` Network: ${link.network}`,\n ` URL valid until: ${link.expiresAt}`,\n '',\n 'Share that URL with the end-user; the onramp deposits USDC straight to the agent\\'s wallet.',\n ];\n return textResult(lines.join('\\n'));\n } catch (err) {\n if (err instanceof HostedTopupNotConfiguredError) {\n return textResult(\n [\n 'Hosted onramp is not configured on this ArisPay deployment.',\n 'Falling back to the manual path:',\n '',\n ` Send USDC on ${stored.network ?? 'base'} to ${stored.walletAddress}`,\n '',\n 'Ask the deployment owner to set ARISPAY_ONRAMP_PROVIDER=coinbase (+ COINBASE_ONRAMP_APP_ID) to enable hosted top-ups.',\n ].join('\\n'),\n );\n }\n return textResult(\n `fund_agent (hosted) failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n }\n\n const lines = [\n `Fund \\`${name}\\` by sending USDC on ${stored.network ?? 'base'} to:`,\n '',\n ` ${stored.walletAddress}`,\n '',\n 'Pass `hosted: true` to get a Coinbase onramp URL instead (requires ARISPAY_ONRAMP_PROVIDER).',\n 'Call `get_balance` when the deposit lands.',\n ];\n return textResult(lines.join('\\n'));\n },\n);\n\n// --- get_balance -----------------------------------------------------------\n\nserver.tool(\n 'get_balance',\n {\n name: z.string().describe('Name of a locally-stored agent.'),\n },\n async ({ name }) => {\n const stored = getAgent(name);\n if (!stored) return textResult(`No locally-stored agent named \\`${name}\\`.`, true);\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const balance = await client.getBalance(stored.agentId);\n const human = formatUSDC(BigInt(balance.usdcBalance || '0'));\n const lines = [\n `${name}: ${human} USDC on ${balance.network}`,\n balance.fundedAt\n ? ` First funded at: ${balance.fundedAt}`\n : ' Not yet funded.',\n ` Wallet: ${balance.walletAddress}`,\n ];\n return textResult(lines.join('\\n'));\n } catch (err) {\n return textResult(`get_balance failed: ${err instanceof Error ? err.message : String(err)}`, true);\n }\n },\n);\n\n// --- create_enduser --------------------------------------------------------\n\nserver.tool(\n 'create_enduser',\n {\n externalId: z.string().describe('Your own stable id for this customer (e.g. `tg:12345`).'),\n email: z.string().optional().describe('Optional email for compliance / receipts.'),\n findOrCreate: z\n .boolean()\n .optional()\n .describe('If true, return the existing user instead of erroring on externalId collision.'),\n },\n async ({ externalId, email, findOrCreate }) => {\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const user = await client.createEndUser({ externalId, email, findOrCreate });\n const lines = [\n `✓ End-user \\`${externalId}\\` ready.`,\n ` ArisPay id: ${user.id}`,\n ` Has card: ${user.hasPaymentMethod ? 'yes' : 'no'}`,\n ` Has wallet: ${user.hasWallet ? 'yes' : 'no'}`,\n ];\n return textResult(lines.join('\\n'));\n } catch (err) {\n return textResult(\n `create_enduser failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- attach_card_for_user -------------------------------------------------\n\nserver.tool(\n 'attach_card_for_user',\n {\n userId: z.string().describe('The ArisPay-internal end-user id (not externalId).'),\n agentName: z\n .string()\n .optional()\n .describe('Optional locally-stored agent name to scope the card-setup session to.'),\n },\n async ({ userId, agentName }) => {\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const agentId = agentName ? getAgent(agentName)?.agentId : undefined;\n const session = await client.createCardSetupSession({ endUserId: userId, agentId });\n const lines = [\n `Card-entry URL for user \\`${userId}\\`:`,\n '',\n ` ${session.setupUrl}`,\n '',\n ` Expires at: ${session.expiresAt}`,\n '',\n 'Share this URL with the end-user. They enter the card on ArisPay\\'s hosted page; we handle tokenization + 3DS.',\n 'Call `get_user_status` afterwards to confirm the card is attached.',\n ];\n return textResult(lines.join('\\n'));\n } catch (err) {\n return textResult(\n `attach_card_for_user failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- set_user_limits -------------------------------------------------------\n\nserver.tool(\n 'set_user_limits',\n {\n userId: z.string().describe('ArisPay-internal end-user id.'),\n agentName: z.string().describe('Locally-stored agent name.'),\n perTx: z.number().int().optional().describe('Per-transaction cap in cents. Omit to inherit agent defaults.'),\n daily: z.number().int().optional().describe('Daily cap in cents.'),\n monthly: z.number().int().optional().describe('Monthly cap in cents.'),\n allowedMcc: z.array(z.string()).optional().describe('Allowed Merchant Category Codes.'),\n blockedMcc: z.array(z.string()).optional().describe('Blocked MCCs.'),\n },\n async ({ userId, agentName, perTx, daily, monthly, allowedMcc, blockedMcc }) => {\n try {\n const stored = getAgent(agentName);\n if (!stored) {\n return textResult(`No locally-stored agent named \\`${agentName}\\`.`, true);\n }\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const limit = await client.setUserLimits(userId, {\n agentId: stored.agentId,\n maxPerTransaction: perTx ?? null,\n maxDaily: daily ?? null,\n maxMonthly: monthly ?? null,\n allowedMerchantCategories: allowedMcc,\n blockedMerchantCategories: blockedMcc,\n });\n return textResult(\n [\n `✓ Limits set for \\`${userId}\\` on agent \\`${agentName}\\`.`,\n ` per-tx ${limit.maxPerTransaction ?? 'inherit'}¢, daily ${limit.maxDaily ?? 'inherit'}¢, monthly ${limit.maxMonthly ?? 'inherit'}¢`,\n ].join('\\n'),\n );\n } catch (err) {\n return textResult(\n `set_user_limits failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- get_user_status -------------------------------------------------------\n\nserver.tool(\n 'get_user_status',\n {\n userId: z.string().describe('ArisPay-internal end-user id.'),\n },\n async ({ userId }) => {\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const user = await client.getEndUser(userId);\n const lines = [\n `${user.externalId} (${user.id})`,\n ` email: ${user.email ?? '—'}`,\n ` card: ${user.hasPaymentMethod ? `${user.cardBrand ?? 'card'} …${user.cardLast4 ?? '????'}` : '—'}`,\n ` wallet: ${user.walletAddress ?? '—'}${user.walletChain ? ` on ${user.walletChain}` : ''}`,\n ];\n if (user.hasWallet) {\n try {\n const w = await client.getWalletStatus(userId);\n lines.push(` balance: ${w.usdcBalance} USDC base units`);\n lines.push(` allowance: ${w.usdcAllowance} (${w.allowanceSufficient ? 'ok' : 'insufficient'})`);\n lines.push(` ready: ${w.ready}`);\n } catch {\n // getWalletStatus fails if wallet not configured — ignore.\n }\n }\n return textResult(lines.join('\\n'));\n } catch (err) {\n return textResult(\n `get_user_status failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- pay_merchant ----------------------------------------------------------\n\nserver.tool(\n 'pay_merchant',\n {\n agentName: z.string().describe('Name of the locally-stored agent making the payment.'),\n merchantUrl: z.string().describe('Canonical merchant URL (stored on the payment record).'),\n amount: z.number().int().positive().describe('Amount in cents.'),\n memo: z.string().describe('Human-readable memo attached to the payment.'),\n userId: z\n .string()\n .optional()\n .describe('Optional ArisPay end-user id. Required when the agent is in platform mode.'),\n rail: z\n .enum(['card', 'crypto', 'balance', 'mpp'])\n .optional()\n .describe('Force a specific rail. Default: server-picked based on agent mode + userId.'),\n merchantName: z.string().optional().describe('Optional human-readable merchant name.'),\n merchantCategoryCode: z.string().optional().describe('MCC for spend-limit enforcement.'),\n },\n async ({ agentName, merchantUrl, amount, memo, userId, rail, merchantName, merchantCategoryCode }) => {\n try {\n const stored = getAgent(agentName);\n if (!stored) {\n return textResult(`No locally-stored agent named \\`${agentName}\\`.`, true);\n }\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const payment = await client.createPayment(stored.agentId, {\n amount,\n memo,\n merchantUrl,\n merchantName,\n merchantCategoryCode,\n userId,\n rail,\n });\n const lines = [\n `Payment ${payment.id}: ${payment.status}`,\n ` rail: ${payment.rail}`,\n ` amount: ${payment.amount}¢ ${payment.currency}`,\n ];\n if (payment.merchantName) lines.push(` merchant: ${payment.merchantName}`);\n if (payment.txHash) lines.push(` tx hash: ${payment.txHash}`);\n if (payment.nextAction) {\n lines.push(` next action: ${payment.nextAction.type}`);\n if (payment.nextAction.challengeUrl) {\n lines.push(` 3DS challenge URL: ${payment.nextAction.challengeUrl}`);\n }\n }\n if (payment.error) {\n lines.push(` error: ${payment.error.code} — ${payment.error.message}`);\n }\n return textResult(lines.join('\\n'), payment.status === 'failed');\n } catch (err) {\n return textResult(\n `pay_merchant failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- bootstrap_agent -------------------------------------------------------\n//\n// Cold-start primitive: signs up a developer + provisions an agent in one\n// MCP tool call, no `payagent init` required first. Backed by\n// `POST /v1/bootstrap` on the API. Persists results to the same\n// ~/.payagent/config.json the CLI uses, so afterwards every other tool\n// (`pay_api`, `check_wallet`, `get_balance`, `fund_agent`) just works.\n\nserver.tool(\n 'bootstrap_agent',\n {\n email: z.string().describe('Email for the new ArisPay developer account.'),\n name: z.string().optional().describe('Human name. Falls back to the email local-part.'),\n orgName: z.string().optional().describe('Workspace / org name. Falls back to \"<name>\\'s Team\".'),\n agentName: z.string().optional().describe('Local name for the provisioned agent. Default: \"default\".'),\n perTx: z.number().int().positive().optional().describe('Per-tx cap in cents. Default: 50.'),\n daily: z.number().int().positive().optional().describe('Daily cap in cents. Default: 1000.'),\n monthly: z.number().int().positive().optional().describe('Monthly cap in cents. Default: 10000.'),\n allowedDomains: z\n .array(z.string())\n .optional()\n .describe('Domains the agent may pay. Empty = unrestricted.'),\n fund: z\n .number()\n .positive()\n .optional()\n .describe('Optional preset USD amount; mints a Coinbase Onramp URL pre-set to this value.'),\n },\n async ({ email, name, orgName, agentName, perTx, daily, monthly, allowedDomains, fund }) => {\n try {\n const result = await bootstrapAgent({\n email,\n name,\n orgName,\n agentName,\n limits: { perTx, daily, monthly },\n allowedDomains,\n fund,\n arispayUrl: process.env.ARISPAY_URL,\n clientId: 'payagent-mcp-bootstrap',\n });\n const lines = [\n `✓ Account: ${result.email} (org \\`${result.orgName}\\`)`,\n `✓ Agent: ${result.agentName} (${result.agentId})`,\n ` Wallet: ${result.walletAddress} (${result.network})`,\n ` Limits: ${result.limits.perTx}¢ / tx, ${result.limits.daily}¢ / day, ${result.limits.monthly}¢ / month`,\n '',\n ];\n if (result.fundingUrl) {\n lines.push('Fund this wallet via Coinbase Onramp:');\n lines.push(` ${result.fundingUrl}`);\n if (result.fundingExpiresAt) lines.push(` URL valid until: ${result.fundingExpiresAt}`);\n lines.push(` Or send USDC on ${result.network} directly to ${result.walletAddress}.`);\n } else {\n if (result.fundingUrlError) {\n lines.push(`Onramp not available (${result.fundingUrlError}).`);\n }\n lines.push(`Fund the wallet by sending USDC on ${result.network} to ${result.walletAddress}.`);\n lines.push(\n `Or call \\`fund_agent\\` with name=\"${result.agentName}\", hosted=true to mint a Coinbase Onramp URL on demand.`,\n );\n }\n return textResult(lines.join('\\n'));\n } catch (err) {\n if (err instanceof BootstrapError) {\n return textResult(`bootstrap_agent failed (${err.code}): ${err.message}`, true);\n }\n return textResult(\n `bootstrap_agent failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- list_agents -----------------------------------------------------------\n\nserver.tool(\n 'list_agents',\n {},\n async () => {\n const agents = listAgents();\n if (!agents.length) {\n return textResult('No agents stored locally. Create one with `create_agent`.');\n }\n const lines = agents.map((a) =>\n [\n a.name,\n ` agent id: ${a.agentId}`,\n ` wallet: ${a.walletAddress}`,\n ` network: ${a.network ?? 'base'}`,\n ` limits: ${a.limits.perTx}¢ / tx, ${a.limits.daily}¢ / day, ${a.limits.monthly}¢ / month`,\n ` created: ${a.createdAt}`,\n ].join('\\n'),\n );\n return textResult(lines.join('\\n\\n'));\n },\n);\n\n// ── Start ─────────────────────────────────────────────\n\nasync function main() {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n\nmain().catch((err) => {\n console.error('Fatal:', err);\n process.exit(1);\n});\n","/**\n * Helpers for the `pay_api` MCP tool.\n *\n * Extracted into their own module so the heuristic that triggers\n * automatic Onramp-URL surfacing is unit-testable. The trigger has to\n * be conservative — false positives turn legitimate errors (allowed-\n * domain blocks, suspended agents) into misleading \"fund your wallet\"\n * suggestions.\n */\n\n/**\n * Does this error message look like the agent's USDC ran out?\n *\n * The signal we trust is `PaymentRejectedError(402, \"Server returned 402\n * after payment was signed and sent. Seller response: ...\")` from\n * `payFetchDelegated`, where the seller's body contains a funds- or\n * balance-shaped token. We do not pre-flight balance on every call —\n * that would add a round-trip to the warm path. Post-hoc detection\n * only, and only when both the 402 status AND a balance keyword\n * appear in the same message.\n */\nexport function looksLikeInsufficientFunds(message: string): boolean {\n if (!/402/.test(message)) return false;\n return /insufficient|insufficient_funds|insufficient_balance|exceeds_balance|invalid_transfer/i.test(\n message,\n );\n}\n"],"mappings":";;;AAsBA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,SAAS;AAClB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;AClBA,SAAS,2BAA2B,SAA0B;AACnE,MAAI,CAAC,MAAM,KAAK,OAAO,EAAG,QAAO;AACjC,SAAO,yFAAyF;AAAA,IAC9F;AAAA,EACF;AACF;;;ADkBA,IAAM,aAAa,cAAc,QAAQ,IAAI,WAAW;AAExD,IAAM,iBAAiB,QAAQ,IAAI;AACnC,IAAM,sBAAsB,QAAQ,IAAI;AAExC,SAAS,aAAa,MAAwC;AAC5D,MAAI,KAAM,QAAO,SAAS,IAAI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C;AAAA,QAC3E;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAIA,OAAO;AAAA,EACL;AAAA,EACA,CAAC;AAAA,EACD,YAAY;AACV,UAAM,SAAS,WAAW;AAC1B,QAAI,CAAC,OAAO,QAAQ;AAClB,aAAO,WAAW,2DAA2D;AAAA,IAC/E;AACA,UAAM,QAAQ,OAAO;AAAA,MAAI,CAAC,MACxB;AAAA,QACE,EAAE;AAAA,QACF,gBAAgB,EAAE,OAAO;AAAA,QACzB,gBAAgB,EAAE,aAAa;AAAA,QAC/B,gBAAgB,EAAE,WAAW,MAAM;AAAA,QACnC,gBAAgB,EAAE,OAAO,KAAK,cAAW,EAAE,OAAO,KAAK,eAAY,EAAE,OAAO,OAAO;AAAA,QACnF,gBAAgB,EAAE,SAAS;AAAA,MAC7B,EAAE,KAAK,IAAI;AAAA,IACb;AACA,WAAO,WAAW,MAAM,KAAK,MAAM,CAAC;AAAA,EACtC;AACF;AAIA,eAAe,OAAO;AACpB,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAChC;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,MAAM,UAAU,GAAG;AAC3B,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["lines"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/pay-api-helpers.ts","../src/profile.ts"],"sourcesContent":["/**\n * payagent-mcp — MCP server for agent-side x402 payments + headless launch.\n *\n * Thirteen tools over stdio. Core (the 80% path):\n * - bootstrap_agent(...) — cold-start: sign up + provision an agent in one call\n * - pay_api(url, ...) — paid HTTP request via delegated signing\n * - check_wallet() — report current agent credentials + on-chain balance\n *\n * Wallet management:\n * - create_agent(...) — provision a new x402 agent (calls /v1/agents/x402)\n * - fund_agent({ name }) — wallet address / hosted Coinbase Onramp URL\n * - get_balance({ name }) — on-server USDC balance + fundedAt latch\n * - list_agents() — server-authoritative wallet enumeration\n * - rename_agent(...) — server-side rename + local cache mirror\n *\n * Platform (end-user) tools:\n * - create_enduser(...) — find-or-create an EndUser by externalId\n * - attach_card_for_user(...)— mint a hosted card-setup session URL\n * - set_user_limits(...) — per-(user, agent) spend caps + MCC rules\n * - get_user_status(...) — card / wallet / readiness report\n * - pay_merchant(...) — direct payment via POST /v1/payments\n *\n * Config store lives at ~/.payagent/config.json (shared with the `payagent`\n * CLI). Credentials created via `npx payagent init` + `payagent agent create`\n * are immediately available here; equally, agents created via\n * `create_agent` are immediately visible to the CLI.\n *\n * Two auth modes, picked at request time:\n * 1. Legacy single-agent: ARISPAY_AGENT_KEY set → pay_api + check_wallet use it directly.\n * 2. Multi-agent: no env var, credentials come from the shared config store.\n * Management tools (create / fund / get_balance / list) always use the\n * developer key from the config store (or ARISPAY_API_KEY env).\n */\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport {\n BootstrapError,\n type DelegatedPaymentInfo,\n DelegationClient,\n HostedTopupNotConfiguredError,\n type StoredAgent,\n bootstrapAgent,\n formatUSDC,\n getAgent,\n getApiKey,\n getArispayUrl,\n getUSDCBalance,\n launchAgent,\n listAgents,\n payFetchDelegated,\n renameStoredAgent,\n syncAgents,\n} from \"payagent\";\nimport { z } from \"zod\";\nimport { looksLikeInsufficientFunds } from \"./pay-api-helpers.js\";\nimport { platformToolsEnabled } from \"./profile.js\";\n\n// ── Configuration ─────────────────────────────────────\n\nconst arispayUrl = getArispayUrl(process.env.ARISPAY_URL);\n/** Legacy single-agent key (kept for backwards compatibility). */\nconst legacyAgentKey = process.env.ARISPAY_AGENT_KEY;\nconst legacyWalletAddress = process.env.PAYAGENT_WALLET;\n\nfunction resolveAgent(name?: string): StoredAgent | undefined {\n if (name) return getAgent(name);\n const agents = listAgents();\n return agents[0];\n}\n\n/**\n * Look up the agent-scoped key to use for paid requests.\n * Priority: explicit agent name → legacy env var → first stored agent.\n */\nfunction resolveAgentKey(name?: string): { key: string; source: string } | undefined {\n if (name) {\n const stored = getAgent(name);\n if (stored) return { key: stored.apiKey, source: `agent \\`${name}\\`` };\n return undefined;\n }\n if (legacyAgentKey) return { key: legacyAgentKey, source: \"ARISPAY_AGENT_KEY\" };\n const first = listAgents()[0];\n if (first) return { key: first.apiKey, source: `agent \\`${first.name}\\`` };\n return undefined;\n}\n\nfunction requireDevKey(): string {\n const key = getApiKey();\n if (!key) {\n throw new Error(\n \"No ArisPay developer key found. Run `npx payagent init` or set ARISPAY_API_KEY.\",\n );\n }\n return key;\n}\n\nfunction textResult(text: string, isError = false) {\n return {\n content: [{ type: \"text\" as const, text }],\n ...(isError ? { isError } : {}),\n };\n}\n\n// ── MCP Server ────────────────────────────────────────\n\nconst server = new McpServer({\n name: \"payagent\",\n version: \"2.1.0\",\n});\n\n// --- pay_api ----------------------------------------------------------------\n\nserver.tool(\n \"pay_api\",\n \"Make an HTTP request to a paid API, transparently paying any x402 (HTTP 402) challenge with USDC under the agent's spend limits. THE tool for fetching paid resources — never bypass a 402 or hand-roll payment.\",\n {\n url: z.string().describe(\"The full URL of the API endpoint to call\"),\n method: z\n .enum([\"GET\", \"POST\", \"PUT\", \"DELETE\", \"PATCH\"])\n .default(\"GET\")\n .describe(\"HTTP method\"),\n headers: z.record(z.string(), z.string()).optional().describe(\"Additional HTTP headers\"),\n body: z.string().optional().describe(\"Request body (for POST/PUT/PATCH)\"),\n agent: z\n .string()\n .optional()\n .describe(\n \"Optional: name of a locally-stored agent to pay with. Defaults to ARISPAY_AGENT_KEY or the first stored agent.\",\n ),\n },\n async ({ url, method, headers, body, agent }) => {\n const resolved = resolveAgentKey(agent);\n if (!resolved) {\n return textResult(\n [\n \"No agent available. Cold-start in one call:\",\n ' bootstrap_agent({ email: \"you@example.com\", name: \"<your-name>\" })',\n \"\",\n \"Or, if a developer key is already paired (`npx payagent init`):\",\n \" create_agent({ name, perTx, daily, monthly })\",\n \"\",\n \"Or set ARISPAY_AGENT_KEY for legacy single-agent mode.\",\n ].join(\"\\n\"),\n true,\n );\n }\n try {\n // Budget headroom rides the delegated-sign response — capture it so the\n // host learns its remaining budget without a second tool call.\n let paymentInfo: DelegatedPaymentInfo | undefined;\n const fetch402 = payFetchDelegated({\n arispayUrl,\n apiKey: resolved.key,\n onPayment: (info) => {\n paymentInfo = info;\n },\n });\n const response = await fetch402(url, { method, headers, body });\n const responseBody = await response.text();\n const statusLine = paymentInfo\n ? `HTTP ${response.status} (paid ${paymentInfo.amountCents}¢ via ${resolved.source} — budget left: ${paymentInfo.remainingDaily}¢ today, ${paymentInfo.remainingMonthly}¢ this month)`\n : `HTTP ${response.status} (paid via ${resolved.source})`;\n return textResult([statusLine, \"\", responseBody].join(\"\\n\"));\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n // Detect \"agent wallet has no USDC\" — surface a Coinbase Onramp URL\n // inline so Claude / the host doesn't have to make a second tool\n // call to figure out the recovery path. We're conservative about\n // the trigger: only do this on a 402-after-signed-payment with a\n // funds-shaped error in the seller response. Other failures\n // (allowed-domain block, agent suspended, network) propagate as-is.\n if (looksLikeInsufficientFunds(message)) {\n const onrampHint = await tryGetOnrampHint(agent);\n return textResult(\n [\n `Error: ${message}`,\n \"\",\n \"This looks like the agent wallet is out of USDC. Fund it and retry:\",\n ...(onrampHint ?? [\n \" Use the `fund_agent` tool with hosted=true to mint a Coinbase Onramp URL,\",\n \" or send USDC on Base directly to the wallet address from `check_wallet`.\",\n ]),\n ].join(\"\\n\"),\n true,\n );\n }\n return textResult(`Error: ${message}`, true);\n }\n },\n);\n\n/**\n * Best-effort: mint an Onramp URL for the named agent (or the first one\n * in the local store). Returns the lines to append to the error message,\n * or `undefined` if we can't get one (no dev key, no Onramp configured,\n * no agent name resolvable).\n */\nasync function tryGetOnrampHint(agentName?: string): Promise<string[] | undefined> {\n const stored = resolveAgent(agentName);\n if (!stored) return undefined;\n const devKey = getApiKey();\n if (!devKey) return undefined;\n try {\n const client = new DelegationClient(arispayUrl, devKey);\n const link = await client.getHostedTopup(stored.agentId, {});\n return [\n ` Coinbase Onramp: ${link.fundingUrl}`,\n ` URL valid until: ${link.expiresAt}`,\n ` Or send USDC on ${link.network} directly to ${link.walletAddress}`,\n ];\n } catch (err) {\n if (err instanceof HostedTopupNotConfiguredError) return undefined;\n return undefined;\n }\n}\n\n// --- check_wallet ----------------------------------------------------------\n\nserver.tool(\n \"check_wallet\",\n 'Show the current agent\\'s credentials, wallet address, and on-chain USDC balance — the quick \"what state am I in\" probe.',\n {\n agent: z\n .string()\n .optional()\n .describe(\n \"Optional: name of a locally-stored agent. Defaults to legacy ARISPAY_WALLET mode.\",\n ),\n },\n async ({ agent }) => {\n const resolved = resolveAgent(agent);\n const walletAddress = resolved?.walletAddress ?? legacyWalletAddress;\n const keyTail =\n resolved?.apiKey.slice(-4) ?? (legacyAgentKey ? legacyAgentKey.slice(-4) : undefined);\n\n const lines = [`ArisPay URL: ${arispayUrl}`];\n if (resolved) lines.push(`Agent: ${resolved.name} (${resolved.agentId})`);\n if (keyTail) lines.push(`Agent key: ap_…${keyTail}`);\n\n if (walletAddress) {\n lines.push(`Wallet: ${walletAddress}`);\n try {\n const raw = await getUSDCBalance(walletAddress, (resolved?.network as \"base\") ?? \"base\");\n lines.push(`Balance: ${formatUSDC(raw)} USDC on ${resolved?.network ?? \"base\"}`);\n } catch (err) {\n lines.push(\n `Balance: unavailable (${err instanceof Error ? err.message : String(err)})`,\n );\n }\n } else {\n lines.push(\"\", \"No wallet known. Use `create_agent` or set PAYAGENT_WALLET for legacy mode.\");\n }\n\n lines.push(\"\", \"Manage limits + full history: https://arispay.app/dashboard\");\n return textResult(lines.join(\"\\n\"));\n },\n);\n\n// --- create_agent ----------------------------------------------------------\n\nserver.tool(\n \"create_agent\",\n \"Provision an additional x402 payment agent (wallet + spend limits) under the already-paired developer account.\",\n {\n name: z.string().describe(\"Local identifier for this agent. Used by later tools.\"),\n perTx: z.number().int().positive().describe(\"Per-transaction spend cap in cents.\"),\n daily: z.number().int().positive().describe(\"Daily spend cap in cents.\"),\n monthly: z.number().int().positive().describe(\"Monthly spend cap in cents.\"),\n allowedDomains: z\n .array(z.string())\n .optional()\n .describe(\"If provided, restrict this agent to paying only these domains.\"),\n network: z\n .enum([\"base\", \"base-sepolia\", \"ethereum\", \"polygon\"])\n .default(\"base\")\n .describe(\"EVM network the agent pays on.\"),\n agentType: z.string().optional().describe('Optional metadata label (e.g. \"hermes\").'),\n },\n async ({ name, perTx, daily, monthly, allowedDomains, network, agentType }) => {\n try {\n requireDevKey(); // fail fast with a helpful message if not signed in\n const agent = await launchAgent({\n name,\n limits: { perTx, daily, monthly },\n allowedDomains,\n network,\n agentType,\n });\n const lines = [\n `✓ Agent \\`${name}\\` created.`,\n ` Agent ID: ${agent.agentId}`,\n ` Wallet: ${agent.walletAddress}`,\n ` Network: ${agent.network}`,\n ` Limits: ${perTx}¢ / tx, ${daily}¢ / day, ${monthly}¢ / month`,\n \"\",\n ` Fund the wallet with USDC on ${agent.network}, then call \\`get_balance\\` with name=\"${name}\".`,\n ];\n return textResult(lines.join(\"\\n\"));\n } catch (err) {\n return textResult(\n `create_agent failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- fund_agent ------------------------------------------------------------\n\nserver.tool(\n \"fund_agent\",\n \"Get funding instructions for an agent's wallet — the USDC deposit address, or a hosted Coinbase Onramp URL with `hosted: true`.\",\n {\n name: z.string().describe(\"Name of a locally-stored agent.\"),\n hosted: z\n .boolean()\n .optional()\n .describe(\n \"If true, request a provider-hosted onramp URL (Coinbase, etc.) instead of the plain wallet address. Requires ARISPAY_ONRAMP_PROVIDER on the API deployment.\",\n ),\n amount: z\n .number()\n .optional()\n .describe(\"Preset top-up amount in dollars. Only meaningful with `hosted: true`.\"),\n },\n async ({ name, hosted, amount }) => {\n const stored = getAgent(name);\n if (!stored) return textResult(`No locally-stored agent named \\`${name}\\`.`, true);\n\n if (hosted) {\n const devKey = getApiKey();\n if (!devKey) {\n return textResult(\"No ArisPay developer key found. Run `npx payagent init` first.\", true);\n }\n const client = new DelegationClient(arispayUrl, devKey);\n try {\n const link = await client.getHostedTopup(stored.agentId, { amount });\n const lines = [\n `Top up \\`${name}\\` via ${link.provider}:`,\n \"\",\n ` ${link.fundingUrl}`,\n \"\",\n ` Wallet: ${link.walletAddress}`,\n ` Network: ${link.network}`,\n ` URL valid until: ${link.expiresAt}`,\n \"\",\n \"Share that URL with the end-user; the onramp deposits USDC straight to the agent's wallet.\",\n ];\n return textResult(lines.join(\"\\n\"));\n } catch (err) {\n if (err instanceof HostedTopupNotConfiguredError) {\n return textResult(\n [\n \"Hosted onramp is not configured on this ArisPay deployment.\",\n \"Falling back to the manual path:\",\n \"\",\n ` Send USDC on ${stored.network ?? \"base\"} to ${stored.walletAddress}`,\n \"\",\n \"Ask the deployment owner to set ARISPAY_ONRAMP_PROVIDER=coinbase (+ COINBASE_ONRAMP_APP_ID) to enable hosted top-ups.\",\n ].join(\"\\n\"),\n );\n }\n return textResult(\n `fund_agent (hosted) failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n }\n\n const lines = [\n `Fund \\`${name}\\` by sending USDC on ${stored.network ?? \"base\"} to:`,\n \"\",\n ` ${stored.walletAddress}`,\n \"\",\n \"Pass `hosted: true` to get a Coinbase onramp URL instead (requires ARISPAY_ONRAMP_PROVIDER).\",\n \"Call `get_balance` when the deposit lands.\",\n ];\n return textResult(lines.join(\"\\n\"));\n },\n);\n\n// --- get_balance -----------------------------------------------------------\n\nserver.tool(\n \"get_balance\",\n \"Server-side USDC balance + funding status for one named agent.\",\n {\n name: z.string().describe(\"Name of a locally-stored agent.\"),\n },\n async ({ name }) => {\n const stored = getAgent(name);\n if (!stored) return textResult(`No locally-stored agent named \\`${name}\\`.`, true);\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const balance = await client.getBalance(stored.agentId);\n const human = formatUSDC(BigInt(balance.usdcBalance || \"0\"));\n const lines = [\n `${name}: ${human} USDC on ${balance.network}`,\n balance.fundedAt ? ` First funded at: ${balance.fundedAt}` : \" Not yet funded.\",\n ` Wallet: ${balance.walletAddress}`,\n ];\n return textResult(lines.join(\"\\n\"));\n } catch (err) {\n return textResult(\n `get_balance failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- Platform (end-user) tools ----------------------------------------------\n//\n// Skipped under PAYAGENT_MCP_PROFILE=core so pay-URL-only hosts load 8 tool\n// schemas instead of 13 (see src/profile.ts).\nif (platformToolsEnabled()) {\n // --- create_enduser --------------------------------------------------------\n\n server.tool(\n \"create_enduser\",\n \"Platform mode: register an end-customer (EndUser) under your account, keyed by your own externalId.\",\n {\n externalId: z.string().describe(\"Your own stable id for this customer (e.g. `tg:12345`).\"),\n email: z.string().optional().describe(\"Optional email for compliance / receipts.\"),\n findOrCreate: z\n .boolean()\n .optional()\n .describe(\"If true, return the existing user instead of erroring on externalId collision.\"),\n },\n async ({ externalId, email, findOrCreate }) => {\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const user = await client.createEndUser({ externalId, email, findOrCreate });\n const lines = [\n `✓ End-user \\`${externalId}\\` ready.`,\n ` ArisPay id: ${user.id}`,\n ` Has card: ${user.hasPaymentMethod ? \"yes\" : \"no\"}`,\n ` Has wallet: ${user.hasWallet ? \"yes\" : \"no\"}`,\n ];\n return textResult(lines.join(\"\\n\"));\n } catch (err) {\n return textResult(\n `create_enduser failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n );\n\n // --- attach_card_for_user -------------------------------------------------\n\n server.tool(\n \"attach_card_for_user\",\n \"Platform mode: mint a hosted card-entry URL for an end-user (ArisPay handles tokenization + 3DS).\",\n {\n userId: z.string().describe(\"The ArisPay-internal end-user id (not externalId).\"),\n agentName: z\n .string()\n .optional()\n .describe(\"Optional locally-stored agent name to scope the card-setup session to.\"),\n },\n async ({ userId, agentName }) => {\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const agentId = agentName ? getAgent(agentName)?.agentId : undefined;\n const session = await client.createCardSetupSession({ endUserId: userId, agentId });\n const lines = [\n `Card-entry URL for user \\`${userId}\\`:`,\n \"\",\n ` ${session.setupUrl}`,\n \"\",\n ` Expires at: ${session.expiresAt}`,\n \"\",\n \"Share this URL with the end-user. They enter the card on ArisPay's hosted page; we handle tokenization + 3DS.\",\n \"Call `get_user_status` afterwards to confirm the card is attached.\",\n ];\n return textResult(lines.join(\"\\n\"));\n } catch (err) {\n return textResult(\n `attach_card_for_user failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n );\n\n // --- set_user_limits -------------------------------------------------------\n\n server.tool(\n \"set_user_limits\",\n \"Platform mode: set per-(user, agent) spend caps in integer cents plus MCC allow/block rules.\",\n {\n userId: z.string().describe(\"ArisPay-internal end-user id.\"),\n agentName: z.string().describe(\"Locally-stored agent name.\"),\n perTx: z\n .number()\n .int()\n .optional()\n .describe(\"Per-transaction cap in cents. Omit to inherit agent defaults.\"),\n daily: z.number().int().optional().describe(\"Daily cap in cents.\"),\n monthly: z.number().int().optional().describe(\"Monthly cap in cents.\"),\n allowedMcc: z.array(z.string()).optional().describe(\"Allowed Merchant Category Codes.\"),\n blockedMcc: z.array(z.string()).optional().describe(\"Blocked MCCs.\"),\n },\n async ({ userId, agentName, perTx, daily, monthly, allowedMcc, blockedMcc }) => {\n try {\n const stored = getAgent(agentName);\n if (!stored) {\n return textResult(`No locally-stored agent named \\`${agentName}\\`.`, true);\n }\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const limit = await client.setUserLimits(userId, {\n agentId: stored.agentId,\n maxPerTransaction: perTx ?? null,\n maxDaily: daily ?? null,\n maxMonthly: monthly ?? null,\n allowedMerchantCategories: allowedMcc,\n blockedMerchantCategories: blockedMcc,\n });\n return textResult(\n [\n `✓ Limits set for \\`${userId}\\` on agent \\`${agentName}\\`.`,\n ` per-tx ${limit.maxPerTransaction ?? \"inherit\"}¢, daily ${limit.maxDaily ?? \"inherit\"}¢, monthly ${limit.maxMonthly ?? \"inherit\"}¢`,\n ].join(\"\\n\"),\n );\n } catch (err) {\n return textResult(\n `set_user_limits failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n );\n\n // --- get_user_status -------------------------------------------------------\n\n server.tool(\n \"get_user_status\",\n \"Platform mode: report an end-user's card, wallet, and payment readiness.\",\n {\n userId: z.string().describe(\"ArisPay-internal end-user id.\"),\n },\n async ({ userId }) => {\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const user = await client.getEndUser(userId);\n const lines = [\n `${user.externalId} (${user.id})`,\n ` email: ${user.email ?? \"—\"}`,\n ` card: ${user.hasPaymentMethod ? `${user.cardBrand ?? \"card\"} …${user.cardLast4 ?? \"????\"}` : \"—\"}`,\n ` wallet: ${user.walletAddress ?? \"—\"}${user.walletChain ? ` on ${user.walletChain}` : \"\"}`,\n ];\n if (user.hasWallet) {\n try {\n const w = await client.getWalletStatus(userId);\n lines.push(` balance: ${w.usdcBalance} USDC base units`);\n lines.push(\n ` allowance: ${w.usdcAllowance} (${w.allowanceSufficient ? \"ok\" : \"insufficient\"})`,\n );\n lines.push(` ready: ${w.ready}`);\n } catch {\n // getWalletStatus fails if wallet not configured — ignore.\n }\n }\n return textResult(lines.join(\"\\n\"));\n } catch (err) {\n return textResult(\n `get_user_status failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n );\n\n // --- pay_merchant ----------------------------------------------------------\n\n server.tool(\n \"pay_merchant\",\n \"Direct payment to a known merchant via ArisPay rails (card / crypto / balance / MPP) when you already know the amount. For x402-protected HTTP resources use `pay_api` instead.\",\n {\n agentName: z.string().describe(\"Name of the locally-stored agent making the payment.\"),\n merchantUrl: z.string().describe(\"Canonical merchant URL (stored on the payment record).\"),\n amount: z.number().int().positive().describe(\"Amount in cents.\"),\n memo: z.string().describe(\"Human-readable memo attached to the payment.\"),\n userId: z\n .string()\n .optional()\n .describe(\"Optional ArisPay end-user id. Required when the agent is in platform mode.\"),\n rail: z\n .enum([\"card\", \"crypto\", \"balance\", \"mpp\"])\n .optional()\n .describe(\"Force a specific rail. Default: server-picked based on agent mode + userId.\"),\n merchantName: z.string().optional().describe(\"Optional human-readable merchant name.\"),\n merchantCategoryCode: z.string().optional().describe(\"MCC for spend-limit enforcement.\"),\n },\n async ({\n agentName,\n merchantUrl,\n amount,\n memo,\n userId,\n rail,\n merchantName,\n merchantCategoryCode,\n }) => {\n try {\n const stored = getAgent(agentName);\n if (!stored) {\n return textResult(`No locally-stored agent named \\`${agentName}\\`.`, true);\n }\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const payment = await client.createPayment(stored.agentId, {\n amount,\n memo,\n merchantUrl,\n merchantName,\n merchantCategoryCode,\n userId,\n rail,\n });\n const lines = [\n `Payment ${payment.id}: ${payment.status}`,\n ` rail: ${payment.rail}`,\n ` amount: ${payment.amount}¢ ${payment.currency}`,\n ];\n if (payment.merchantName) lines.push(` merchant: ${payment.merchantName}`);\n if (payment.txHash) lines.push(` tx hash: ${payment.txHash}`);\n if (payment.spend) {\n const fmtCap = (v: number | null) => (v == null ? \"no cap\" : `${v}¢`);\n lines.push(\n ` budget: ${fmtCap(payment.spend.remainingDaily)} left today, ${fmtCap(payment.spend.remainingMonthly)} this month`,\n );\n }\n if (payment.nextAction) {\n lines.push(` next action: ${payment.nextAction.type}`);\n if (payment.nextAction.challengeUrl) {\n lines.push(` 3DS challenge URL: ${payment.nextAction.challengeUrl}`);\n }\n }\n if (payment.error) {\n lines.push(` error: ${payment.error.code} — ${payment.error.message}`);\n }\n return textResult(lines.join(\"\\n\"), payment.status === \"failed\");\n } catch (err) {\n return textResult(\n `pay_merchant failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n );\n}\n\n// --- bootstrap_agent -------------------------------------------------------\n//\n// Cold-start primitive: signs up a developer + provisions an agent in one\n// MCP tool call, no `payagent init` required first. Backed by\n// `POST /v1/bootstrap` on the API. Persists results to the same\n// ~/.payagent/config.json the CLI uses, so afterwards every other tool\n// (`pay_api`, `check_wallet`, `get_balance`, `fund_agent`) just works.\n\nserver.tool(\n \"bootstrap_agent\",\n \"Cold-start in one call: create (or recover) an ArisPay account plus a payment agent from just an email. Run this first on a fresh machine; safe to re-run — it recovers the existing agent and wallet set instead of creating duplicates.\",\n {\n email: z.string().describe(\"Email for the new ArisPay developer account.\"),\n name: z.string().optional().describe(\"Human name. Falls back to the email local-part.\"),\n orgName: z\n .string()\n .optional()\n .describe('Workspace / org name. Falls back to \"<name>\\'s Team\".'),\n agentName: z\n .string()\n .optional()\n .describe('Local name for the provisioned agent. Default: \"default\".'),\n perTx: z.number().int().positive().optional().describe(\"Per-tx cap in cents. Default: 50.\"),\n daily: z.number().int().positive().optional().describe(\"Daily cap in cents. Default: 1000.\"),\n monthly: z\n .number()\n .int()\n .positive()\n .optional()\n .describe(\"Monthly cap in cents. Default: 10000.\"),\n allowedDomains: z\n .array(z.string())\n .optional()\n .describe(\"Domains the agent may pay. Empty = unrestricted.\"),\n fund: z\n .number()\n .positive()\n .optional()\n .describe(\"Optional preset USD amount; mints a Coinbase Onramp URL pre-set to this value.\"),\n },\n async ({ email, name, orgName, agentName, perTx, daily, monthly, allowedDomains, fund }) => {\n try {\n const result = await bootstrapAgent({\n email,\n name,\n orgName,\n agentName,\n limits: { perTx, daily, monthly },\n allowedDomains,\n fund,\n arispayUrl: process.env.ARISPAY_URL,\n clientId: \"payagent-mcp-bootstrap\",\n });\n const lines = [\n `✓ Account: ${result.email} (org \\`${result.orgName}\\`)`,\n `✓ Agent: ${result.agentName} (${result.agentId})`,\n ` Wallet: ${result.walletAddress} (${result.network})`,\n ` Limits: ${result.limits.perTx}¢ / tx, ${result.limits.daily}¢ / day, ${result.limits.monthly}¢ / month`,\n \"\",\n ];\n if (result.fundingUrl) {\n lines.push(\"Fund this wallet via Coinbase Onramp:\");\n lines.push(` ${result.fundingUrl}`);\n if (result.fundingExpiresAt) lines.push(` URL valid until: ${result.fundingExpiresAt}`);\n lines.push(` Or send USDC on ${result.network} directly to ${result.walletAddress}.`);\n } else {\n if (result.fundingUrlError) {\n lines.push(`Onramp not available (${result.fundingUrlError}).`);\n }\n lines.push(\n `Fund the wallet by sending USDC on ${result.network} to ${result.walletAddress}.`,\n );\n lines.push(\n `Or call \\`fund_agent\\` with name=\"${result.agentName}\", hosted=true to mint a Coinbase Onramp URL on demand.`,\n );\n }\n // BuyForMe phone-pairing handoff. Surface the URL prominently so\n // the user (or the AI host) can choose to open it directly or\n // pass it along to the human-on-the-phone.\n if (result.pairing) {\n lines.push(\"\");\n lines.push(\"📱 Open BuyForMe on your phone (signs you into the same account):\");\n lines.push(` ${result.pairing.url}`);\n lines.push(` Link expires: ${result.pairing.expiresAt}`);\n }\n return textResult(lines.join(\"\\n\"));\n } catch (err) {\n if (err instanceof BootstrapError) {\n return textResult(`bootstrap_agent failed (${err.code}): ${err.message}`, true);\n }\n return textResult(\n `bootstrap_agent failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- list_agents -----------------------------------------------------------\n//\n// Server-authoritative. Hits `GET /v1/agents?withDelegation=1` and (when\n// `withBalance: true`) fans out per-agent balance checks. The local\n// `~/.payagent/config.json` is rehydrated as a side-effect so a subsequent\n// pay_api / fund_agent call sees the same wallet view. Falls back to the\n// local cache when no developer key is available — keeps the legacy\n// single-agent-via-ARISPAY_AGENT_KEY flow working without a dev key.\n\nserver.tool(\n \"list_agents\",\n \"List all wallets under this account (server-authoritative; rehydrates the local cache).\",\n {\n withBalance: z\n .boolean()\n .optional()\n .describe(\n \"When true, fetch on-chain USDC balance per agent (adds one round-trip per wallet).\",\n ),\n },\n async ({ withBalance }) => {\n // If the user has no developer key, we can't hit the server. Fall back\n // to the local cache so the tool stays useful for env-key-only setups.\n const devKey = getApiKey();\n if (!devKey) {\n const local = listAgents();\n if (!local.length) {\n return textResult(\n \"No developer key set and no agents cached locally. Run `bootstrap_agent` or set ARISPAY_API_KEY.\",\n );\n }\n const lines = local.map((a) =>\n [\n a.name,\n ` agent id: ${a.agentId}`,\n ` wallet: ${a.walletAddress}`,\n ` network: ${a.network ?? \"base\"}`,\n ` limits: ${a.limits.perTx}¢ / tx, ${a.limits.daily}¢ / day, ${a.limits.monthly}¢ / month`,\n ` created: ${a.createdAt}`,\n \" (local cache only — set ARISPAY_API_KEY to sync from the server)\",\n ].join(\"\\n\"),\n );\n return textResult(lines.join(\"\\n\\n\"));\n }\n\n try {\n const result = await syncAgents({ includeBalance: withBalance === true });\n if (!result.agents.length) {\n return textResult(\n \"No wallets found under this developer key. Create one with `create_agent` or `bootstrap_agent`.\",\n );\n }\n const lines = result.agents.map((a) => {\n const balanceLine =\n a.usdcBalance !== undefined\n ? ` balance: ${formatUSDC(BigInt(a.usdcBalance || \"0\"))} USDC`\n : null;\n const fundedLine = a.fundedAt ? ` funded: ${a.fundedAt}` : \" funded: not yet\";\n const domainsLine = a.allowedDomains.length\n ? ` domains: ${a.allowedDomains.join(\", \")}`\n : \" domains: (unrestricted)\";\n const suspendedLine = a.suspended ? \" status: SUSPENDED\" : null;\n return [\n a.name,\n ` agent id: ${a.agentId}`,\n ` wallet: ${a.walletAddress}`,\n ` network: ${a.network}`,\n ` limits: ${a.limits.maxPerTx}¢ / tx, ${a.limits.maxDaily}¢ / day, ${a.limits.maxMonthly}¢ / month`,\n domainsLine,\n fundedLine,\n ...(balanceLine ? [balanceLine] : []),\n ...(suspendedLine ? [suspendedLine] : []),\n ` created: ${a.createdAt}`,\n ].join(\"\\n\");\n });\n return textResult(\n `${result.agents.length} wallet${result.agents.length === 1 ? \"\" : \"s\"} under this account (synced from server):\\n\\n${lines.join(\"\\n\\n\")}`,\n );\n } catch (err) {\n return textResult(\n `list_agents failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- rename_agent ----------------------------------------------------------\n//\n// Renames the server-side Agent (PATCH /v1/agents/:id) AND the local\n// cache entry. The server enforces per-org name uniqueness — a 409 here\n// means another wallet under this account already uses that name.\n\nserver.tool(\n \"rename_agent\",\n \"Rename an agent on the server and in the local cache (names are unique per account).\",\n {\n name: z.string().describe(\"Current local name of the agent to rename.\"),\n newName: z\n .string()\n .describe(\n \"New name. Letters, numbers, spaces, hyphens, underscores, dots. 1-64 chars. Must be unique per account.\",\n ),\n },\n async ({ name, newName }) => {\n if (name === newName) {\n return textResult(`Agent \\`${name}\\` already has that name — nothing to do.`);\n }\n const stored = getAgent(name);\n if (!stored) {\n return textResult(\n `No locally-cached agent named \\`${name}\\`. Run \\`list_agents\\` first to sync, or check the spelling.`,\n true,\n );\n }\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const result = await client.renameAgent(stored.agentId, newName);\n // Server accepted — mirror locally. `result.name` is the canonical\n // form (server may have trimmed it), so we use that, not the raw input.\n renameStoredAgent(name, result.name);\n return textResult(\n `✓ Renamed \\`${name}\\` → \\`${result.name}\\`. Wallet ${result.walletAddress ?? stored.walletAddress} is unchanged.`,\n );\n } catch (err) {\n return textResult(\n `rename_agent failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// ── Start ─────────────────────────────────────────────\n\nasync function main() {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n\nmain().catch((err) => {\n console.error(\"Fatal:\", err);\n process.exit(1);\n});\n","/**\n * Helpers for the `pay_api` MCP tool.\n *\n * Extracted into their own module so the heuristic that triggers\n * automatic Onramp-URL surfacing is unit-testable. The trigger has to\n * be conservative — false positives turn legitimate errors (allowed-\n * domain blocks, suspended agents) into misleading \"fund your wallet\"\n * suggestions.\n */\n\n/**\n * Does this error message look like the agent's USDC ran out?\n *\n * The signal we trust is `PaymentRejectedError(402, \"Server returned 402\n * after payment was signed and sent. Seller response: ...\")` from\n * `payFetchDelegated`, where the seller's body contains a funds- or\n * balance-shaped token. We do not pre-flight balance on every call —\n * that would add a round-trip to the warm path. Post-hoc detection\n * only, and only when both the 402 status AND a balance keyword\n * appear in the same message.\n */\nexport function looksLikeInsufficientFunds(message: string): boolean {\n if (!/402/.test(message)) return false;\n return /insufficient|insufficient_funds|insufficient_balance|exceeds_balance|invalid_transfer/i.test(\n message,\n );\n}\n","/**\n * Tool-profile selection (docs/agent-discoverability.md, open question 2).\n *\n * Every registered tool's schema is resident in the MCP host's context on\n * every task. The common persona — \"an agent that pays URLs\" — never needs\n * the five platform (end-user) tools, so `PAYAGENT_MCP_PROFILE=core` skips\n * registering them and the host loads 8 schemas instead of 13:\n *\n * core profile: bootstrap_agent, pay_api, check_wallet, create_agent,\n * fund_agent, get_balance, list_agents, rename_agent\n * all (default): the above + create_enduser, attach_card_for_user,\n * set_user_limits, get_user_status, pay_merchant\n *\n * Default stays \"all\" for backward compatibility with existing host configs.\n */\nexport function platformToolsEnabled(raw = process.env.PAYAGENT_MCP_PROFILE): boolean {\n return (raw ?? \"all\").trim().toLowerCase() !== \"core\";\n}\n"],"mappings":";;;AAiCA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,SAAS;;;AChCX,SAAS,2BAA2B,SAA0B;AACnE,MAAI,CAAC,MAAM,KAAK,OAAO,EAAG,QAAO;AACjC,SAAO,yFAAyF;AAAA,IAC9F;AAAA,EACF;AACF;;;ACXO,SAAS,qBAAqB,MAAM,QAAQ,IAAI,sBAA+B;AACpF,UAAQ,OAAO,OAAO,KAAK,EAAE,YAAY,MAAM;AACjD;;;AF0CA,IAAM,aAAa,cAAc,QAAQ,IAAI,WAAW;AAExD,IAAM,iBAAiB,QAAQ,IAAI;AACnC,IAAM,sBAA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A,IACF;AAAA,EACF;AACF;AAIA,eAAe,OAAO;AACpB,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAChC;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,MAAM,UAAU,GAAG;AAC3B,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["lines"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arispay/payagent-mcp",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "MCP server
|
|
3
|
+
"version": "2.7.1",
|
|
4
|
+
"description": "MCP server that gives AI agents a wallet: pay x402 APIs (USD + EUR), check balances, self-onboard with one tool call. Use with Claude, Cursor, or any MCP client — delegated custody, no private keys on the agent.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"payagent-mcp": "dist/index.js"
|
|
@@ -30,7 +30,13 @@
|
|
|
30
30
|
"cursor",
|
|
31
31
|
"windsurf",
|
|
32
32
|
"agent-tool",
|
|
33
|
-
"delegated-custody"
|
|
33
|
+
"delegated-custody",
|
|
34
|
+
"agent-wallet",
|
|
35
|
+
"agent-payments",
|
|
36
|
+
"eurc",
|
|
37
|
+
"pay-for-api",
|
|
38
|
+
"agentic-commerce",
|
|
39
|
+
"bootstrap"
|
|
34
40
|
],
|
|
35
41
|
"engines": {
|
|
36
42
|
"node": ">=18"
|
|
@@ -46,13 +52,14 @@
|
|
|
46
52
|
"dependencies": {
|
|
47
53
|
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
48
54
|
"zod": "^3.25.0",
|
|
49
|
-
"payagent": "^2.
|
|
55
|
+
"payagent": "^2.12.2"
|
|
50
56
|
},
|
|
51
57
|
"devDependencies": {
|
|
52
58
|
"@types/node": "^22.0.0",
|
|
53
59
|
"tsup": "^8.0.0",
|
|
54
60
|
"typescript": "^5.7.0"
|
|
55
61
|
},
|
|
62
|
+
"private": false,
|
|
56
63
|
"scripts": {
|
|
57
64
|
"build": "tsup",
|
|
58
65
|
"dev": "tsup --watch",
|