@arispay/payagent-mcp 3.0.0 → 3.1.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/README.md +1 -0
- package/dist/index.js +31 -1
- package/dist/index.js.map +1 -1
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -108,6 +108,7 @@ Or invoke directly via `npx @arispay/payagent-mcp` from an MCP client config —
|
|
|
108
108
|
## Related
|
|
109
109
|
|
|
110
110
|
- [payagent](https://www.npmjs.com/package/payagent) — the SDK for programmatic use
|
|
111
|
+
- [facilitator.arispay.app](https://facilitator.arispay.app) — ArisPay's open x402 facilitator (USDC + EURC on Base), where paid 402s settle
|
|
111
112
|
- [x402 protocol](https://github.com/coinbase/x402) — HTTP 402 payment standard
|
|
112
113
|
|
|
113
114
|
## License
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
launchAgent,
|
|
16
16
|
listAgents,
|
|
17
17
|
payFetchDelegated,
|
|
18
|
+
payFetchLocal,
|
|
18
19
|
renameStoredAgent,
|
|
19
20
|
syncAgents
|
|
20
21
|
} from "payagent";
|
|
@@ -370,12 +371,41 @@ server.tool(
|
|
|
370
371
|
agent: z.string().optional().describe("Optional name of a stored x402 payer agent.")
|
|
371
372
|
},
|
|
372
373
|
async ({ url, method, headers, body, agent }) => {
|
|
374
|
+
const localKey = process.env.PAYAGENT_PRIVATE_KEY;
|
|
375
|
+
if (localKey) {
|
|
376
|
+
try {
|
|
377
|
+
const fetch402 = payFetchLocal({ privateKey: localKey });
|
|
378
|
+
const response = await fetch402(url, { method, headers, body });
|
|
379
|
+
const responseBody = await response.text();
|
|
380
|
+
return textResult(
|
|
381
|
+
[
|
|
382
|
+
`HTTP ${response.status} (paid locally \u2014 permissionless mode, no server-enforced limits)`,
|
|
383
|
+
"",
|
|
384
|
+
responseBody
|
|
385
|
+
].join("\n")
|
|
386
|
+
);
|
|
387
|
+
} catch (err) {
|
|
388
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
389
|
+
if (looksLikeInsufficientFunds(message)) {
|
|
390
|
+
return textResult(
|
|
391
|
+
[
|
|
392
|
+
`Error: ${message}`,
|
|
393
|
+
"",
|
|
394
|
+
"The local wallet is out of USDC. Fund it on Base, or unset PAYAGENT_PRIVATE_KEY to use delegated custody."
|
|
395
|
+
].join("\n"),
|
|
396
|
+
true
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
return textResult(`Error: ${message}`, true);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
373
402
|
const stored = agent ? getAgent(agent) : listAgents()[0];
|
|
374
403
|
if (!stored?.apiKey) {
|
|
375
404
|
return textResult(
|
|
376
405
|
[
|
|
377
406
|
"No x402 payer agent available. For wallet-centric payments use pay_merchant.",
|
|
378
|
-
"To create an x402 agent, use create_agent({ name, perTx, daily, monthly })."
|
|
407
|
+
"To create an x402 agent, use create_agent({ name, perTx, daily, monthly }).",
|
|
408
|
+
"Or set PAYAGENT_PRIVATE_KEY to pay with a local key (permissionless mode \u2014 no ArisPay account)."
|
|
379
409
|
].join("\n"),
|
|
380
410
|
true
|
|
381
411
|
);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/pay-api-helpers.ts","../src/profile.ts"],"sourcesContent":["/**\n * payagent-mcp — MCP server for ArisPay's wallet-centric model.\n *\n * Core idea: the user has a master funding account and one or more\n * sub-wallets (spending profiles). Sub-wallets do NOT hold their own\n * on-chain keys; they draw from the user's FundingAccount when making\n * payments. The AI (Claude, Cursor, etc.) is the agent that operates the\n * sub-wallet on the user's behalf.\n *\n * Default tools:\n * - create_user({ email, name? }) — sign up + create master funding account\n * - create_wallet({ name, perTx, daily, monthly, allowedDomains? })\n * — create a sub-wallet / spending profile\n * - list_wallets() — list sub-wallets\n * - fund_wallet({ wallet, rail, amount? }) — fund the master wallet (europ via Schuman vIBAN,\n * card via hosted card-setup)\n * - get_balance({ wallet? }) — sub-wallet + master funding-account balances\n * - pay_merchant({ wallet, merchantUrl, amount, memo, merchantId?, currency? })\n * — pay from the master wallet via balance/card rail\n *\n * Advanced / x402 rail:\n * - pay_api(url, ...) — pay an x402-protected HTTP resource (Base USDC)\n * - create_agent(...) — provision an x402 payer with its own Base wallet\n * - list_agents() — list x402 payer agents\n * - fund_agent({ name }) — fund an x402 agent's Base wallet\n * - get_balance_agent({ name }) — on-chain USDC balance for an x402 agent\n *\n * Auth: developer bearer key from ~/.payagent/config.json or ARISPAY_API_KEY.\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);\nconst legacyAgentKey = process.env.ARISPAY_AGENT_KEY;\nconst legacyWalletAddress = process.env.PAYAGENT_WALLET;\n\n/** External id used to represent the developer user as their own EndUser/payer. */\nconst SELF_ENDUSER_EXTERNAL_ID = \"self\";\n\n/** Browser handoff host for EURØP / Schuman KYC. */\nconst buyformeUrl =\n process.env.BUYFORME_URL?.replace(/\\/$/, \"\") ?? \"https://buyforme.arispay.app\";\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// ── Wallet resolution ─────────────────────────────────\n\n/**\n * Resolve a locally-known sub-wallet name to its server-side wallet id.\n * Wallets are authoritative on the server; we look them up by name each time\n * so renaming on the server is always reflected immediately.\n */\nasync function resolveWallet(\n client: DelegationClient,\n name: string,\n): Promise<{ id: string; name: string } | undefined> {\n const list = await client.listWallets();\n return list.wallets.find((w) => w.name === name);\n}\n\n/**\n * Resolve the \"self\" EndUser id for the authenticated developer. This is the\n * payer record that owns the master FundingAccount.\n */\nasync function resolveSelfEndUserId(client: DelegationClient): Promise<string | undefined> {\n try {\n const user = await client.getEndUserByExternalId(SELF_ENDUSER_EXTERNAL_ID);\n return user.id;\n } catch {\n return undefined;\n }\n}\n\n// ── MCP Server ────────────────────────────────────────\n\nconst server = new McpServer({\n name: \"payagent\",\n version: \"3.0.0\",\n});\n\n// --- create_user ------------------------------------------------------------\n\nserver.tool(\n \"create_user\",\n \"Cold-start in one call: create an ArisPay user account plus the master funding account. Safe to re-run — it recovers the existing account instead of creating duplicates.\",\n {\n email: z.string().describe(\"Email for the new ArisPay account.\"),\n name: z.string().optional().describe(\"Human name. Falls back to the email local-part.\"),\n },\n async ({ email, name }) => {\n try {\n const result = await bootstrapAgent({\n email,\n name,\n arispayUrl: process.env.ARISPAY_URL,\n clientId: \"payagent-mcp-bootstrap\",\n });\n\n // Ensure the developer user has a self EndUser record so the master\n // FundingAccount can be provisioned.\n const devKey = getApiKey();\n if (devKey) {\n const client = new DelegationClient(arispayUrl, devKey);\n try {\n await client.createEndUser({\n externalId: SELF_ENDUSER_EXTERNAL_ID,\n email,\n findOrCreate: true,\n });\n } catch {\n // Best-effort; the wallets route will create it on demand if needed.\n }\n }\n\n const lines = [\n `✓ Account: ${result.email} (org \\`${result.orgName}\\`)`,\n `✓ Master funding account ready.`,\n \"\",\n \"Next steps:\",\n \" 1. create_wallet({ name: 'Daily', perTx, daily, monthly })\",\n \" 2. fund_wallet({ wallet: 'Daily', rail: 'europ' }) for SEPA / EURØP\", \n \" or fund_wallet({ wallet: 'Daily', rail: 'card' }) for card top-up.\",\n ];\n return textResult(lines.join(\"\\n\"));\n } catch (err) {\n if (err instanceof BootstrapError) {\n return textResult(`create_user failed (${err.code}): ${err.message}`, true);\n }\n return textResult(\n `create_user failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- create_wallet ----------------------------------------------------------\n\nserver.tool(\n \"create_wallet\",\n \"Create a sub-wallet / spending profile. Sub-wallets draw from the master funding account and enforce per-transaction, daily, and monthly spend limits.\",\n {\n name: z.string().describe(\"Human name for this sub-wallet, e.g. 'Daily' or 'Travel'.\"),\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 sub-wallet to paying only these domains.\"),\n },\n async ({ name, perTx, daily, monthly, allowedDomains }) => {\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const wallet = await client.createWallet({\n name,\n perTx,\n daily,\n monthly,\n allowedDomains,\n });\n const lines = [\n `✓ Sub-wallet \\`${wallet.name}\\` created.`,\n ` id: ${wallet.id}`,\n ` limits: ${wallet.limits.perTx ?? \"—\"}¢ / tx, ${wallet.limits.daily ?? \"—\"}¢ / day, ${wallet.limits.monthly ?? \"—\"}¢ / month`,\n \"\",\n `Fund it with fund_wallet({ wallet: \"${wallet.name}\", rail: \"europ\" | \"card\" }).`,\n ];\n return textResult(lines.join(\"\\n\"));\n } catch (err) {\n return textResult(\n `create_wallet failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- list_wallets -----------------------------------------------------------\n\nserver.tool(\n \"list_wallets\",\n \"List all sub-wallets under this account.\",\n {},\n async () => {\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const list = await client.listWallets();\n if (!list.wallets.length) {\n return textResult(\n \"No sub-wallets yet. Create one with create_wallet({ name, perTx, daily, monthly }).\",\n );\n }\n const lines = list.wallets.map((w) =>\n [\n `\\`${w.name}\\` (${w.id})`,\n ` status: ${w.status}`,\n ` limits: ${w.limits.perTx ?? \"—\"}¢ / tx, ${w.limits.daily ?? \"—\"}¢ / day, ${w.limits.monthly ?? \"—\"}¢ / month`,\n ` balance: ${w.balance} ${w.balanceCurrency}`,\n ].join(\"\\n\"),\n );\n return textResult(lines.join(\"\\n\\n\"));\n } catch (err) {\n return textResult(\n `list_wallets failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- fund_wallet ------------------------------------------------------------\n\nserver.tool(\n \"fund_wallet\",\n \"Add money to the master funding account so a sub-wallet can spend. rail='europ' opens the Schuman KYC / vIBAN flow in a browser; rail='card' mints a hosted card-setup URL.\",\n {\n wallet: z.string().describe(\"Name of a sub-wallet (used only for handoff context).\"),\n rail: z\n .enum([\"europ\", \"card\"])\n .describe(\"Funding rail: 'europ' for SEPA/EURØP, 'card' for debit/credit card.\"),\n amount: z.number().positive().optional().describe(\"Optional preset amount in dollars.\"),\n },\n async ({ wallet, rail, amount }) => {\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const resolved = await resolveWallet(client, wallet);\n if (!resolved) {\n return textResult(`No sub-wallet named \\`${wallet}\\`. Run list_wallets().`, true);\n }\n\n if (rail === \"europ\") {\n const handoffUrl = `${buyformeUrl}/onboarding/fund-europ?agentId=${encodeURIComponent(\n resolved.id,\n )}`;\n const lines = [\n `Fund the master wallet for \\`${wallet}\\` with EURØP via Schuman:`,\n \"\",\n ` ${handoffUrl}`,\n \"\",\n \"Open that link in a browser to:\",\n \" 1. Verify your identity with Schuman Financial (one-time KYC).\",\n \" 2. Receive a dedicated SEPA vIBAN.\",\n \" 3. Send EUR by bank transfer; Schuman mints EURØP once it clears.\",\n \"\",\n \"After the deposit clears, the master funding account is credited and this sub-wallet can spend.\",\n ];\n return textResult(lines.join(\"\\n\"));\n }\n\n // rail === 'card'\n const endUserId = await resolveSelfEndUserId(client);\n if (!endUserId) {\n return textResult(\n \"No payer record found. Run create_user first, then retry fund_wallet with rail='card'.\",\n true,\n );\n }\n const session = await client.createCardSetupSession({ endUserId });\n const lines = [\n `Add a card to fund the master wallet for \\`${wallet}\\`:`,\n \"\",\n ` ${session.setupUrl}`,\n \"\",\n ` Expires at: ${session.expiresAt}`,\n \"\",\n \"After the card is verified, you can top up. Card top-ups are not yet exposed via MCP; use the BuyForMe web app or the ArisPay dashboard for now.\",\n ];\n return textResult(lines.join(\"\\n\"));\n } catch (err) {\n return textResult(\n `fund_wallet failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- get_balance ------------------------------------------------------------\n\nserver.tool(\n \"get_balance\",\n \"Show the master funding-account balance(s) and a sub-wallet's spend limits. If no wallet is named, lists all sub-wallets.\",\n {\n wallet: z\n .string()\n .optional()\n .describe(\"Optional sub-wallet name. Omit to list all sub-wallets.\"),\n },\n async ({ wallet }) => {\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n\n if (!wallet) {\n const list = await client.listWallets();\n if (!list.wallets.length) {\n return textResult(\"No sub-wallets yet. Create one with create_wallet().\");\n }\n const lines = list.wallets.map((w) => {\n const lim = `limits: ${w.limits.perTx ?? \"—\"}¢ / tx, ${w.limits.daily ?? \"—\"}¢ / day, ${w.limits.monthly ?? \"—\"}¢ / month`;\n return `\\`${w.name}\\` — ${w.balance} ${w.balanceCurrency} — ${lim}`;\n });\n return textResult(lines.join(\"\\n\"));\n }\n\n const resolved = await resolveWallet(client, wallet);\n if (!resolved) {\n return textResult(`No sub-wallet named \\`${wallet}\\`.`, true);\n }\n\n const bal = await client.getWalletBalance(resolved.id);\n const lines = [\n `Sub-wallet: \\`${bal.wallet.name}\\``,\n ` status: ${bal.wallet.status}`,\n ` limits: ${bal.wallet.limits.perTx ?? \"—\"}¢ / tx, ${bal.wallet.limits.daily ?? \"—\"}¢ / day, ${bal.wallet.limits.monthly ?? \"—\"}¢ / month`,\n \"\",\n \"Master funding accounts:\",\n ];\n if (!bal.fundingAccounts.length) {\n lines.push(\" No funded accounts yet. Use fund_wallet() to add money.\");\n } else {\n for (const acct of bal.fundingAccounts) {\n lines.push(` ${acct.currency}: ${acct.balance}¢ (${acct.provider ?? \"internal\"})`);\n }\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// --- pay_merchant -----------------------------------------------------------\n\nserver.tool(\n \"pay_merchant\",\n \"Pay a merchant from the master wallet through a sub-wallet. For balance-rail payments (from FundingAccount), merchantId is required. For card-rail payments, the user must have a verified card on file.\",\n {\n wallet: z.string().describe(\"Name of the sub-wallet to spend through.\"),\n merchantUrl: z.string().describe(\"Canonical merchant URL for this payment.\"),\n amount: z.number().int().positive().describe(\"Amount in cents.\"),\n memo: z.string().describe(\"Human-readable memo, e.g. 'T-shirt from getwatta.com'.\"),\n merchantId: z\n .string()\n .optional()\n .describe(\"Required for balance-rail payments to a registered merchant.\"),\n currency: z.string().optional().describe(\"Currency code. Default: USD.\"),\n rail: z\n .enum([\"balance\", \"card\"])\n .optional()\n .describe(\"Force balance or card rail. Default: server picks based on available funding.\"),\n },\n async ({ wallet, merchantUrl, amount, memo, merchantId, currency, rail }) => {\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const resolved = await resolveWallet(client, wallet);\n if (!resolved) {\n return textResult(`No sub-wallet named \\`${wallet}\\`.`, true);\n }\n\n const endUserId = await resolveSelfEndUserId(client);\n if (!endUserId) {\n return textResult(\n \"No payer record found. Run create_user first, then retry the payment.\",\n true,\n );\n }\n\n const payment = await client.createPayment(resolved.id, {\n userId: endUserId,\n amount,\n currency: currency ?? \"USD\",\n memo,\n merchantUrl,\n merchantId,\n rail,\n });\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?.challengeUrl) {\n lines.push(` 3DS challenge URL: ${payment.nextAction.challengeUrl}`);\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// --- pay_api (advanced x402) ------------------------------------------------\n\nserver.tool(\n \"pay_api\",\n \"Advanced: make an HTTP request to an x402-protected API, paying with USDC on Base via delegated signing. This is a separate rail from the wallet-centric balance/card flows.\",\n {\n url: z.string().describe(\"The full URL of the API endpoint to call.\"),\n method: z.enum([\"GET\", \"POST\", \"PUT\", \"DELETE\", \"PATCH\"]).default(\"GET\"),\n headers: z.record(z.string(), z.string()).optional(),\n body: z.string().optional(),\n agent: z.string().optional().describe(\"Optional name of a stored x402 payer agent.\"),\n },\n async ({ url, method, headers, body, agent }) => {\n const stored = agent ? getAgent(agent) : listAgents()[0];\n if (!stored?.apiKey) {\n return textResult(\n [\n \"No x402 payer agent available. For wallet-centric payments use pay_merchant.\",\n \"To create an x402 agent, use create_agent({ name, perTx, daily, monthly }).\",\n ].join(\"\\n\"),\n true,\n );\n }\n try {\n let paymentInfo: DelegatedPaymentInfo | undefined;\n const fetch402 = payFetchDelegated({\n arispayUrl,\n apiKey: stored.apiKey,\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 \\`${stored.name}\\` — budget left: ${paymentInfo.remainingDaily}¢ today, ${paymentInfo.remainingMonthly}¢ this month)`\n : `HTTP ${response.status} (paid via \\`${stored.name}\\`)`;\n return textResult([statusLine, \"\", responseBody].join(\"\\n\"));\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n if (looksLikeInsufficientFunds(message)) {\n return textResult(\n [\n `Error: ${message}`,\n \"\",\n \"The x402 agent wallet is out of USDC. Fund it with fund_agent({ name }) or switch to wallet-centric pay_merchant.\",\n ].join(\"\\n\"),\n true,\n );\n }\n return textResult(`Error: ${message}`, true);\n }\n },\n);\n\n// --- create_agent (advanced x402) -------------------------------------------\n\nserver.tool(\n \"create_agent\",\n \"Advanced: provision an x402 payer agent with its own Base USDC wallet. Use create_wallet instead unless you specifically need to pay x402-protected HTTP resources.\",\n {\n name: z.string().describe(\"Local identifier for this x402 agent.\"),\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.array(z.string()).optional(),\n network: z.enum([\"base\", \"base-sepolia\", \"ethereum\", \"polygon\"]).default(\"base\"),\n agentType: z.string().optional(),\n },\n async ({ name, perTx, daily, monthly, allowedDomains, network, agentType }) => {\n try {\n requireDevKey();\n const agent = await launchAgent({\n name,\n limits: { perTx, daily, monthly },\n allowedDomains,\n network,\n agentType,\n });\n const lines = [\n `✓ x402 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_agent 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 (advanced x402) ---------------------------------------------\n\nserver.tool(\n \"fund_agent\",\n \"Advanced: get the USDC deposit address for an x402 payer agent.\",\n {\n name: z.string().describe(\"Name of a locally-stored x402 agent.\"),\n },\n async ({ name }) => {\n const stored = getAgent(name);\n if (!stored) return textResult(`No x402 agent named \\`${name}\\`.`, true);\n const lines = [\n `Fund x402 agent \\`${name}\\` by sending USDC on ${stored.network ?? \"base\"} to:`,\n \"\",\n ` ${stored.walletAddress}`,\n \"\",\n \"Only send USDC on the network shown above. Other tokens or networks may be lost.\",\n \"Call get_balance_agent when the deposit lands.\",\n ];\n return textResult(lines.join(\"\\n\"));\n },\n);\n\n// --- get_balance_agent (advanced x402) --------------------------------------\n\nserver.tool(\n \"get_balance_agent\",\n \"Advanced: on-chain USDC balance for an x402 payer agent.\",\n {\n name: z.string().describe(\"Name of a locally-stored x402 agent.\"),\n },\n async ({ name }) => {\n const stored = getAgent(name);\n if (!stored) return textResult(`No x402 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_agent failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- list_agents (advanced x402) --------------------------------------------\n\nserver.tool(\n \"list_agents\",\n \"Advanced: list x402 payer agents with on-chain wallets.\",\n {\n withBalance: z.boolean().optional().describe(\"Fetch on-chain USDC balance per agent.\"),\n },\n async ({ withBalance }) => {\n const devKey = getApiKey();\n if (!devKey) {\n return textResult(\"No developer key found. Run create_user or npx payagent init.\");\n }\n try {\n const result = await syncAgents({ includeBalance: withBalance === true });\n if (!result.agents.length) {\n return textResult(\"No x402 agents found. Use create_agent to provision one.\");\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 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 ...(balanceLine ? [balanceLine] : []),\n ].join(\"\\n\");\n });\n return textResult(lines.join(\"\\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 (advanced x402) -------------------------------------------\n\nserver.tool(\n \"rename_agent\",\n \"Advanced: rename an x402 payer agent.\",\n {\n name: z.string().describe(\"Current local name of the x402 agent.\"),\n newName: z.string().describe(\"New name.\"),\n },\n async ({ name, newName }) => {\n if (name === newName) {\n return textResult(`Agent \\`${name}\\` already has that name.`);\n }\n const stored = getAgent(name);\n if (!stored) {\n return textResult(`No x402 agent named \\`${name}\\`.`, true);\n }\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const result = await client.renameAgent(stored.agentId, newName);\n renameStoredAgent(name, result.name);\n return textResult(`✓ Renamed \\`${name}\\` → \\`${result.name}\\`.`);\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// --- Platform (end-user) tools ----------------------------------------------\n//\n// Skipped under PAYAGENT_MCP_PROFILE=core.\nif (platformToolsEnabled()) {\n server.tool(\n \"create_enduser\",\n \"Platform mode: register an end-customer under your account.\",\n {\n externalId: z.string().describe(\"Your own stable id for this customer.\"),\n email: z.string().optional(),\n findOrCreate: z.boolean().optional(),\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 return textResult(\n `✓ End-user \\`${externalId}\\` ready.\\n ArisPay id: ${user.id}\\n Has card: ${user.hasPaymentMethod ? \"yes\" : \"no\"}`,\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 server.tool(\n \"attach_card_for_user\",\n \"Platform mode: mint a hosted card-entry URL for an end-user.\",\n {\n userId: z.string().describe(\"ArisPay-internal end-user id.\"),\n agentName: z.string().optional().describe(\"Optional x402 agent name to scope the 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 return textResult(\n [`Card-entry URL:`, ` ${session.setupUrl}`, ` Expires at: ${session.expiresAt}`].join(\n \"\\n\",\n ),\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 server.tool(\n \"set_user_limits\",\n \"Platform mode: set per-(user, agent) spend caps.\",\n {\n userId: z.string(),\n agentName: z.string(),\n perTx: z.number().int().optional(),\n daily: z.number().int().optional(),\n monthly: z.number().int().optional(),\n allowedMcc: z.array(z.string()).optional(),\n blockedMcc: z.array(z.string()).optional(),\n },\n async ({ userId, agentName, perTx, daily, monthly, allowedMcc, blockedMcc }) => {\n try {\n const stored = getAgent(agentName);\n if (!stored) return textResult(`No x402 agent named \\`${agentName}\\`.`, true);\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 `✓ Limits set. per-tx ${limit.maxPerTransaction ?? \"inherit\"}¢, daily ${limit.maxDaily ?? \"inherit\"}¢, monthly ${limit.maxMonthly ?? \"inherit\"}¢`,\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 server.tool(\n \"get_user_status\",\n \"Platform mode: report an end-user's card and wallet readiness.\",\n {\n userId: z.string(),\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 ` card: ${user.hasPaymentMethod ? `${user.cardBrand ?? \"card\"} …${user.cardLast4 ?? \"????\"}` : \"—\"}`,\n ` wallet: ${user.walletAddress ?? \"—\"}${user.walletChain ? ` on ${user.walletChain}` : \"\"}`,\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\n// --- check_wallet (legacy diagnostic) ---------------------------------------\n\nserver.tool(\n \"check_wallet\",\n \"Legacy diagnostic for x402 payer agents. Use get_balance for wallet-centric balances.\",\n {\n agent: z.string().optional().describe(\"Optional name of a locally-stored x402 agent.\"),\n },\n async ({ agent }) => {\n const stored = agent ? getAgent(agent) : listAgents()[0];\n const walletAddress = stored?.walletAddress ?? legacyWalletAddress;\n const keyTail =\n stored?.apiKey.slice(-4) ?? (legacyAgentKey ? legacyAgentKey.slice(-4) : undefined);\n\n const lines = [`ArisPay URL: ${arispayUrl}`];\n if (stored) lines.push(`Agent: ${stored.name} (${stored.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, (stored?.network as \"base\") ?? \"base\");\n lines.push(`Balance: ${formatUSDC(raw)} USDC on ${stored?.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.\");\n }\n return textResult(lines.join(\"\\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":";;;AA6BA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EAEA;AAAA,EAGA;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;;;AC5BX,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;;;AFsCA,IAAM,aAAa,cAAc,QAAQ,IAAI,WAAW;AACxD,IAAM,iBAAiB,QAAQ,IAAI;AACnC,IAAM,sBAAsB,QAAQ,IAAI;AAGxC,IAAM,2BAA2B;AAGjC,IAAM,cACJ,QAAQ,IAAI,cAAc,QAAQ,OAAO,EAAE,KAAK;AAElD,SAAS,gBAAwB;AAC/B,QAAM,MAAM,UAAU;AACtB,MAAI,CAAC,KAAK;AACR,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,WAAW,MAAc,UAAU,OAAO;AACjD,SAAO;AAAA,IACL,SAAS,CAAC,EAAE,MAAM,QAAiB,KAAK,CAAC;AAAA,IACzC,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;AAAA,EAC/B;AACF;AASA,eAAe,cACb,QACA,MACmD;AACnD,QAAM,OAAO,MAAM,OAAO,YAAY;AACtC,SAAO,KAAK,QAAQ,KAAK,CAAC,MAAM,EAAE,SAAS,IAAI;AAC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,EAAE;AAC3C,QAAI,OAAQ,OAAM,KAAK,gBAAgB,OAAO,IAAI,KAAK,OAAO,OAAO,GAAG;AACxE,QAAI,QAAS,OAAM,KAAK,yBAAoB,OAAO,EAAE;AAErD,QAAI,eAAe;AACjB,YAAM,KAAK,gBAAgB,aAAa,EAAE;AAC1C,UAAI;AACF,cAAM,MAAM,MAAM,eAAe,eAAgB,QAAQ,WAAsB,MAAM;AACrF,cAAM,KAAK,gBAAgB,WAAW,GAAG,CAAC,YAAY,QAAQ,WAAW,MAAM,EAAE;AAAA,MACnF,SAAS,KAAK;AACZ,cAAM,KAAK,6BAA6B,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC,GAAG;AAAA,MAC7F;AAAA,IACF,OAAO;AACL,YAAM,KAAK,IAAI,kBAAkB;AAAA,IACnC;AACA,WAAO,WAAW,MAAM,KAAK,IAAI,CAAC;AAAA,EACpC;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 ArisPay's wallet-centric model.\n *\n * Core idea: the user has a master funding account and one or more\n * sub-wallets (spending profiles). Sub-wallets do NOT hold their own\n * on-chain keys; they draw from the user's FundingAccount when making\n * payments. The AI (Claude, Cursor, etc.) is the agent that operates the\n * sub-wallet on the user's behalf.\n *\n * Default tools:\n * - create_user({ email, name? }) — sign up + create master funding account\n * - create_wallet({ name, perTx, daily, monthly, allowedDomains? })\n * — create a sub-wallet / spending profile\n * - list_wallets() — list sub-wallets\n * - fund_wallet({ wallet, rail, amount? }) — fund the master wallet (europ via Schuman vIBAN,\n * card via hosted card-setup)\n * - get_balance({ wallet? }) — sub-wallet + master funding-account balances\n * - pay_merchant({ wallet, merchantUrl, amount, memo, merchantId?, currency? })\n * — pay from the master wallet via balance/card rail\n *\n * Advanced / x402 rail:\n * - pay_api(url, ...) — pay an x402-protected HTTP resource (Base USDC)\n * - create_agent(...) — provision an x402 payer with its own Base wallet\n * - list_agents() — list x402 payer agents\n * - fund_agent({ name }) — fund an x402 agent's Base wallet\n * - get_balance_agent({ name }) — on-chain USDC balance for an x402 agent\n *\n * Auth: developer bearer key from ~/.payagent/config.json or ARISPAY_API_KEY.\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 payFetchLocal,\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);\nconst legacyAgentKey = process.env.ARISPAY_AGENT_KEY;\nconst legacyWalletAddress = process.env.PAYAGENT_WALLET;\n\n/** External id used to represent the developer user as their own EndUser/payer. */\nconst SELF_ENDUSER_EXTERNAL_ID = \"self\";\n\n/** Browser handoff host for EURØP / Schuman KYC. */\nconst buyformeUrl =\n process.env.BUYFORME_URL?.replace(/\\/$/, \"\") ?? \"https://buyforme.arispay.app\";\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// ── Wallet resolution ─────────────────────────────────\n\n/**\n * Resolve a locally-known sub-wallet name to its server-side wallet id.\n * Wallets are authoritative on the server; we look them up by name each time\n * so renaming on the server is always reflected immediately.\n */\nasync function resolveWallet(\n client: DelegationClient,\n name: string,\n): Promise<{ id: string; name: string } | undefined> {\n const list = await client.listWallets();\n return list.wallets.find((w) => w.name === name);\n}\n\n/**\n * Resolve the \"self\" EndUser id for the authenticated developer. This is the\n * payer record that owns the master FundingAccount.\n */\nasync function resolveSelfEndUserId(client: DelegationClient): Promise<string | undefined> {\n try {\n const user = await client.getEndUserByExternalId(SELF_ENDUSER_EXTERNAL_ID);\n return user.id;\n } catch {\n return undefined;\n }\n}\n\n// ── MCP Server ────────────────────────────────────────\n\nconst server = new McpServer({\n name: \"payagent\",\n version: \"3.0.0\",\n});\n\n// --- create_user ------------------------------------------------------------\n\nserver.tool(\n \"create_user\",\n \"Cold-start in one call: create an ArisPay user account plus the master funding account. Safe to re-run — it recovers the existing account instead of creating duplicates.\",\n {\n email: z.string().describe(\"Email for the new ArisPay account.\"),\n name: z.string().optional().describe(\"Human name. Falls back to the email local-part.\"),\n },\n async ({ email, name }) => {\n try {\n const result = await bootstrapAgent({\n email,\n name,\n arispayUrl: process.env.ARISPAY_URL,\n clientId: \"payagent-mcp-bootstrap\",\n });\n\n // Ensure the developer user has a self EndUser record so the master\n // FundingAccount can be provisioned.\n const devKey = getApiKey();\n if (devKey) {\n const client = new DelegationClient(arispayUrl, devKey);\n try {\n await client.createEndUser({\n externalId: SELF_ENDUSER_EXTERNAL_ID,\n email,\n findOrCreate: true,\n });\n } catch {\n // Best-effort; the wallets route will create it on demand if needed.\n }\n }\n\n const lines = [\n `✓ Account: ${result.email} (org \\`${result.orgName}\\`)`,\n `✓ Master funding account ready.`,\n \"\",\n \"Next steps:\",\n \" 1. create_wallet({ name: 'Daily', perTx, daily, monthly })\",\n \" 2. fund_wallet({ wallet: 'Daily', rail: 'europ' }) for SEPA / EURØP\", \n \" or fund_wallet({ wallet: 'Daily', rail: 'card' }) for card top-up.\",\n ];\n return textResult(lines.join(\"\\n\"));\n } catch (err) {\n if (err instanceof BootstrapError) {\n return textResult(`create_user failed (${err.code}): ${err.message}`, true);\n }\n return textResult(\n `create_user failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- create_wallet ----------------------------------------------------------\n\nserver.tool(\n \"create_wallet\",\n \"Create a sub-wallet / spending profile. Sub-wallets draw from the master funding account and enforce per-transaction, daily, and monthly spend limits.\",\n {\n name: z.string().describe(\"Human name for this sub-wallet, e.g. 'Daily' or 'Travel'.\"),\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 sub-wallet to paying only these domains.\"),\n },\n async ({ name, perTx, daily, monthly, allowedDomains }) => {\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const wallet = await client.createWallet({\n name,\n perTx,\n daily,\n monthly,\n allowedDomains,\n });\n const lines = [\n `✓ Sub-wallet \\`${wallet.name}\\` created.`,\n ` id: ${wallet.id}`,\n ` limits: ${wallet.limits.perTx ?? \"—\"}¢ / tx, ${wallet.limits.daily ?? \"—\"}¢ / day, ${wallet.limits.monthly ?? \"—\"}¢ / month`,\n \"\",\n `Fund it with fund_wallet({ wallet: \"${wallet.name}\", rail: \"europ\" | \"card\" }).`,\n ];\n return textResult(lines.join(\"\\n\"));\n } catch (err) {\n return textResult(\n `create_wallet failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- list_wallets -----------------------------------------------------------\n\nserver.tool(\n \"list_wallets\",\n \"List all sub-wallets under this account.\",\n {},\n async () => {\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const list = await client.listWallets();\n if (!list.wallets.length) {\n return textResult(\n \"No sub-wallets yet. Create one with create_wallet({ name, perTx, daily, monthly }).\",\n );\n }\n const lines = list.wallets.map((w) =>\n [\n `\\`${w.name}\\` (${w.id})`,\n ` status: ${w.status}`,\n ` limits: ${w.limits.perTx ?? \"—\"}¢ / tx, ${w.limits.daily ?? \"—\"}¢ / day, ${w.limits.monthly ?? \"—\"}¢ / month`,\n ` balance: ${w.balance} ${w.balanceCurrency}`,\n ].join(\"\\n\"),\n );\n return textResult(lines.join(\"\\n\\n\"));\n } catch (err) {\n return textResult(\n `list_wallets failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- fund_wallet ------------------------------------------------------------\n\nserver.tool(\n \"fund_wallet\",\n \"Add money to the master funding account so a sub-wallet can spend. rail='europ' opens the Schuman KYC / vIBAN flow in a browser; rail='card' mints a hosted card-setup URL.\",\n {\n wallet: z.string().describe(\"Name of a sub-wallet (used only for handoff context).\"),\n rail: z\n .enum([\"europ\", \"card\"])\n .describe(\"Funding rail: 'europ' for SEPA/EURØP, 'card' for debit/credit card.\"),\n amount: z.number().positive().optional().describe(\"Optional preset amount in dollars.\"),\n },\n async ({ wallet, rail, amount }) => {\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const resolved = await resolveWallet(client, wallet);\n if (!resolved) {\n return textResult(`No sub-wallet named \\`${wallet}\\`. Run list_wallets().`, true);\n }\n\n if (rail === \"europ\") {\n const handoffUrl = `${buyformeUrl}/onboarding/fund-europ?agentId=${encodeURIComponent(\n resolved.id,\n )}`;\n const lines = [\n `Fund the master wallet for \\`${wallet}\\` with EURØP via Schuman:`,\n \"\",\n ` ${handoffUrl}`,\n \"\",\n \"Open that link in a browser to:\",\n \" 1. Verify your identity with Schuman Financial (one-time KYC).\",\n \" 2. Receive a dedicated SEPA vIBAN.\",\n \" 3. Send EUR by bank transfer; Schuman mints EURØP once it clears.\",\n \"\",\n \"After the deposit clears, the master funding account is credited and this sub-wallet can spend.\",\n ];\n return textResult(lines.join(\"\\n\"));\n }\n\n // rail === 'card'\n const endUserId = await resolveSelfEndUserId(client);\n if (!endUserId) {\n return textResult(\n \"No payer record found. Run create_user first, then retry fund_wallet with rail='card'.\",\n true,\n );\n }\n const session = await client.createCardSetupSession({ endUserId });\n const lines = [\n `Add a card to fund the master wallet for \\`${wallet}\\`:`,\n \"\",\n ` ${session.setupUrl}`,\n \"\",\n ` Expires at: ${session.expiresAt}`,\n \"\",\n \"After the card is verified, you can top up. Card top-ups are not yet exposed via MCP; use the BuyForMe web app or the ArisPay dashboard for now.\",\n ];\n return textResult(lines.join(\"\\n\"));\n } catch (err) {\n return textResult(\n `fund_wallet failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- get_balance ------------------------------------------------------------\n\nserver.tool(\n \"get_balance\",\n \"Show the master funding-account balance(s) and a sub-wallet's spend limits. If no wallet is named, lists all sub-wallets.\",\n {\n wallet: z\n .string()\n .optional()\n .describe(\"Optional sub-wallet name. Omit to list all sub-wallets.\"),\n },\n async ({ wallet }) => {\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n\n if (!wallet) {\n const list = await client.listWallets();\n if (!list.wallets.length) {\n return textResult(\"No sub-wallets yet. Create one with create_wallet().\");\n }\n const lines = list.wallets.map((w) => {\n const lim = `limits: ${w.limits.perTx ?? \"—\"}¢ / tx, ${w.limits.daily ?? \"—\"}¢ / day, ${w.limits.monthly ?? \"—\"}¢ / month`;\n return `\\`${w.name}\\` — ${w.balance} ${w.balanceCurrency} — ${lim}`;\n });\n return textResult(lines.join(\"\\n\"));\n }\n\n const resolved = await resolveWallet(client, wallet);\n if (!resolved) {\n return textResult(`No sub-wallet named \\`${wallet}\\`.`, true);\n }\n\n const bal = await client.getWalletBalance(resolved.id);\n const lines = [\n `Sub-wallet: \\`${bal.wallet.name}\\``,\n ` status: ${bal.wallet.status}`,\n ` limits: ${bal.wallet.limits.perTx ?? \"—\"}¢ / tx, ${bal.wallet.limits.daily ?? \"—\"}¢ / day, ${bal.wallet.limits.monthly ?? \"—\"}¢ / month`,\n \"\",\n \"Master funding accounts:\",\n ];\n if (!bal.fundingAccounts.length) {\n lines.push(\" No funded accounts yet. Use fund_wallet() to add money.\");\n } else {\n for (const acct of bal.fundingAccounts) {\n lines.push(` ${acct.currency}: ${acct.balance}¢ (${acct.provider ?? \"internal\"})`);\n }\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// --- pay_merchant -----------------------------------------------------------\n\nserver.tool(\n \"pay_merchant\",\n \"Pay a merchant from the master wallet through a sub-wallet. For balance-rail payments (from FundingAccount), merchantId is required. For card-rail payments, the user must have a verified card on file.\",\n {\n wallet: z.string().describe(\"Name of the sub-wallet to spend through.\"),\n merchantUrl: z.string().describe(\"Canonical merchant URL for this payment.\"),\n amount: z.number().int().positive().describe(\"Amount in cents.\"),\n memo: z.string().describe(\"Human-readable memo, e.g. 'T-shirt from getwatta.com'.\"),\n merchantId: z\n .string()\n .optional()\n .describe(\"Required for balance-rail payments to a registered merchant.\"),\n currency: z.string().optional().describe(\"Currency code. Default: USD.\"),\n rail: z\n .enum([\"balance\", \"card\"])\n .optional()\n .describe(\"Force balance or card rail. Default: server picks based on available funding.\"),\n },\n async ({ wallet, merchantUrl, amount, memo, merchantId, currency, rail }) => {\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const resolved = await resolveWallet(client, wallet);\n if (!resolved) {\n return textResult(`No sub-wallet named \\`${wallet}\\`.`, true);\n }\n\n const endUserId = await resolveSelfEndUserId(client);\n if (!endUserId) {\n return textResult(\n \"No payer record found. Run create_user first, then retry the payment.\",\n true,\n );\n }\n\n const payment = await client.createPayment(resolved.id, {\n userId: endUserId,\n amount,\n currency: currency ?? \"USD\",\n memo,\n merchantUrl,\n merchantId,\n rail,\n });\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?.challengeUrl) {\n lines.push(` 3DS challenge URL: ${payment.nextAction.challengeUrl}`);\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// --- pay_api (advanced x402) ------------------------------------------------\n\nserver.tool(\n \"pay_api\",\n \"Advanced: make an HTTP request to an x402-protected API, paying with USDC on Base via delegated signing. This is a separate rail from the wallet-centric balance/card flows.\",\n {\n url: z.string().describe(\"The full URL of the API endpoint to call.\"),\n method: z.enum([\"GET\", \"POST\", \"PUT\", \"DELETE\", \"PATCH\"]).default(\"GET\"),\n headers: z.record(z.string(), z.string()).optional(),\n body: z.string().optional(),\n agent: z.string().optional().describe(\"Optional name of a stored x402 payer agent.\"),\n },\n async ({ url, method, headers, body, agent }) => {\n // Permissionless mode: a local key signs in-process — no ArisPay\n // account, no stored agent, no server-enforced limits (mirrors the\n // payagent CLI's PAYAGENT_PRIVATE_KEY path).\n const localKey = process.env.PAYAGENT_PRIVATE_KEY;\n if (localKey) {\n try {\n const fetch402 = payFetchLocal({ privateKey: localKey });\n const response = await fetch402(url, { method, headers, body });\n const responseBody = await response.text();\n return textResult(\n [\n `HTTP ${response.status} (paid locally — permissionless mode, no server-enforced limits)`,\n \"\",\n responseBody,\n ].join(\"\\n\"),\n );\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n if (looksLikeInsufficientFunds(message)) {\n return textResult(\n [\n `Error: ${message}`,\n \"\",\n \"The local wallet is out of USDC. Fund it on Base, or unset PAYAGENT_PRIVATE_KEY to use delegated custody.\",\n ].join(\"\\n\"),\n true,\n );\n }\n return textResult(`Error: ${message}`, true);\n }\n }\n\n const stored = agent ? getAgent(agent) : listAgents()[0];\n if (!stored?.apiKey) {\n return textResult(\n [\n \"No x402 payer agent available. For wallet-centric payments use pay_merchant.\",\n \"To create an x402 agent, use create_agent({ name, perTx, daily, monthly }).\",\n \"Or set PAYAGENT_PRIVATE_KEY to pay with a local key (permissionless mode — no ArisPay account).\",\n ].join(\"\\n\"),\n true,\n );\n }\n try {\n let paymentInfo: DelegatedPaymentInfo | undefined;\n const fetch402 = payFetchDelegated({\n arispayUrl,\n apiKey: stored.apiKey,\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 \\`${stored.name}\\` — budget left: ${paymentInfo.remainingDaily}¢ today, ${paymentInfo.remainingMonthly}¢ this month)`\n : `HTTP ${response.status} (paid via \\`${stored.name}\\`)`;\n return textResult([statusLine, \"\", responseBody].join(\"\\n\"));\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n if (looksLikeInsufficientFunds(message)) {\n return textResult(\n [\n `Error: ${message}`,\n \"\",\n \"The x402 agent wallet is out of USDC. Fund it with fund_agent({ name }) or switch to wallet-centric pay_merchant.\",\n ].join(\"\\n\"),\n true,\n );\n }\n return textResult(`Error: ${message}`, true);\n }\n },\n);\n\n// --- create_agent (advanced x402) -------------------------------------------\n\nserver.tool(\n \"create_agent\",\n \"Advanced: provision an x402 payer agent with its own Base USDC wallet. Use create_wallet instead unless you specifically need to pay x402-protected HTTP resources.\",\n {\n name: z.string().describe(\"Local identifier for this x402 agent.\"),\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.array(z.string()).optional(),\n network: z.enum([\"base\", \"base-sepolia\", \"ethereum\", \"polygon\"]).default(\"base\"),\n agentType: z.string().optional(),\n },\n async ({ name, perTx, daily, monthly, allowedDomains, network, agentType }) => {\n try {\n requireDevKey();\n const agent = await launchAgent({\n name,\n limits: { perTx, daily, monthly },\n allowedDomains,\n network,\n agentType,\n });\n const lines = [\n `✓ x402 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_agent 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 (advanced x402) ---------------------------------------------\n\nserver.tool(\n \"fund_agent\",\n \"Advanced: get the USDC deposit address for an x402 payer agent.\",\n {\n name: z.string().describe(\"Name of a locally-stored x402 agent.\"),\n },\n async ({ name }) => {\n const stored = getAgent(name);\n if (!stored) return textResult(`No x402 agent named \\`${name}\\`.`, true);\n const lines = [\n `Fund x402 agent \\`${name}\\` by sending USDC on ${stored.network ?? \"base\"} to:`,\n \"\",\n ` ${stored.walletAddress}`,\n \"\",\n \"Only send USDC on the network shown above. Other tokens or networks may be lost.\",\n \"Call get_balance_agent when the deposit lands.\",\n ];\n return textResult(lines.join(\"\\n\"));\n },\n);\n\n// --- get_balance_agent (advanced x402) --------------------------------------\n\nserver.tool(\n \"get_balance_agent\",\n \"Advanced: on-chain USDC balance for an x402 payer agent.\",\n {\n name: z.string().describe(\"Name of a locally-stored x402 agent.\"),\n },\n async ({ name }) => {\n const stored = getAgent(name);\n if (!stored) return textResult(`No x402 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_agent failed: ${err instanceof Error ? err.message : String(err)}`,\n true,\n );\n }\n },\n);\n\n// --- list_agents (advanced x402) --------------------------------------------\n\nserver.tool(\n \"list_agents\",\n \"Advanced: list x402 payer agents with on-chain wallets.\",\n {\n withBalance: z.boolean().optional().describe(\"Fetch on-chain USDC balance per agent.\"),\n },\n async ({ withBalance }) => {\n const devKey = getApiKey();\n if (!devKey) {\n return textResult(\"No developer key found. Run create_user or npx payagent init.\");\n }\n try {\n const result = await syncAgents({ includeBalance: withBalance === true });\n if (!result.agents.length) {\n return textResult(\"No x402 agents found. Use create_agent to provision one.\");\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 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 ...(balanceLine ? [balanceLine] : []),\n ].join(\"\\n\");\n });\n return textResult(lines.join(\"\\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 (advanced x402) -------------------------------------------\n\nserver.tool(\n \"rename_agent\",\n \"Advanced: rename an x402 payer agent.\",\n {\n name: z.string().describe(\"Current local name of the x402 agent.\"),\n newName: z.string().describe(\"New name.\"),\n },\n async ({ name, newName }) => {\n if (name === newName) {\n return textResult(`Agent \\`${name}\\` already has that name.`);\n }\n const stored = getAgent(name);\n if (!stored) {\n return textResult(`No x402 agent named \\`${name}\\`.`, true);\n }\n try {\n const devKey = requireDevKey();\n const client = new DelegationClient(arispayUrl, devKey);\n const result = await client.renameAgent(stored.agentId, newName);\n renameStoredAgent(name, result.name);\n return textResult(`✓ Renamed \\`${name}\\` → \\`${result.name}\\`.`);\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// --- Platform (end-user) tools ----------------------------------------------\n//\n// Skipped under PAYAGENT_MCP_PROFILE=core.\nif (platformToolsEnabled()) {\n server.tool(\n \"create_enduser\",\n \"Platform mode: register an end-customer under your account.\",\n {\n externalId: z.string().describe(\"Your own stable id for this customer.\"),\n email: z.string().optional(),\n findOrCreate: z.boolean().optional(),\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 return textResult(\n `✓ End-user \\`${externalId}\\` ready.\\n ArisPay id: ${user.id}\\n Has card: ${user.hasPaymentMethod ? \"yes\" : \"no\"}`,\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 server.tool(\n \"attach_card_for_user\",\n \"Platform mode: mint a hosted card-entry URL for an end-user.\",\n {\n userId: z.string().describe(\"ArisPay-internal end-user id.\"),\n agentName: z.string().optional().describe(\"Optional x402 agent name to scope the 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 return textResult(\n [`Card-entry URL:`, ` ${session.setupUrl}`, ` Expires at: ${session.expiresAt}`].join(\n \"\\n\",\n ),\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 server.tool(\n \"set_user_limits\",\n \"Platform mode: set per-(user, agent) spend caps.\",\n {\n userId: z.string(),\n agentName: z.string(),\n perTx: z.number().int().optional(),\n daily: z.number().int().optional(),\n monthly: z.number().int().optional(),\n allowedMcc: z.array(z.string()).optional(),\n blockedMcc: z.array(z.string()).optional(),\n },\n async ({ userId, agentName, perTx, daily, monthly, allowedMcc, blockedMcc }) => {\n try {\n const stored = getAgent(agentName);\n if (!stored) return textResult(`No x402 agent named \\`${agentName}\\`.`, true);\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 `✓ Limits set. per-tx ${limit.maxPerTransaction ?? \"inherit\"}¢, daily ${limit.maxDaily ?? \"inherit\"}¢, monthly ${limit.maxMonthly ?? \"inherit\"}¢`,\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 server.tool(\n \"get_user_status\",\n \"Platform mode: report an end-user's card and wallet readiness.\",\n {\n userId: z.string(),\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 ` card: ${user.hasPaymentMethod ? `${user.cardBrand ?? \"card\"} …${user.cardLast4 ?? \"????\"}` : \"—\"}`,\n ` wallet: ${user.walletAddress ?? \"—\"}${user.walletChain ? ` on ${user.walletChain}` : \"\"}`,\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\n// --- check_wallet (legacy diagnostic) ---------------------------------------\n\nserver.tool(\n \"check_wallet\",\n \"Legacy diagnostic for x402 payer agents. Use get_balance for wallet-centric balances.\",\n {\n agent: z.string().optional().describe(\"Optional name of a locally-stored x402 agent.\"),\n },\n async ({ agent }) => {\n const stored = agent ? getAgent(agent) : listAgents()[0];\n const walletAddress = stored?.walletAddress ?? legacyWalletAddress;\n const keyTail =\n stored?.apiKey.slice(-4) ?? (legacyAgentKey ? legacyAgentKey.slice(-4) : undefined);\n\n const lines = [`ArisPay URL: ${arispayUrl}`];\n if (stored) lines.push(`Agent: ${stored.name} (${stored.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, (stored?.network as \"base\") ?? \"base\");\n lines.push(`Balance: ${formatUSDC(raw)} USDC on ${stored?.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.\");\n }\n return textResult(lines.join(\"\\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":";;;AA6BA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EAEA;AAAA,EAGA;AAAA,EACA;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;;;AC7BX,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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M,EAAE,IAAI;AAE3E,UAAM,QAAQ,CAAC,gBAAgB,UAAU,EAAE;AAC3C,QAAI,OAAQ,OAAM,KAAK,gBAAgB,OAAO,IAAI,KAAK,OAAO,OAAO,GAAG;AACxE,QAAI,QAAS,OAAM,KAAK,yBAAoB,OAAO,EAAE;AAErD,QAAI,eAAe;AACjB,YAAM,KAAK,gBAAgB,aAAa,EAAE;AAC1C,UAAI;AACF,cAAM,MAAM,MAAM,eAAe,eAAgB,QAAQ,WAAsB,MAAM;AACrF,cAAM,KAAK,gBAAgB,WAAW,GAAG,CAAC,YAAY,QAAQ,WAAW,MAAM,EAAE;AAAA,MACnF,SAAS,KAAK;AACZ,cAAM,KAAK,6BAA6B,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC,GAAG;AAAA,MAC7F;AAAA,IACF,OAAO;AACL,YAAM,KAAK,IAAI,kBAAkB;AAAA,IACnC;AACA,WAAO,WAAW,MAAM,KAAK,IAAI,CAAC;AAAA,EACpC;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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arispay/payagent-mcp",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
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": {
|
|
@@ -15,6 +15,12 @@
|
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsup",
|
|
20
|
+
"dev": "tsup --watch",
|
|
21
|
+
"type-check": "tsc --noEmit",
|
|
22
|
+
"prepublishOnly": "npm run build"
|
|
23
|
+
},
|
|
18
24
|
"keywords": [
|
|
19
25
|
"arispay",
|
|
20
26
|
"mcp",
|
|
@@ -51,18 +57,13 @@
|
|
|
51
57
|
"homepage": "https://github.com/arispay-inc/ArisPay/tree/master/packages/payagent-mcp#readme",
|
|
52
58
|
"dependencies": {
|
|
53
59
|
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
54
|
-
"
|
|
55
|
-
"
|
|
60
|
+
"payagent": "workspace:^",
|
|
61
|
+
"zod": "^3.25.0"
|
|
56
62
|
},
|
|
57
63
|
"devDependencies": {
|
|
58
64
|
"@types/node": "^22.0.0",
|
|
59
65
|
"tsup": "^8.0.0",
|
|
60
66
|
"typescript": "^5.7.0"
|
|
61
67
|
},
|
|
62
|
-
"private": false
|
|
63
|
-
|
|
64
|
-
"build": "tsup",
|
|
65
|
-
"dev": "tsup --watch",
|
|
66
|
-
"type-check": "tsc --noEmit"
|
|
67
|
-
}
|
|
68
|
-
}
|
|
68
|
+
"private": false
|
|
69
|
+
}
|