@useagentpay/mcp-server 0.1.6 → 0.1.8

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 CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  MCP server for [AgentPay](https://github.com/kar69-96/useagentpay) — exposes the full payment lifecycle to any MCP-compatible AI host (Claude Desktop, Cursor, Claude Code, Windsurf).
4
4
 
5
- 8 tools, 3 resources, 3 prompts. Agents can propose purchases, wait for human approval, execute checkout, and retrieve receipts — all over the Model Context Protocol.
5
+ 9 tools, 3 resources, 3 prompts. Agents can propose purchases, wait for human approval, execute checkout, and retrieve receipts — all over the Model Context Protocol.
6
6
 
7
7
  ## Install & Setup
8
8
 
9
9
  ```bash
10
- npx agentpay init # creates agentpay/ folder with AGENT.md
11
- npx agentpay setup # opens browser to enter card, set budget & limits
10
+ npx -p @useagentpay/mcp-server agentpay init # creates agentpay/ folder with AGENT.md
11
+ npx -p @useagentpay/mcp-server agentpay setup # opens browser to enter card, set budget & limits
12
12
  ```
13
13
 
14
14
  ## Host Configuration
@@ -42,14 +42,39 @@ Add to your Claude Desktop, Cursor, or Claude Code config:
42
42
  }
43
43
  ```
44
44
 
45
+ ## Mobile Mode
46
+
47
+ Enable mobile mode to approve purchases from your phone via Cloudflare Tunnel. No Cloudflare account needed — requires `cloudflared` installed on the system.
48
+
49
+ ```bash
50
+ # Enable mobile mode
51
+ npx -p @useagentpay/mcp-server agentpay mobile on
52
+
53
+ # With notification (how the approval link reaches your phone)
54
+ npx -p @useagentpay/mcp-server agentpay mobile on --notify-command "your-send-command {{url}}"
55
+ npx -p @useagentpay/mcp-server agentpay mobile on --notify-webhook "https://hooks.example.com/notify"
56
+
57
+ # Disable mobile mode
58
+ npx -p @useagentpay/mcp-server agentpay mobile off
59
+ ```
60
+
61
+ When mobile mode is on, agents call `agentpay_request_mobile_approval` instead of opening the local dashboard. This starts a Cloudflare Quick Tunnel and sends a temporary HTTPS approval link to the configured notification endpoint.
62
+
63
+ ### Install cloudflared
64
+
65
+ - **macOS:** `brew install cloudflared`
66
+ - **Linux:** [Download](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/)
67
+ - **Windows:** `winget install Cloudflare.cloudflared`
68
+
45
69
  ## Tools
46
70
 
47
71
  | Tool | Description |
48
72
  |------|-------------|
49
- | `agentpay_status` | Check if setup is complete, balance, budget, pending count |
73
+ | `agentpay_status` | Check setup state, balance, budget, mobileMode, pending count |
50
74
  | `agentpay_check_balance` | Current balance and limits (call before proposing) |
51
75
  | `agentpay_list_pending` | Pending transactions awaiting approval |
52
76
  | `agentpay_propose_purchase` | Propose a new purchase (merchant, amount, description, url) |
77
+ | `agentpay_request_mobile_approval` | Tunnel a secure approval link to the user's phone |
53
78
  | `agentpay_get_transaction` | Get transaction details by ID |
54
79
  | `agentpay_wait_for_approval` | Long-poll until approved or rejected |
55
80
  | `agentpay_execute_purchase` | Execute an approved purchase (requires passphrase config) |
@@ -74,12 +99,14 @@ Add to your Claude Desktop, Cursor, or Claude Code config:
74
99
  ## Typical Agent Flow
75
100
 
76
101
  ```
77
- 1. agentpay_status → verify setup is complete
78
- 2. agentpay_check_balance → confirm budget for purchase
79
- 3. agentpay_propose_purchase → create pending transaction
80
- 4. agentpay_wait_for_approval wait for human to approve
81
- 5. agentpay_execute_purchaserun checkout via headless browser
82
- 6. agentpay_get_receipt retrieve confirmation
102
+ 1. agentpay_status → verify setup, check mobileMode
103
+ 2. agentpay_check_balance → confirm budget for purchase
104
+ 3. agentpay_propose_purchase → create pending transaction
105
+ 4. agentpay_request_mobile_approval (if mobileMode: true) send link to phone
106
+ OR open dashboard (if mobileMode: false) open browser
107
+ 5. agentpay_wait_for_approval wait for human to approve
108
+ 6. agentpay_execute_purchase → run checkout via headless browser
109
+ 7. agentpay_get_receipt → retrieve confirmation
83
110
  ```
84
111
 
85
112
  ## Passphrase Modes
@@ -98,6 +125,8 @@ The `execute_purchase` tool needs access to the vault passphrase. Three modes:
98
125
  |----------|---------|---------|
99
126
  | `AGENTPAY_PASSPHRASE` | Passphrase for execute (env mode) | — |
100
127
  | `AGENTPAY_PASSPHRASE_SERVER` | URL to fetch passphrase (server mode) | — |
128
+ | `AGENTPAY_NOTIFY_COMMAND` | Override notify command for mobile mode | — |
129
+ | `AGENTPAY_NOTIFY_WEBHOOK` | Override notify webhook for mobile mode | — |
101
130
  | `ANTHROPIC_API_KEY` | LLM API key for browser navigation | — |
102
131
  | `AGENTPAY_HOME` | Override data directory | `./agentpay` |
103
132
  | `MCP_TRANSPORT` | Set to `http` for HTTP transport | `stdio` |
package/dist/cli.js CHANGED
@@ -24,20 +24,49 @@ function generateAgentMd() {
24
24
 
25
25
  You have access to AgentPay for making purchases on behalf of the user.
26
26
 
27
+ ## First-Time Setup
28
+
29
+ If \`agentpay_status\` returns \`isSetup: false\`, run this command yourself to open the browser for the human:
30
+
31
+ \`\`\`
32
+ npx -p @useagentpay/mcp-server agentpay setup
33
+ \`\`\`
34
+
35
+ The human fills in their card details, sets a budget, and creates a passphrase. Wait for them to finish before proceeding.
36
+
37
+ ## Mobile Mode
38
+
39
+ Check \`agentpay_status\` \u2014 if \`mobileMode: true\`, approval links are sent to the user's phone via Cloudflare Tunnel instead of opening a local browser.
40
+
41
+ To toggle mobile mode:
42
+ \`\`\`
43
+ npx -p @useagentpay/mcp-server agentpay mobile on
44
+ npx -p @useagentpay/mcp-server agentpay mobile off
45
+ \`\`\`
46
+
47
+ To set a notification method (how the approval link reaches the user's phone):
48
+ \`\`\`
49
+ npx -p @useagentpay/mcp-server agentpay mobile on --notify-command "your-command {{url}}"
50
+ npx -p @useagentpay/mcp-server agentpay mobile on --notify-webhook "https://hooks.example.com/notify"
51
+ \`\`\`
52
+
27
53
  ## Purchase Flow
28
54
 
29
55
  1. **Check balance** \u2014 call \`agentpay_check_balance\` before proposing
30
56
  2. **Propose** \u2014 call \`agentpay_propose_purchase\` with merchant, amount, description, and URL
31
- 3. **Open the dashboard** \u2014 run \`npx -p @useagentpay/mcp-server agentpay dashboard\` so the human can approve
57
+ 3. **Get approval** \u2014 check \`mobileMode\` in the response:
58
+ - **mobileMode: false** \u2014 run \`npx -p @useagentpay/mcp-server agentpay dashboard\` to open the browser for the human
59
+ - **mobileMode: true** \u2014 call \`agentpay_request_mobile_approval\` to tunnel a secure approval link to their phone
32
60
  4. **Wait** \u2014 call \`agentpay_wait_for_approval\` to poll until approved or rejected
33
61
  5. **Execute** \u2014 call \`agentpay_execute_purchase\` once approved
34
62
  6. **Receipt** \u2014 call \`agentpay_get_receipt\` and share the result with the human
35
63
 
36
64
  ## MCP Tools
37
65
 
38
- - \`agentpay_status\` \u2014 check setup state, balance, and budget
66
+ - \`agentpay_status\` \u2014 check setup state, balance, budget, and mobileMode
39
67
  - \`agentpay_check_balance\` \u2014 current balance and limits
40
68
  - \`agentpay_propose_purchase\` \u2014 propose a new purchase
69
+ - \`agentpay_request_mobile_approval\` \u2014 tunnel a secure approval link to the user's phone (mobile mode)
41
70
  - \`agentpay_wait_for_approval\` \u2014 poll until human approves or rejects
42
71
  - \`agentpay_execute_purchase\` \u2014 execute an approved purchase
43
72
  - \`agentpay_get_receipt\` \u2014 get receipt after purchase
@@ -62,6 +91,7 @@ After setup completes, these files are created in \`agentpay/\`:
62
91
  - \`credentials.enc\` \u2014 encrypted card and billing details
63
92
  - \`keys/\` \u2014 Ed25519 keypair for signing approvals
64
93
  - \`wallet.json\` \u2014 budget, per-transaction limit, and balance
94
+ - \`config.json\` \u2014 mobile mode and notification settings
65
95
  - \`transactions.json\` \u2014 purchase log
66
96
  - \`audit.log\` \u2014 action log
67
97
 
@@ -69,9 +99,11 @@ After setup completes, these files are created in \`agentpay/\`:
69
99
 
70
100
  - Always check balance before proposing
71
101
  - Never propose a purchase without a clear reason
72
- - Never skip the approval step \u2014 open the dashboard and wait
102
+ - Never skip the approval step \u2014 open the dashboard (or send mobile link) and wait
73
103
  - If rejected, respect the decision and suggest alternatives
74
104
  - You CANNOT modify budgets, spending limits, or credentials \u2014 open the dashboard for the human to do it
105
+ - Always run commands yourself (setup, dashboard, mobile) \u2014 never tell the human to open a terminal
106
+ - Check \`mobileMode\` from status to decide approval method \u2014 don't assume
75
107
  `;
76
108
  }
77
109
  var init_agent_md = __esm({
@@ -431,6 +463,51 @@ var init_dashboard = __esm({
431
463
  }
432
464
  });
433
465
 
466
+ // src/commands/mobile.ts
467
+ var mobile_exports = {};
468
+ __export(mobile_exports, {
469
+ mobileCommand: () => mobileCommand
470
+ });
471
+ import { loadConfig, saveConfig } from "@useagentpay/sdk";
472
+ function mobileCommand(mode, options) {
473
+ const enabled = mode === "on";
474
+ if (mode !== "on" && mode !== "off") {
475
+ console.error("Usage: agentpay mobile <on|off>");
476
+ process.exit(1);
477
+ }
478
+ const config = loadConfig();
479
+ config.mobileMode = enabled;
480
+ if (options.notifyCommand !== void 0) {
481
+ config.notifyCommand = options.notifyCommand;
482
+ }
483
+ if (options.notifyWebhook !== void 0) {
484
+ config.notifyWebhook = options.notifyWebhook;
485
+ }
486
+ saveConfig(config);
487
+ console.log(`Mobile approval mode: ${enabled ? "ON" : "OFF"}`);
488
+ if (enabled) {
489
+ console.log("Approval links will be tunneled via Cloudflare for mobile access.");
490
+ console.log("Requires cloudflared to be installed: https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/");
491
+ if (config.notifyCommand) {
492
+ console.log(`Notify command: ${config.notifyCommand}`);
493
+ }
494
+ if (config.notifyWebhook) {
495
+ console.log(`Notify webhook: ${config.notifyWebhook}`);
496
+ }
497
+ if (!config.notifyCommand && !config.notifyWebhook) {
498
+ console.log("\nTip: Set a notification method so you get the approval link on your phone:");
499
+ console.log(' agentpay mobile on --notify-command "open -g {{url}}"');
500
+ console.log(' agentpay mobile on --notify-webhook "https://hooks.example.com/notify"');
501
+ }
502
+ }
503
+ }
504
+ var init_mobile = __esm({
505
+ "src/commands/mobile.ts"() {
506
+ "use strict";
507
+ init_esm_shims();
508
+ }
509
+ });
510
+
434
511
  // src/errors.ts
435
512
  import {
436
513
  NotSetupError,
@@ -581,6 +658,8 @@ function registerProposeTool(server, ap) {
581
658
  async ({ merchant, amount, description, url }) => {
582
659
  try {
583
660
  const tx = ap.transactions.propose({ merchant, amount, description, url });
661
+ const { mobileMode } = ap.status();
662
+ const nextAction = mobileMode ? `Purchase proposed. Mobile mode is ON \u2014 call agentpay_request_mobile_approval with txId "${tx.id}" to send approval link to the user's phone. Then call agentpay_wait_for_approval.` : `Purchase proposed. Open the dashboard for the human to approve: npx -p @useagentpay/mcp-server agentpay dashboard \u2014 then call agentpay_wait_for_approval with txId "${tx.id}".`;
584
663
  return {
585
664
  content: [
586
665
  {
@@ -591,7 +670,8 @@ function registerProposeTool(server, ap) {
591
670
  status: tx.status,
592
671
  merchant: tx.merchant,
593
672
  amount: tx.amount,
594
- nextAction: `Purchase proposed. Open the dashboard for the human to approve: npx -p @useagentpay/mcp-server agentpay dashboard \u2014 then call agentpay_wait_for_approval with txId "${tx.id}".`
673
+ mobileMode,
674
+ nextAction
595
675
  })
596
676
  }
597
677
  ]
@@ -720,7 +800,7 @@ var init_transactions = __esm({
720
800
  });
721
801
 
722
802
  // src/config.ts
723
- function loadConfig(overrides) {
803
+ function loadConfig2(overrides) {
724
804
  const passphrase = process.env.AGENTPAY_PASSPHRASE;
725
805
  const passphraseServer = process.env.AGENTPAY_PASSPHRASE_SERVER;
726
806
  let passphraseMode = "none";
@@ -858,6 +938,51 @@ var init_receipt = __esm({
858
938
  }
859
939
  });
860
940
 
941
+ // src/tools/mobile-approve.ts
942
+ import { z as z5 } from "zod";
943
+ function registerMobileApproveTool(server, ap) {
944
+ server.tool(
945
+ "agentpay_request_mobile_approval",
946
+ "Send a mobile-friendly approval link to the user via Cloudflare Tunnel. Use this when mobileMode is ON. Requires cloudflared installed on the system.",
947
+ {
948
+ txId: z5.string().describe("Transaction ID of a pending purchase")
949
+ },
950
+ async ({ txId }) => {
951
+ try {
952
+ const cfg = ap.config.get();
953
+ const notify = {};
954
+ notify.command = process.env.AGENTPAY_NOTIFY_COMMAND ?? cfg.notifyCommand;
955
+ notify.webhookUrl = process.env.AGENTPAY_NOTIFY_WEBHOOK ?? cfg.notifyWebhook;
956
+ const result = await ap.transactions.requestMobileApproval(txId, notify);
957
+ return {
958
+ content: [
959
+ {
960
+ type: "text",
961
+ text: JSON.stringify({
962
+ success: true,
963
+ txId,
964
+ approvalUrl: result.approvalUrl,
965
+ notifyResults: result.notifyResults,
966
+ action: result.action,
967
+ nextAction: result.action === "approved" ? `Approved! Call agentpay_execute_purchase with txId "${txId}".` : `Rejected. ${result.reason ? `Reason: ${result.reason}` : "No reason given."}`
968
+ })
969
+ }
970
+ ]
971
+ };
972
+ } catch (err) {
973
+ return { content: [{ type: "text", text: JSON.stringify(mapError(err)) }] };
974
+ }
975
+ }
976
+ );
977
+ }
978
+ var init_mobile_approve = __esm({
979
+ "src/tools/mobile-approve.ts"() {
980
+ "use strict";
981
+ init_esm_shims();
982
+ init_errors();
983
+ }
984
+ });
985
+
861
986
  // src/tools/index.ts
862
987
  function registerTools(server, ap, config) {
863
988
  registerStatusTools(server, ap);
@@ -865,6 +990,7 @@ function registerTools(server, ap, config) {
865
990
  registerTransactionTools(server, ap);
866
991
  registerExecuteTool(server, ap, config);
867
992
  registerReceiptTool(server, ap);
993
+ registerMobileApproveTool(server, ap);
868
994
  }
869
995
  var init_tools = __esm({
870
996
  "src/tools/index.ts"() {
@@ -875,6 +1001,7 @@ var init_tools = __esm({
875
1001
  init_transactions();
876
1002
  init_execute();
877
1003
  init_receipt();
1004
+ init_mobile_approve();
878
1005
  }
879
1006
  });
880
1007
 
@@ -999,16 +1126,16 @@ var init_resources = __esm({
999
1126
  });
1000
1127
 
1001
1128
  // src/prompts/buy.ts
1002
- import { z as z5 } from "zod";
1129
+ import { z as z6 } from "zod";
1003
1130
  function registerBuyPrompt(server) {
1004
1131
  server.prompt(
1005
1132
  "buy",
1006
1133
  "Step-by-step purchase flow: check balance, propose, wait for approval, execute.",
1007
1134
  {
1008
- merchant: z5.string().describe("Merchant name"),
1009
- amount: z5.string().describe('Purchase amount in USD (e.g. "29.99")'),
1010
- description: z5.string().describe("What is being purchased"),
1011
- url: z5.string().describe("Product or checkout URL")
1135
+ merchant: z6.string().describe("Merchant name"),
1136
+ amount: z6.string().describe('Purchase amount in USD (e.g. "29.99")'),
1137
+ description: z6.string().describe("What is being purchased"),
1138
+ url: z6.string().describe("Product or checkout URL")
1012
1139
  },
1013
1140
  async ({ merchant, amount, description, url }) => ({
1014
1141
  messages: [
@@ -1084,13 +1211,13 @@ var init_budget_check = __esm({
1084
1211
  });
1085
1212
 
1086
1213
  // src/prompts/purchase-status.ts
1087
- import { z as z6 } from "zod";
1214
+ import { z as z7 } from "zod";
1088
1215
  function registerPurchaseStatusPrompt(server) {
1089
1216
  server.prompt(
1090
1217
  "purchase-status",
1091
1218
  "Review recent transactions and their receipts.",
1092
1219
  {
1093
- limit: z6.string().optional().describe("Number of recent transactions to show (default 5)")
1220
+ limit: z7.string().optional().describe("Number of recent transactions to show (default 5)")
1094
1221
  },
1095
1222
  async ({ limit }) => ({
1096
1223
  messages: [
@@ -1145,7 +1272,7 @@ import { AgentPay as AgentPay3 } from "@useagentpay/sdk";
1145
1272
  function createServer(config) {
1146
1273
  const server = new McpServer({
1147
1274
  name: "agentpay",
1148
- version: true ? "0.1.6" : "0.0.0"
1275
+ version: true ? "0.1.8" : "0.0.0"
1149
1276
  });
1150
1277
  const ap = new AgentPay3({
1151
1278
  home: config.home,
@@ -1171,7 +1298,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
1171
1298
  import { fileURLToPath as fileURLToPath2 } from "url";
1172
1299
  import { realpathSync } from "fs";
1173
1300
  async function startServer(overrides) {
1174
- const config = loadConfig(overrides);
1301
+ const config = loadConfig2(overrides);
1175
1302
  const server = createServer(config);
1176
1303
  if (config.http) {
1177
1304
  const { createServer: createHttpServer } = await import("http");
@@ -1246,7 +1373,7 @@ var init_serve = __esm({
1246
1373
  // src/cli.ts
1247
1374
  init_esm_shims();
1248
1375
  import { Command } from "commander";
1249
- var VERSION = true ? "0.1.6" : "0.0.0";
1376
+ var VERSION = true ? "0.1.8" : "0.0.0";
1250
1377
  var program = new Command();
1251
1378
  program.name("agentpay").description("AgentPay \u2013 MCP server & CLI for AI agent payments").version(VERSION);
1252
1379
  program.command("init").description("Initialize AgentPay in the current directory").action(async () => {
@@ -1293,6 +1420,10 @@ program.command("dashboard").description("Open the AgentPay dashboard in your br
1293
1420
  const { dashboardCommand: dashboardCommand2 } = await Promise.resolve().then(() => (init_dashboard(), dashboard_exports));
1294
1421
  await dashboardCommand2(options);
1295
1422
  });
1423
+ program.command("mobile <on|off>").description("Enable or disable mobile approval mode (Cloudflare Tunnel)").option("--notify-command <cmd>", "Shell command to send notification ({{url}} = approval link)").option("--notify-webhook <url>", "Webhook URL to POST approval payload to").action(async (mode, options) => {
1424
+ const { mobileCommand: mobileCommand2 } = await Promise.resolve().then(() => (init_mobile(), mobile_exports));
1425
+ mobileCommand2(mode, options);
1426
+ });
1296
1427
  program.command("serve").description("Start AgentPay MCP server").option("--http", "Use HTTP transport instead of stdio").action(async (options) => {
1297
1428
  const { serveCommand: serveCommand2 } = await Promise.resolve().then(() => (init_serve(), serve_exports));
1298
1429
  await serveCommand2(options);
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js","../src/templates/agent-md.ts","../src/commands/init.ts","../src/commands/setup.ts","../src/commands/budget.ts","../src/commands/pending.ts","../src/commands/propose.ts","../src/commands/approve.ts","../src/commands/reject.ts","../src/commands/status.ts","../src/commands/history.ts","../src/commands/reset.ts","../src/commands/dashboard.ts","../src/errors.ts","../src/tools/status.ts","../src/tools/propose.ts","../src/tools/transactions.ts","../src/config.ts","../src/tools/execute.ts","../src/tools/receipt.ts","../src/tools/index.ts","../src/resources/wallet.ts","../src/resources/transaction.ts","../src/resources/audit.ts","../src/resources/index.ts","../src/prompts/buy.ts","../src/prompts/budget-check.ts","../src/prompts/purchase-status.ts","../src/prompts/index.ts","../src/server.ts","../src/index.ts","../src/commands/serve.ts","../src/cli.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","export function generateAgentMd(): string {\n return `# AgentPay\n\nYou have access to AgentPay for making purchases on behalf of the user.\n\n## Purchase Flow\n\n1. **Check balance** — call \\`agentpay_check_balance\\` before proposing\n2. **Propose** — call \\`agentpay_propose_purchase\\` with merchant, amount, description, and URL\n3. **Open the dashboard** — run \\`npx -p @useagentpay/mcp-server agentpay dashboard\\` so the human can approve\n4. **Wait** — call \\`agentpay_wait_for_approval\\` to poll until approved or rejected\n5. **Execute** — call \\`agentpay_execute_purchase\\` once approved\n6. **Receipt** — call \\`agentpay_get_receipt\\` and share the result with the human\n\n## MCP Tools\n\n- \\`agentpay_status\\` — check setup state, balance, and budget\n- \\`agentpay_check_balance\\` — current balance and limits\n- \\`agentpay_propose_purchase\\` — propose a new purchase\n- \\`agentpay_wait_for_approval\\` — poll until human approves or rejects\n- \\`agentpay_execute_purchase\\` — execute an approved purchase\n- \\`agentpay_get_receipt\\` — get receipt after purchase\n- \\`agentpay_list_pending\\` — list pending proposals\n- \\`agentpay_get_transaction\\` — get transaction details\n\n## Dashboard — Human-Only Configuration\n\nBudget, spending limits, funds, and credentials can ONLY be changed through the browser dashboard. If the user wants to change any of these, open the dashboard for them:\n\n\\`\\`\\`\nnpx -p @useagentpay/mcp-server agentpay dashboard\n\\`\\`\\`\n\nIf AgentPay isn't set up yet, run setup for them:\n\n\\`\\`\\`\nnpx -p @useagentpay/mcp-server agentpay setup\n\\`\\`\\`\n\nAfter setup completes, these files are created in \\`agentpay/\\`:\n- \\`credentials.enc\\` — encrypted card and billing details\n- \\`keys/\\` — Ed25519 keypair for signing approvals\n- \\`wallet.json\\` — budget, per-transaction limit, and balance\n- \\`transactions.json\\` — purchase log\n- \\`audit.log\\` — action log\n\n## Rules\n\n- Always check balance before proposing\n- Never propose a purchase without a clear reason\n- Never skip the approval step — open the dashboard and wait\n- If rejected, respect the decision and suggest alternatives\n- You CANNOT modify budgets, spending limits, or credentials — open the dashboard for the human to do it\n`;\n}\n","import { mkdirSync, existsSync } from 'node:fs';\nimport { writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { generateAgentMd } from '../templates/agent-md.js';\n\nexport function initCommand(): void {\n const dir = join(process.cwd(), 'agentpay');\n\n if (existsSync(dir)) {\n console.log(`AgentPay already initialized at ${dir}`);\n return;\n }\n\n mkdirSync(dir, { recursive: true });\n writeFileSync(join(dir, 'AGENT.md'), generateAgentMd(), 'utf-8');\n\n console.log('AgentPay initialized. Run `agentpay setup` to add your payment credentials.');\n}\n","import { requestBrowserSetup } from '@useagentpay/sdk';\n\nexport async function setupCommand(): Promise<void> {\n console.log('AgentPay Setup');\n console.log('══════════════\\n');\n console.log('Opening setup form in browser...\\n');\n\n const result = await requestBrowserSetup();\n\n if (result.completed) {\n console.log('\\nSetup complete! Next steps:');\n console.log(' agentpay status Check your wallet');\n console.log(' agentpay budget View/adjust budget');\n }\n}\n","import { BudgetManager, formatCurrency } from '@useagentpay/sdk';\n\nexport function budgetCommand(): void {\n const bm = new BudgetManager();\n const balance = bm.getBalance();\n console.log(`Budget: ${formatCurrency(balance.budget)}`);\n console.log(`Balance: ${formatCurrency(balance.balance)}`);\n console.log(`Spent: ${formatCurrency(balance.spent)}`);\n console.log(`Per-tx limit: ${balance.limitPerTx > 0 ? formatCurrency(balance.limitPerTx) : 'None'}`);\n}\n","import { TransactionManager, formatCurrency } from '@useagentpay/sdk';\n\nexport function pendingCommand(): void {\n const tm = new TransactionManager();\n const pending = tm.getPending();\n\n if (pending.length === 0) {\n console.log('No pending purchases.');\n return;\n }\n\n console.log('Pending Purchases:');\n console.log('─────────────────');\n console.log('TX_ID MERCHANT AMOUNT DESCRIPTION');\n\n for (const tx of pending) {\n const id = tx.id.padEnd(14);\n const merchant = tx.merchant.padEnd(16);\n const amount = formatCurrency(tx.amount).padStart(9);\n console.log(`${id}${merchant}${amount} ${tx.description}`);\n }\n\n console.log(`\\n${pending.length} pending purchase${pending.length === 1 ? '' : 's'}. Use 'agentpay approve <txId>' or 'agentpay reject <txId>'.`);\n}\n","import {\n BudgetManager,\n TransactionManager,\n AuditLogger,\n formatCurrency,\n} from '@useagentpay/sdk';\n\ninterface ProposeOptions {\n merchant: string;\n amount: string;\n description: string;\n url: string;\n}\n\nexport function proposeCommand(options: ProposeOptions): void {\n const amount = parseFloat(options.amount);\n if (isNaN(amount) || amount <= 0) {\n console.error('Invalid amount. Must be a positive number.');\n process.exit(1);\n }\n\n const bm = new BudgetManager();\n const tm = new TransactionManager();\n const audit = new AuditLogger();\n\n try {\n bm.checkProposal(amount);\n } catch (err) {\n console.error(err instanceof Error ? err.message : 'Budget check failed.');\n process.exit(1);\n }\n\n const tx = tm.propose({\n merchant: options.merchant,\n amount,\n description: options.description,\n url: options.url,\n });\n audit.log('PROPOSE', { txId: tx.id, merchant: tx.merchant, amount: tx.amount, source: 'propose-command' });\n\n console.log('Transaction proposed');\n console.log('════════════════════\\n');\n console.log(` ID: ${tx.id}`);\n console.log(` Merchant: ${tx.merchant}`);\n console.log(` Amount: ${formatCurrency(tx.amount)}`);\n console.log(` Description: ${tx.description}`);\n console.log(` URL: ${options.url}`);\n console.log(` Status: ${tx.status}`);\n console.log();\n console.log(`Next step: agentpay approve ${tx.id}`);\n}\n","import {\n TransactionManager,\n AuditLogger,\n formatCurrency,\n requestBrowserApproval,\n} from '@useagentpay/sdk';\n\nexport async function approveCommand(txId: string): Promise<void> {\n const tm = new TransactionManager();\n const audit = new AuditLogger();\n\n const tx = tm.get(txId);\n if (!tx) {\n console.error(`Transaction ${txId} not found.`);\n process.exit(1);\n }\n if (tx.status !== 'pending') {\n console.error(`Cannot approve transaction in '${tx.status}' state.`);\n process.exit(1);\n }\n\n console.log(`Approve purchase:`);\n console.log(` Merchant: ${tx.merchant}`);\n console.log(` Amount: ${formatCurrency(tx.amount)}`);\n console.log(` Description: ${tx.description}`);\n console.log();\n\n const result = await requestBrowserApproval(tx, tm, audit);\n\n if (result.action === 'rejected') {\n console.log(`Purchase denied${result.reason ? ': ' + result.reason : '.'}`);\n process.exit(0);\n }\n\n console.log(`\\nApproved! Transaction ${txId} is now ready for execution.`);\n}\n","import { TransactionManager, AuditLogger } from '@useagentpay/sdk';\n\nexport function rejectCommand(txId: string, options: { reason?: string }): void {\n const tm = new TransactionManager();\n const audit = new AuditLogger();\n\n const tx = tm.get(txId);\n if (!tx) {\n console.error(`Transaction ${txId} not found.`);\n process.exit(1);\n }\n if (tx.status !== 'pending') {\n console.error(`Cannot reject transaction in '${tx.status}' state.`);\n process.exit(1);\n }\n\n tm.reject(txId, options.reason);\n audit.log('REJECT', { txId, reason: options.reason });\n\n console.log(`Rejected transaction ${txId}.${options.reason ? ` Reason: ${options.reason}` : ''}`);\n}\n","import { AgentPay, formatStatus } from '@useagentpay/sdk';\n\nexport function statusCommand(): void {\n const ap = new AgentPay();\n const s = ap.status();\n\n if (!s.isSetup) {\n console.log('AgentPay is not set up. Run `agentpay setup` first.');\n return;\n }\n\n console.log(formatStatus({\n balance: s.balance,\n budget: s.budget,\n limitPerTx: s.limitPerTx,\n pending: s.pending,\n recent: s.recent,\n }));\n}\n","import { TransactionManager, formatCurrency, formatTimestamp } from '@useagentpay/sdk';\n\nexport function historyCommand(): void {\n const tm = new TransactionManager();\n const history = tm.getHistory();\n\n if (history.length === 0) {\n console.log('No transaction history.');\n return;\n }\n\n console.log('Transaction History:');\n console.log('─────────────────────');\n console.log('STATUS TX_ID MERCHANT AMOUNT DATE DESCRIPTION');\n\n for (const tx of history) {\n const status = `[${tx.status}]`.padEnd(13);\n const id = tx.id.padEnd(14);\n const merchant = tx.merchant.padEnd(16);\n const amount = formatCurrency(tx.amount).padStart(9);\n const date = formatTimestamp(tx.createdAt).padEnd(18);\n console.log(`${status}${id}${merchant}${amount} ${date}${tx.description}`);\n }\n}\n","import { rmSync, existsSync } from 'node:fs';\nimport { getHomePath, promptInput } from '@useagentpay/sdk';\n\nexport async function resetCommand(): Promise<void> {\n const home = getHomePath();\n\n if (!existsSync(home)) {\n console.log('Nothing to reset. AgentPay data directory does not exist.');\n return;\n }\n\n console.log(`This will permanently delete all AgentPay data at: ${home}`);\n console.log('This includes encrypted credentials, keys, wallet, transactions, and audit logs.');\n const answer = await promptInput('\\nType YES to confirm: ');\n\n if (answer !== 'YES') {\n console.log('Cancelled.');\n return;\n }\n\n rmSync(home, { recursive: true, force: true });\n console.log('All AgentPay data has been deleted.');\n}\n","import { startDashboardServer, openBrowser } from '@useagentpay/sdk';\n\nexport async function dashboardCommand(options: { port: string }): Promise<void> {\n const port = parseInt(options.port, 10) || 3141;\n const url = `http://127.0.0.1:${port}`;\n\n try {\n const server = await startDashboardServer(port);\n\n console.log(`AgentPay Dashboard running at ${url}`);\n console.log('Press Ctrl+C to stop.\\n');\n\n openBrowser(url);\n\n const shutdown = () => {\n console.log('\\nShutting down dashboard...');\n server.close(() => process.exit(0));\n // Force exit after 3 seconds if connections linger\n setTimeout(() => process.exit(0), 3000);\n };\n\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n } catch (err) {\n const message = err instanceof Error ? err.message : 'Failed to start server';\n console.error(message);\n process.exit(1);\n }\n}\n","import {\n NotSetupError,\n DecryptError,\n InsufficientBalanceError,\n ExceedsTxLimitError,\n NotApprovedError,\n InvalidMandateError,\n AlreadyExecutedError,\n CheckoutFailedError,\n TimeoutError,\n} from '@useagentpay/sdk';\n\nexport interface ToolResult {\n success: boolean;\n error?: string;\n nextAction?: string;\n [key: string]: unknown;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst ERROR_MAP: Array<{\n type: new (...args: any[]) => Error;\n error: string;\n nextAction: string;\n}> = [\n { type: NotSetupError, error: 'NOT_SETUP', nextAction: 'STOP - Human must run: agentpay setup' },\n { type: InsufficientBalanceError, error: 'INSUFFICIENT_BALANCE', nextAction: 'STOP - Human must add budget' },\n { type: ExceedsTxLimitError, error: 'EXCEEDS_TX_LIMIT', nextAction: 'STOP - Human must increase limit' },\n { type: NotApprovedError, error: 'NOT_APPROVED', nextAction: 'WAIT - Needs approval first' },\n { type: InvalidMandateError, error: 'INVALID_MANDATE', nextAction: 'STOP - Security error' },\n { type: AlreadyExecutedError, error: 'ALREADY_EXECUTED', nextAction: 'STOP - Already processed' },\n { type: CheckoutFailedError, error: 'CHECKOUT_FAILED', nextAction: 'ERROR - Human should review' },\n { type: TimeoutError, error: 'TIMEOUT', nextAction: 'RETRY - Try again later' },\n { type: DecryptError, error: 'DECRYPT_FAILED', nextAction: 'STOP - Wrong passphrase' },\n];\n\nexport function mapError(err: unknown): ToolResult {\n if (err instanceof Error) {\n for (const mapping of ERROR_MAP) {\n if (err instanceof mapping.type) {\n return {\n success: false,\n error: mapping.error,\n message: err.message,\n nextAction: mapping.nextAction,\n };\n }\n }\n }\n\n return {\n success: false,\n error: 'UNKNOWN_ERROR',\n message: err instanceof Error ? err.message : String(err),\n };\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { mapError } from '../errors.js';\n\nexport function registerStatusTools(server: McpServer, ap: AgentPay) {\n server.tool(\n 'agentpay_status',\n 'Get AgentPay status: setup state, balance, budget, and pending transactions. Call this first.',\n {},\n async () => {\n try {\n const status = ap.status();\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n ...status,\n pendingCount: status.pending.length,\n nextAction: !status.isSetup\n ? 'STOP - Human must run: agentpay setup'\n : status.pending.length > 0\n ? 'Review pending transactions with agentpay_list_pending'\n : 'Ready for purchases. Use agentpay_check_balance before proposing.',\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n\n server.tool(\n 'agentpay_check_balance',\n 'Check current balance, budget, and per-transaction limit. Call BEFORE proposing a purchase.',\n {},\n async () => {\n try {\n const wallet = ap.wallet.getBalance();\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n ...wallet,\n nextAction:\n wallet.balance <= 0\n ? 'STOP - No balance remaining. Human must add budget.'\n : `Ready. Max single purchase: $${Math.min(wallet.balance, wallet.limitPerTx).toFixed(2)}`,\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n\n server.tool(\n 'agentpay_list_pending',\n 'List all pending transactions awaiting human approval.',\n {},\n async () => {\n try {\n const status = ap.status();\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n pending: status.pending,\n count: status.pending.length,\n nextAction:\n status.pending.length > 0\n ? 'Human must approve/reject via CLI. Use agentpay_wait_for_approval to poll.'\n : 'No pending transactions.',\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { mapError } from '../errors.js';\n\nexport function registerProposeTool(server: McpServer, ap: AgentPay) {\n server.tool(\n 'agentpay_propose_purchase',\n 'Propose a new purchase. Creates a pending transaction that requires human approval before execution.',\n {\n merchant: z.string().describe('Merchant name (e.g. \"Amazon\", \"Target\")'),\n amount: z.number().positive().describe('Purchase amount in USD'),\n description: z.string().describe('What is being purchased'),\n url: z.string().url().describe('Product or checkout URL'),\n },\n async ({ merchant, amount, description, url }) => {\n try {\n const tx = ap.transactions.propose({ merchant, amount, description, url });\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n txId: tx.id,\n status: tx.status,\n merchant: tx.merchant,\n amount: tx.amount,\n nextAction: `Purchase proposed. Open the dashboard for the human to approve: npx -p @useagentpay/mcp-server agentpay dashboard — then call agentpay_wait_for_approval with txId \"${tx.id}\".`,\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { mapError } from '../errors.js';\n\nfunction nextActionForStatus(status: string): string {\n switch (status) {\n case 'pending':\n return 'WAIT - Human must approve via CLI. Use agentpay_wait_for_approval to poll.';\n case 'approved':\n return 'READY - Use agentpay_execute_purchase to complete the purchase.';\n case 'rejected':\n return 'STOP - Transaction was rejected by human.';\n case 'executing':\n return 'WAIT - Purchase is being executed.';\n case 'completed':\n return 'DONE - Use agentpay_get_receipt for confirmation details.';\n case 'failed':\n return 'ERROR - Purchase failed. Human should review.';\n default:\n return 'Unknown status.';\n }\n}\n\nexport function registerTransactionTools(server: McpServer, ap: AgentPay) {\n server.tool(\n 'agentpay_get_transaction',\n 'Get the current status and details of a transaction.',\n {\n txId: z.string().describe('Transaction ID (e.g. \"tx_abc123\")'),\n },\n async ({ txId }) => {\n try {\n const tx = ap.transactions.get(txId);\n if (!tx) {\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: false,\n error: 'NOT_FOUND',\n message: `Transaction ${txId} not found.`,\n }),\n },\n ],\n };\n }\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n id: tx.id,\n status: tx.status,\n merchant: tx.merchant,\n amount: tx.amount,\n description: tx.description,\n url: tx.url,\n createdAt: tx.createdAt,\n nextAction: nextActionForStatus(tx.status),\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n\n server.tool(\n 'agentpay_wait_for_approval',\n 'Long-poll for human approval of a pending transaction. Blocks until approved, rejected, or timeout.',\n {\n txId: z.string().describe('Transaction ID to wait for'),\n pollInterval: z.number().positive().optional().describe('Poll interval in ms (default 2000)'),\n timeout: z.number().positive().optional().describe('Timeout in ms (default 300000 = 5 min)'),\n },\n async ({ txId, pollInterval, timeout }) => {\n try {\n const result = await ap.transactions.waitForApproval(txId, {\n pollInterval: pollInterval ?? 2000,\n timeout: timeout ?? 300000,\n });\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n txId,\n status: result.status,\n reason: result.reason,\n nextAction: nextActionForStatus(result.status),\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import type { ExecutorConfig } from '@useagentpay/sdk';\n\nexport interface ServerConfig {\n home?: string;\n passphrase?: string;\n passphraseServer?: string;\n passphraseMode: 'env' | 'server' | 'none';\n executor?: ExecutorConfig;\n http?: boolean;\n}\n\nexport function loadConfig(overrides?: { http?: boolean }): ServerConfig {\n const passphrase = process.env.AGENTPAY_PASSPHRASE;\n const passphraseServer = process.env.AGENTPAY_PASSPHRASE_SERVER;\n\n let passphraseMode: ServerConfig['passphraseMode'] = 'none';\n if (passphrase) passphraseMode = 'env';\n else if (passphraseServer) passphraseMode = 'server';\n\n // Default: local Chromium via Stagehand. Only modelApiKey needed for AI navigation.\n const executor: ExecutorConfig = {\n modelApiKey: process.env.ANTHROPIC_API_KEY,\n };\n\n return {\n home: process.env.AGENTPAY_HOME || undefined,\n passphrase,\n passphraseServer,\n passphraseMode,\n executor,\n http: overrides?.http ?? process.env.MCP_TRANSPORT === 'http',\n };\n}\n\nexport async function getPassphrase(config: ServerConfig): Promise<string> {\n if (config.passphraseMode === 'env' && config.passphrase) {\n return config.passphrase;\n }\n\n if (config.passphraseMode === 'server' && config.passphraseServer) {\n const res = await fetch(config.passphraseServer);\n if (!res.ok) throw new Error(`Passphrase server returned ${res.status}`);\n const body = await res.text();\n return body.trim();\n }\n\n throw new Error(\n 'No passphrase configured. Set AGENTPAY_PASSPHRASE or AGENTPAY_PASSPHRASE_SERVER to enable purchase execution.'\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { AgentPay } from '@useagentpay/sdk';\nimport type { ServerConfig } from '../config.js';\nimport { getPassphrase } from '../config.js';\nimport { mapError } from '../errors.js';\n\nexport function registerExecuteTool(server: McpServer, ap: AgentPay, config: ServerConfig) {\n server.tool(\n 'agentpay_execute_purchase',\n 'Execute an approved purchase. Requires passphrase config. Decrypts credentials and completes checkout via browser.',\n {\n txId: z.string().describe('Transaction ID of an approved purchase'),\n },\n async ({ txId }) => {\n try {\n const passphrase = await getPassphrase(config);\n\n // Create a temporary instance with passphrase for execution\n const execAp = new AgentPay({\n home: ap.home,\n passphrase,\n executor: config.executor,\n });\n\n const receipt = await execAp.transactions.execute(txId);\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n receipt,\n nextAction: 'DONE - Purchase completed. Use agentpay_get_receipt for details.',\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { mapError } from '../errors.js';\n\nexport function registerReceiptTool(server: McpServer, ap: AgentPay) {\n server.tool(\n 'agentpay_get_receipt',\n 'Get the receipt for a completed purchase.',\n {\n txId: z.string().describe('Transaction ID of a completed purchase'),\n },\n async ({ txId }) => {\n try {\n const receipt = ap.transactions.getReceipt(txId);\n if (!receipt) {\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: false,\n error: 'NO_RECEIPT',\n message: `No receipt found for transaction ${txId}. Transaction may not be completed yet.`,\n nextAction: 'Check transaction status with agentpay_get_transaction',\n }),\n },\n ],\n };\n }\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n receipt,\n nextAction: 'DONE - Purchase confirmed.',\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport type { ServerConfig } from '../config.js';\nimport { registerStatusTools } from './status.js';\nimport { registerProposeTool } from './propose.js';\nimport { registerTransactionTools } from './transactions.js';\nimport { registerExecuteTool } from './execute.js';\nimport { registerReceiptTool } from './receipt.js';\n\nexport function registerTools(server: McpServer, ap: AgentPay, config: ServerConfig) {\n registerStatusTools(server, ap);\n registerProposeTool(server, ap);\n registerTransactionTools(server, ap);\n registerExecuteTool(server, ap, config);\n registerReceiptTool(server, ap);\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\n\nexport function registerWalletResource(server: McpServer, ap: AgentPay) {\n server.resource('wallet', 'agentpay://wallet', async () => {\n try {\n const wallet = ap.wallet.getBalance();\n return {\n contents: [\n {\n uri: 'agentpay://wallet',\n mimeType: 'application/json',\n text: JSON.stringify(wallet, null, 2),\n },\n ],\n };\n } catch {\n return {\n contents: [\n {\n uri: 'agentpay://wallet',\n mimeType: 'application/json',\n text: JSON.stringify({ budget: 0, balance: 0, limitPerTx: 0, spent: 0 }),\n },\n ],\n };\n }\n });\n}\n","import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\n\nexport function registerTransactionResource(server: McpServer, ap: AgentPay) {\n server.resource(\n 'transaction',\n new ResourceTemplate('agentpay://transactions/{txId}', { list: undefined }),\n async (uri, { txId }) => {\n const tx = ap.transactions.get(txId as string);\n if (!tx) {\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify({ error: 'Transaction not found' }),\n },\n ],\n };\n }\n\n // Omit mandate internals for security\n const { mandate: _, ...safeTx } = tx;\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(safeTx, null, 2),\n },\n ],\n };\n }\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\n\nexport function registerAuditResource(server: McpServer, ap: AgentPay) {\n server.resource('audit-log', 'agentpay://audit-log', async () => {\n const lines = ap.audit.getLog();\n const last50 = lines.slice(-50);\n\n const entries = last50.map((line) => {\n const parts = line.split('\\t');\n return {\n timestamp: parts[0] ?? '',\n action: parts[1] ?? '',\n details: parts[2] ? JSON.parse(parts[2]) : {},\n };\n });\n\n return {\n contents: [\n {\n uri: 'agentpay://audit-log',\n mimeType: 'application/json',\n text: JSON.stringify(entries, null, 2),\n },\n ],\n };\n });\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { registerWalletResource } from './wallet.js';\nimport { registerTransactionResource } from './transaction.js';\nimport { registerAuditResource } from './audit.js';\n\nexport function registerResources(server: McpServer, ap: AgentPay) {\n registerWalletResource(server, ap);\n registerTransactionResource(server, ap);\n registerAuditResource(server, ap);\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerBuyPrompt(server: McpServer) {\n server.prompt(\n 'buy',\n 'Step-by-step purchase flow: check balance, propose, wait for approval, execute.',\n {\n merchant: z.string().describe('Merchant name'),\n amount: z.string().describe('Purchase amount in USD (e.g. \"29.99\")'),\n description: z.string().describe('What is being purchased'),\n url: z.string().describe('Product or checkout URL'),\n },\n async ({ merchant, amount, description, url }) => ({\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n `I need to purchase from ${merchant}.`,\n '',\n 'Follow these steps exactly:',\n '',\n '1. Call agentpay_check_balance to verify sufficient funds',\n `2. Call agentpay_propose_purchase with:`,\n ` - merchant: \"${merchant}\"`,\n ` - amount: ${amount}`,\n ` - description: \"${description}\"`,\n ` - url: \"${url}\"`,\n '3. Tell me the transaction ID and that I need to approve it',\n '4. Call agentpay_wait_for_approval with the transaction ID',\n '5. Once approved, call agentpay_execute_purchase',\n '6. Call agentpay_get_receipt to confirm',\n '',\n 'If any step fails, stop and explain what went wrong.',\n ].join('\\n'),\n },\n },\n ],\n })\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerBudgetCheckPrompt(server: McpServer) {\n server.prompt(\n 'budget-check',\n 'Check current balance, spending limits, and pending transactions.',\n {},\n async () => ({\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n 'Check my AgentPay budget status:',\n '',\n '1. Call agentpay_check_balance to get current balance and limits',\n '2. Call agentpay_list_pending to see any pending transactions',\n '3. Summarize:',\n ' - Available balance',\n ' - Per-transaction limit',\n ' - Total budget and amount spent',\n ' - Number of pending transactions (if any)',\n ].join('\\n'),\n },\n },\n ],\n })\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerPurchaseStatusPrompt(server: McpServer) {\n server.prompt(\n 'purchase-status',\n 'Review recent transactions and their receipts.',\n {\n limit: z.string().optional().describe('Number of recent transactions to show (default 5)'),\n },\n async ({ limit }) => ({\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n `Show me the status of my recent AgentPay transactions (last ${limit ?? '5'}):`,\n '',\n '1. Call agentpay_status to get recent transactions',\n '2. For each completed transaction, call agentpay_get_receipt',\n '3. Present a summary table with:',\n ' - Transaction ID',\n ' - Merchant',\n ' - Amount',\n ' - Status',\n ' - Confirmation ID (if completed)',\n ].join('\\n'),\n },\n },\n ],\n })\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { registerBuyPrompt } from './buy.js';\nimport { registerBudgetCheckPrompt } from './budget-check.js';\nimport { registerPurchaseStatusPrompt } from './purchase-status.js';\n\nexport function registerPrompts(server: McpServer) {\n registerBuyPrompt(server);\n registerBudgetCheckPrompt(server);\n registerPurchaseStatusPrompt(server);\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { AgentPay } from '@useagentpay/sdk';\nimport type { ServerConfig } from './config.js';\nimport { registerTools } from './tools/index.js';\nimport { registerResources } from './resources/index.js';\nimport { registerPrompts } from './prompts/index.js';\n\ndeclare const __PKG_VERSION__: string;\n\nexport function createServer(config: ServerConfig): McpServer {\n const server = new McpServer({\n name: 'agentpay',\n version: typeof __PKG_VERSION__ !== 'undefined' ? __PKG_VERSION__ : '0.0.0',\n });\n\n // Shared AgentPay instance (no passphrase — read-only by default)\n const ap = new AgentPay({\n home: config.home,\n executor: config.executor,\n });\n\n registerTools(server, ap, config);\n registerResources(server, ap);\n registerPrompts(server);\n\n return server;\n}\n","import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { fileURLToPath } from 'node:url';\nimport { realpathSync } from 'node:fs';\nimport { createServer } from './server.js';\nimport { loadConfig } from './config.js';\n\nexport { createServer } from './server.js';\nexport { loadConfig } from './config.js';\nexport type { ServerConfig } from './config.js';\n\nexport async function startServer(overrides?: { http?: boolean }) {\n const config = loadConfig(overrides);\n const server = createServer(config);\n\n if (config.http) {\n // Dynamic import to avoid loading HTTP deps when not needed\n const { createServer: createHttpServer } = await import('node:http');\n const { StreamableHTTPServerTransport } = await import(\n '@modelcontextprotocol/sdk/server/streamableHttp.js'\n );\n\n const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: () => crypto.randomUUID() });\n await server.connect(transport);\n\n const httpServer = createHttpServer((req, res) => {\n transport.handleRequest(req, res);\n });\n\n const port = parseInt(process.env.MCP_HTTP_PORT ?? '3100', 10);\n httpServer.listen(port, () => {\n console.error(`AgentPay MCP server listening on http://localhost:${port}`);\n });\n\n const shutdown = () => {\n httpServer.close();\n process.exit(0);\n };\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n } else {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n\n const shutdown = async () => {\n await server.close();\n process.exit(0);\n };\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n }\n}\n\n// Auto-start when run directly (handles npx, global install, and symlinks)\nlet isDirectRun = false;\ntry {\n const thisFile = fileURLToPath(import.meta.url);\n isDirectRun = !!process.argv[1] && realpathSync(process.argv[1]) === thisFile;\n} catch {\n // process.argv[1] doesn't exist or can't be resolved\n}\n\nif (isDirectRun) {\n const httpFlag = process.argv.includes('--http');\n startServer({ http: httpFlag }).catch((err) => {\n console.error('Failed to start MCP server:', err);\n process.exit(1);\n });\n}\n","import { startServer } from '../index.js';\n\nexport async function serveCommand(options: { http?: boolean }): Promise<void> {\n await startServer({ http: options.http });\n}\n","import { Command } from 'commander';\n\ndeclare const __PKG_VERSION__: string;\nconst VERSION = typeof __PKG_VERSION__ !== 'undefined' ? __PKG_VERSION__ : '0.0.0';\n\nconst program = new Command();\n\nprogram\n .name('agentpay')\n .description('AgentPay – MCP server & CLI for AI agent payments')\n .version(VERSION);\n\nprogram\n .command('init')\n .description('Initialize AgentPay in the current directory')\n .action(async () => {\n const { initCommand } = await import('./commands/init.js');\n initCommand();\n });\n\nprogram\n .command('setup')\n .description('Set up AgentPay with your billing credentials')\n .action(async () => {\n const { setupCommand } = await import('./commands/setup.js');\n await setupCommand();\n });\n\nprogram\n .command('budget')\n .description('View current spending budget (configure via dashboard)')\n .action(async () => {\n const { budgetCommand } = await import('./commands/budget.js');\n budgetCommand();\n });\n\nprogram\n .command('pending')\n .description('List pending purchase proposals')\n .action(async () => {\n const { pendingCommand } = await import('./commands/pending.js');\n pendingCommand();\n });\n\nprogram\n .command('propose')\n .description('Propose a purchase (creates a pending transaction)')\n .requiredOption('--merchant <name>', 'Merchant name')\n .requiredOption('--amount <amount>', 'Purchase amount in USD')\n .requiredOption('--description <desc>', 'Purchase description')\n .requiredOption('--url <url>', 'Product/checkout URL')\n .action(async (options: { merchant: string; amount: string; description: string; url: string }) => {\n const { proposeCommand } = await import('./commands/propose.js');\n proposeCommand(options);\n });\n\nprogram\n .command('approve <txId>')\n .description('Approve a pending purchase')\n .action(async (txId: string) => {\n const { approveCommand } = await import('./commands/approve.js');\n await approveCommand(txId);\n });\n\nprogram\n .command('reject <txId>')\n .description('Reject a pending purchase')\n .option('--reason <reason>', 'Reason for rejection')\n .action(async (txId: string, options: { reason?: string }) => {\n const { rejectCommand } = await import('./commands/reject.js');\n rejectCommand(txId, options);\n });\n\nprogram\n .command('status')\n .description('Show wallet status and recent transactions')\n .action(async () => {\n const { statusCommand } = await import('./commands/status.js');\n statusCommand();\n });\n\nprogram\n .command('history')\n .description('Show full transaction history')\n .action(async () => {\n const { historyCommand } = await import('./commands/history.js');\n historyCommand();\n });\n\nprogram\n .command('reset')\n .description('Delete all AgentPay data')\n .action(async () => {\n const { resetCommand } = await import('./commands/reset.js');\n await resetCommand();\n });\n\nprogram\n .command('dashboard')\n .description('Open the AgentPay dashboard in your browser')\n .option('--port <port>', 'Port for dashboard server', '3141')\n .action(async (options: { port: string }) => {\n const { dashboardCommand } = await import('./commands/dashboard.js');\n await dashboardCommand(options);\n });\n\nprogram\n .command('serve')\n .description('Start AgentPay MCP server')\n .option('--http', 'Use HTTP transport instead of stdio')\n .action(async (options: { http?: boolean }) => {\n const { serveCommand } = await import('./commands/serve.js');\n await serveCommand(options);\n });\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;AACA,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAF9B;AAAA;AAAA;AAAA;AAAA;;;ACAO,SAAS,kBAA0B;AACxC,SAAO;AAAA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O;AAC5B,CAAC;AAEH,QAAQ,MAAM;","names":["formatCurrency","BudgetManager","TransactionManager","formatCurrency","TransactionManager","AuditLogger","formatCurrency","TransactionManager","AuditLogger","TransactionManager","formatCurrency","existsSync","init_status","init_propose","z","z","AgentPay","z","init_status","init_propose","z","z","AgentPay","fileURLToPath","initCommand","setupCommand","budgetCommand","pendingCommand","proposeCommand","approveCommand","rejectCommand","statusCommand","historyCommand","resetCommand","dashboardCommand","serveCommand"]}
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/esm_shims.js","../src/templates/agent-md.ts","../src/commands/init.ts","../src/commands/setup.ts","../src/commands/budget.ts","../src/commands/pending.ts","../src/commands/propose.ts","../src/commands/approve.ts","../src/commands/reject.ts","../src/commands/status.ts","../src/commands/history.ts","../src/commands/reset.ts","../src/commands/dashboard.ts","../src/commands/mobile.ts","../src/errors.ts","../src/tools/status.ts","../src/tools/propose.ts","../src/tools/transactions.ts","../src/config.ts","../src/tools/execute.ts","../src/tools/receipt.ts","../src/tools/mobile-approve.ts","../src/tools/index.ts","../src/resources/wallet.ts","../src/resources/transaction.ts","../src/resources/audit.ts","../src/resources/index.ts","../src/prompts/buy.ts","../src/prompts/budget-check.ts","../src/prompts/purchase-status.ts","../src/prompts/index.ts","../src/server.ts","../src/index.ts","../src/commands/serve.ts","../src/cli.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","export function generateAgentMd(): string {\n return `# AgentPay\n\nYou have access to AgentPay for making purchases on behalf of the user.\n\n## First-Time Setup\n\nIf \\`agentpay_status\\` returns \\`isSetup: false\\`, run this command yourself to open the browser for the human:\n\n\\`\\`\\`\nnpx -p @useagentpay/mcp-server agentpay setup\n\\`\\`\\`\n\nThe human fills in their card details, sets a budget, and creates a passphrase. Wait for them to finish before proceeding.\n\n## Mobile Mode\n\nCheck \\`agentpay_status\\` — if \\`mobileMode: true\\`, approval links are sent to the user's phone via Cloudflare Tunnel instead of opening a local browser.\n\nTo toggle mobile mode:\n\\`\\`\\`\nnpx -p @useagentpay/mcp-server agentpay mobile on\nnpx -p @useagentpay/mcp-server agentpay mobile off\n\\`\\`\\`\n\nTo set a notification method (how the approval link reaches the user's phone):\n\\`\\`\\`\nnpx -p @useagentpay/mcp-server agentpay mobile on --notify-command \"your-command {{url}}\"\nnpx -p @useagentpay/mcp-server agentpay mobile on --notify-webhook \"https://hooks.example.com/notify\"\n\\`\\`\\`\n\n## Purchase Flow\n\n1. **Check balance** — call \\`agentpay_check_balance\\` before proposing\n2. **Propose** — call \\`agentpay_propose_purchase\\` with merchant, amount, description, and URL\n3. **Get approval** — check \\`mobileMode\\` in the response:\n - **mobileMode: false** — run \\`npx -p @useagentpay/mcp-server agentpay dashboard\\` to open the browser for the human\n - **mobileMode: true** — call \\`agentpay_request_mobile_approval\\` to tunnel a secure approval link to their phone\n4. **Wait** — call \\`agentpay_wait_for_approval\\` to poll until approved or rejected\n5. **Execute** — call \\`agentpay_execute_purchase\\` once approved\n6. **Receipt** — call \\`agentpay_get_receipt\\` and share the result with the human\n\n## MCP Tools\n\n- \\`agentpay_status\\` — check setup state, balance, budget, and mobileMode\n- \\`agentpay_check_balance\\` — current balance and limits\n- \\`agentpay_propose_purchase\\` — propose a new purchase\n- \\`agentpay_request_mobile_approval\\` — tunnel a secure approval link to the user's phone (mobile mode)\n- \\`agentpay_wait_for_approval\\` — poll until human approves or rejects\n- \\`agentpay_execute_purchase\\` — execute an approved purchase\n- \\`agentpay_get_receipt\\` — get receipt after purchase\n- \\`agentpay_list_pending\\` — list pending proposals\n- \\`agentpay_get_transaction\\` — get transaction details\n\n## Dashboard — Human-Only Configuration\n\nBudget, spending limits, funds, and credentials can ONLY be changed through the browser dashboard. If the user wants to change any of these, open the dashboard for them:\n\n\\`\\`\\`\nnpx -p @useagentpay/mcp-server agentpay dashboard\n\\`\\`\\`\n\nIf AgentPay isn't set up yet, run setup for them:\n\n\\`\\`\\`\nnpx -p @useagentpay/mcp-server agentpay setup\n\\`\\`\\`\n\nAfter setup completes, these files are created in \\`agentpay/\\`:\n- \\`credentials.enc\\` — encrypted card and billing details\n- \\`keys/\\` — Ed25519 keypair for signing approvals\n- \\`wallet.json\\` — budget, per-transaction limit, and balance\n- \\`config.json\\` — mobile mode and notification settings\n- \\`transactions.json\\` — purchase log\n- \\`audit.log\\` — action log\n\n## Rules\n\n- Always check balance before proposing\n- Never propose a purchase without a clear reason\n- Never skip the approval step — open the dashboard (or send mobile link) and wait\n- If rejected, respect the decision and suggest alternatives\n- You CANNOT modify budgets, spending limits, or credentials — open the dashboard for the human to do it\n- Always run commands yourself (setup, dashboard, mobile) — never tell the human to open a terminal\n- Check \\`mobileMode\\` from status to decide approval method — don't assume\n`;\n}\n","import { mkdirSync, existsSync } from 'node:fs';\nimport { writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { generateAgentMd } from '../templates/agent-md.js';\n\nexport function initCommand(): void {\n const dir = join(process.cwd(), 'agentpay');\n\n if (existsSync(dir)) {\n console.log(`AgentPay already initialized at ${dir}`);\n return;\n }\n\n mkdirSync(dir, { recursive: true });\n writeFileSync(join(dir, 'AGENT.md'), generateAgentMd(), 'utf-8');\n\n console.log('AgentPay initialized. Run `agentpay setup` to add your payment credentials.');\n}\n","import { requestBrowserSetup } from '@useagentpay/sdk';\n\nexport async function setupCommand(): Promise<void> {\n console.log('AgentPay Setup');\n console.log('══════════════\\n');\n console.log('Opening setup form in browser...\\n');\n\n const result = await requestBrowserSetup();\n\n if (result.completed) {\n console.log('\\nSetup complete! Next steps:');\n console.log(' agentpay status Check your wallet');\n console.log(' agentpay budget View/adjust budget');\n }\n}\n","import { BudgetManager, formatCurrency } from '@useagentpay/sdk';\n\nexport function budgetCommand(): void {\n const bm = new BudgetManager();\n const balance = bm.getBalance();\n console.log(`Budget: ${formatCurrency(balance.budget)}`);\n console.log(`Balance: ${formatCurrency(balance.balance)}`);\n console.log(`Spent: ${formatCurrency(balance.spent)}`);\n console.log(`Per-tx limit: ${balance.limitPerTx > 0 ? formatCurrency(balance.limitPerTx) : 'None'}`);\n}\n","import { TransactionManager, formatCurrency } from '@useagentpay/sdk';\n\nexport function pendingCommand(): void {\n const tm = new TransactionManager();\n const pending = tm.getPending();\n\n if (pending.length === 0) {\n console.log('No pending purchases.');\n return;\n }\n\n console.log('Pending Purchases:');\n console.log('─────────────────');\n console.log('TX_ID MERCHANT AMOUNT DESCRIPTION');\n\n for (const tx of pending) {\n const id = tx.id.padEnd(14);\n const merchant = tx.merchant.padEnd(16);\n const amount = formatCurrency(tx.amount).padStart(9);\n console.log(`${id}${merchant}${amount} ${tx.description}`);\n }\n\n console.log(`\\n${pending.length} pending purchase${pending.length === 1 ? '' : 's'}. Use 'agentpay approve <txId>' or 'agentpay reject <txId>'.`);\n}\n","import {\n BudgetManager,\n TransactionManager,\n AuditLogger,\n formatCurrency,\n} from '@useagentpay/sdk';\n\ninterface ProposeOptions {\n merchant: string;\n amount: string;\n description: string;\n url: string;\n}\n\nexport function proposeCommand(options: ProposeOptions): void {\n const amount = parseFloat(options.amount);\n if (isNaN(amount) || amount <= 0) {\n console.error('Invalid amount. Must be a positive number.');\n process.exit(1);\n }\n\n const bm = new BudgetManager();\n const tm = new TransactionManager();\n const audit = new AuditLogger();\n\n try {\n bm.checkProposal(amount);\n } catch (err) {\n console.error(err instanceof Error ? err.message : 'Budget check failed.');\n process.exit(1);\n }\n\n const tx = tm.propose({\n merchant: options.merchant,\n amount,\n description: options.description,\n url: options.url,\n });\n audit.log('PROPOSE', { txId: tx.id, merchant: tx.merchant, amount: tx.amount, source: 'propose-command' });\n\n console.log('Transaction proposed');\n console.log('════════════════════\\n');\n console.log(` ID: ${tx.id}`);\n console.log(` Merchant: ${tx.merchant}`);\n console.log(` Amount: ${formatCurrency(tx.amount)}`);\n console.log(` Description: ${tx.description}`);\n console.log(` URL: ${options.url}`);\n console.log(` Status: ${tx.status}`);\n console.log();\n console.log(`Next step: agentpay approve ${tx.id}`);\n}\n","import {\n TransactionManager,\n AuditLogger,\n formatCurrency,\n requestBrowserApproval,\n} from '@useagentpay/sdk';\n\nexport async function approveCommand(txId: string): Promise<void> {\n const tm = new TransactionManager();\n const audit = new AuditLogger();\n\n const tx = tm.get(txId);\n if (!tx) {\n console.error(`Transaction ${txId} not found.`);\n process.exit(1);\n }\n if (tx.status !== 'pending') {\n console.error(`Cannot approve transaction in '${tx.status}' state.`);\n process.exit(1);\n }\n\n console.log(`Approve purchase:`);\n console.log(` Merchant: ${tx.merchant}`);\n console.log(` Amount: ${formatCurrency(tx.amount)}`);\n console.log(` Description: ${tx.description}`);\n console.log();\n\n const result = await requestBrowserApproval(tx, tm, audit);\n\n if (result.action === 'rejected') {\n console.log(`Purchase denied${result.reason ? ': ' + result.reason : '.'}`);\n process.exit(0);\n }\n\n console.log(`\\nApproved! Transaction ${txId} is now ready for execution.`);\n}\n","import { TransactionManager, AuditLogger } from '@useagentpay/sdk';\n\nexport function rejectCommand(txId: string, options: { reason?: string }): void {\n const tm = new TransactionManager();\n const audit = new AuditLogger();\n\n const tx = tm.get(txId);\n if (!tx) {\n console.error(`Transaction ${txId} not found.`);\n process.exit(1);\n }\n if (tx.status !== 'pending') {\n console.error(`Cannot reject transaction in '${tx.status}' state.`);\n process.exit(1);\n }\n\n tm.reject(txId, options.reason);\n audit.log('REJECT', { txId, reason: options.reason });\n\n console.log(`Rejected transaction ${txId}.${options.reason ? ` Reason: ${options.reason}` : ''}`);\n}\n","import { AgentPay, formatStatus } from '@useagentpay/sdk';\n\nexport function statusCommand(): void {\n const ap = new AgentPay();\n const s = ap.status();\n\n if (!s.isSetup) {\n console.log('AgentPay is not set up. Run `agentpay setup` first.');\n return;\n }\n\n console.log(formatStatus({\n balance: s.balance,\n budget: s.budget,\n limitPerTx: s.limitPerTx,\n pending: s.pending,\n recent: s.recent,\n }));\n}\n","import { TransactionManager, formatCurrency, formatTimestamp } from '@useagentpay/sdk';\n\nexport function historyCommand(): void {\n const tm = new TransactionManager();\n const history = tm.getHistory();\n\n if (history.length === 0) {\n console.log('No transaction history.');\n return;\n }\n\n console.log('Transaction History:');\n console.log('─────────────────────');\n console.log('STATUS TX_ID MERCHANT AMOUNT DATE DESCRIPTION');\n\n for (const tx of history) {\n const status = `[${tx.status}]`.padEnd(13);\n const id = tx.id.padEnd(14);\n const merchant = tx.merchant.padEnd(16);\n const amount = formatCurrency(tx.amount).padStart(9);\n const date = formatTimestamp(tx.createdAt).padEnd(18);\n console.log(`${status}${id}${merchant}${amount} ${date}${tx.description}`);\n }\n}\n","import { rmSync, existsSync } from 'node:fs';\nimport { getHomePath, promptInput } from '@useagentpay/sdk';\n\nexport async function resetCommand(): Promise<void> {\n const home = getHomePath();\n\n if (!existsSync(home)) {\n console.log('Nothing to reset. AgentPay data directory does not exist.');\n return;\n }\n\n console.log(`This will permanently delete all AgentPay data at: ${home}`);\n console.log('This includes encrypted credentials, keys, wallet, transactions, and audit logs.');\n const answer = await promptInput('\\nType YES to confirm: ');\n\n if (answer !== 'YES') {\n console.log('Cancelled.');\n return;\n }\n\n rmSync(home, { recursive: true, force: true });\n console.log('All AgentPay data has been deleted.');\n}\n","import { startDashboardServer, openBrowser } from '@useagentpay/sdk';\n\nexport async function dashboardCommand(options: { port: string }): Promise<void> {\n const port = parseInt(options.port, 10) || 3141;\n const url = `http://127.0.0.1:${port}`;\n\n try {\n const server = await startDashboardServer(port);\n\n console.log(`AgentPay Dashboard running at ${url}`);\n console.log('Press Ctrl+C to stop.\\n');\n\n openBrowser(url);\n\n const shutdown = () => {\n console.log('\\nShutting down dashboard...');\n server.close(() => process.exit(0));\n // Force exit after 3 seconds if connections linger\n setTimeout(() => process.exit(0), 3000);\n };\n\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n } catch (err) {\n const message = err instanceof Error ? err.message : 'Failed to start server';\n console.error(message);\n process.exit(1);\n }\n}\n","import { loadConfig, saveConfig } from '@useagentpay/sdk';\n\nexport function mobileCommand(\n mode: string,\n options: { notifyCommand?: string; notifyWebhook?: string },\n): void {\n const enabled = mode === 'on';\n if (mode !== 'on' && mode !== 'off') {\n console.error('Usage: agentpay mobile <on|off>');\n process.exit(1);\n }\n\n const config = loadConfig();\n config.mobileMode = enabled;\n\n if (options.notifyCommand !== undefined) {\n config.notifyCommand = options.notifyCommand;\n }\n if (options.notifyWebhook !== undefined) {\n config.notifyWebhook = options.notifyWebhook;\n }\n\n saveConfig(config);\n\n console.log(`Mobile approval mode: ${enabled ? 'ON' : 'OFF'}`);\n if (enabled) {\n console.log('Approval links will be tunneled via Cloudflare for mobile access.');\n console.log('Requires cloudflared to be installed: https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/');\n if (config.notifyCommand) {\n console.log(`Notify command: ${config.notifyCommand}`);\n }\n if (config.notifyWebhook) {\n console.log(`Notify webhook: ${config.notifyWebhook}`);\n }\n if (!config.notifyCommand && !config.notifyWebhook) {\n console.log('\\nTip: Set a notification method so you get the approval link on your phone:');\n console.log(' agentpay mobile on --notify-command \"open -g {{url}}\"');\n console.log(' agentpay mobile on --notify-webhook \"https://hooks.example.com/notify\"');\n }\n }\n}\n","import {\n NotSetupError,\n DecryptError,\n InsufficientBalanceError,\n ExceedsTxLimitError,\n NotApprovedError,\n InvalidMandateError,\n AlreadyExecutedError,\n CheckoutFailedError,\n TimeoutError,\n} from '@useagentpay/sdk';\n\nexport interface ToolResult {\n success: boolean;\n error?: string;\n nextAction?: string;\n [key: string]: unknown;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst ERROR_MAP: Array<{\n type: new (...args: any[]) => Error;\n error: string;\n nextAction: string;\n}> = [\n { type: NotSetupError, error: 'NOT_SETUP', nextAction: 'STOP - Human must run: agentpay setup' },\n { type: InsufficientBalanceError, error: 'INSUFFICIENT_BALANCE', nextAction: 'STOP - Human must add budget' },\n { type: ExceedsTxLimitError, error: 'EXCEEDS_TX_LIMIT', nextAction: 'STOP - Human must increase limit' },\n { type: NotApprovedError, error: 'NOT_APPROVED', nextAction: 'WAIT - Needs approval first' },\n { type: InvalidMandateError, error: 'INVALID_MANDATE', nextAction: 'STOP - Security error' },\n { type: AlreadyExecutedError, error: 'ALREADY_EXECUTED', nextAction: 'STOP - Already processed' },\n { type: CheckoutFailedError, error: 'CHECKOUT_FAILED', nextAction: 'ERROR - Human should review' },\n { type: TimeoutError, error: 'TIMEOUT', nextAction: 'RETRY - Try again later' },\n { type: DecryptError, error: 'DECRYPT_FAILED', nextAction: 'STOP - Wrong passphrase' },\n];\n\nexport function mapError(err: unknown): ToolResult {\n if (err instanceof Error) {\n for (const mapping of ERROR_MAP) {\n if (err instanceof mapping.type) {\n return {\n success: false,\n error: mapping.error,\n message: err.message,\n nextAction: mapping.nextAction,\n };\n }\n }\n }\n\n return {\n success: false,\n error: 'UNKNOWN_ERROR',\n message: err instanceof Error ? err.message : String(err),\n };\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { mapError } from '../errors.js';\n\nexport function registerStatusTools(server: McpServer, ap: AgentPay) {\n server.tool(\n 'agentpay_status',\n 'Get AgentPay status: setup state, balance, budget, and pending transactions. Call this first.',\n {},\n async () => {\n try {\n const status = ap.status();\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n ...status,\n pendingCount: status.pending.length,\n nextAction: !status.isSetup\n ? 'STOP - Human must run: agentpay setup'\n : status.pending.length > 0\n ? 'Review pending transactions with agentpay_list_pending'\n : 'Ready for purchases. Use agentpay_check_balance before proposing.',\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n\n server.tool(\n 'agentpay_check_balance',\n 'Check current balance, budget, and per-transaction limit. Call BEFORE proposing a purchase.',\n {},\n async () => {\n try {\n const wallet = ap.wallet.getBalance();\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n ...wallet,\n nextAction:\n wallet.balance <= 0\n ? 'STOP - No balance remaining. Human must add budget.'\n : `Ready. Max single purchase: $${Math.min(wallet.balance, wallet.limitPerTx).toFixed(2)}`,\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n\n server.tool(\n 'agentpay_list_pending',\n 'List all pending transactions awaiting human approval.',\n {},\n async () => {\n try {\n const status = ap.status();\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n pending: status.pending,\n count: status.pending.length,\n nextAction:\n status.pending.length > 0\n ? 'Human must approve/reject via CLI. Use agentpay_wait_for_approval to poll.'\n : 'No pending transactions.',\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { mapError } from '../errors.js';\n\nexport function registerProposeTool(server: McpServer, ap: AgentPay) {\n server.tool(\n 'agentpay_propose_purchase',\n 'Propose a new purchase. Creates a pending transaction that requires human approval before execution.',\n {\n merchant: z.string().describe('Merchant name (e.g. \"Amazon\", \"Target\")'),\n amount: z.number().positive().describe('Purchase amount in USD'),\n description: z.string().describe('What is being purchased'),\n url: z.string().url().describe('Product or checkout URL'),\n },\n async ({ merchant, amount, description, url }) => {\n try {\n const tx = ap.transactions.propose({ merchant, amount, description, url });\n const { mobileMode } = ap.status();\n\n const nextAction = mobileMode\n ? `Purchase proposed. Mobile mode is ON — call agentpay_request_mobile_approval with txId \"${tx.id}\" to send approval link to the user's phone. Then call agentpay_wait_for_approval.`\n : `Purchase proposed. Open the dashboard for the human to approve: npx -p @useagentpay/mcp-server agentpay dashboard — then call agentpay_wait_for_approval with txId \"${tx.id}\".`;\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n txId: tx.id,\n status: tx.status,\n merchant: tx.merchant,\n amount: tx.amount,\n mobileMode,\n nextAction,\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { mapError } from '../errors.js';\n\nfunction nextActionForStatus(status: string): string {\n switch (status) {\n case 'pending':\n return 'WAIT - Human must approve via CLI. Use agentpay_wait_for_approval to poll.';\n case 'approved':\n return 'READY - Use agentpay_execute_purchase to complete the purchase.';\n case 'rejected':\n return 'STOP - Transaction was rejected by human.';\n case 'executing':\n return 'WAIT - Purchase is being executed.';\n case 'completed':\n return 'DONE - Use agentpay_get_receipt for confirmation details.';\n case 'failed':\n return 'ERROR - Purchase failed. Human should review.';\n default:\n return 'Unknown status.';\n }\n}\n\nexport function registerTransactionTools(server: McpServer, ap: AgentPay) {\n server.tool(\n 'agentpay_get_transaction',\n 'Get the current status and details of a transaction.',\n {\n txId: z.string().describe('Transaction ID (e.g. \"tx_abc123\")'),\n },\n async ({ txId }) => {\n try {\n const tx = ap.transactions.get(txId);\n if (!tx) {\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: false,\n error: 'NOT_FOUND',\n message: `Transaction ${txId} not found.`,\n }),\n },\n ],\n };\n }\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n id: tx.id,\n status: tx.status,\n merchant: tx.merchant,\n amount: tx.amount,\n description: tx.description,\n url: tx.url,\n createdAt: tx.createdAt,\n nextAction: nextActionForStatus(tx.status),\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n\n server.tool(\n 'agentpay_wait_for_approval',\n 'Long-poll for human approval of a pending transaction. Blocks until approved, rejected, or timeout.',\n {\n txId: z.string().describe('Transaction ID to wait for'),\n pollInterval: z.number().positive().optional().describe('Poll interval in ms (default 2000)'),\n timeout: z.number().positive().optional().describe('Timeout in ms (default 300000 = 5 min)'),\n },\n async ({ txId, pollInterval, timeout }) => {\n try {\n const result = await ap.transactions.waitForApproval(txId, {\n pollInterval: pollInterval ?? 2000,\n timeout: timeout ?? 300000,\n });\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n txId,\n status: result.status,\n reason: result.reason,\n nextAction: nextActionForStatus(result.status),\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import type { ExecutorConfig } from '@useagentpay/sdk';\n\nexport interface ServerConfig {\n home?: string;\n passphrase?: string;\n passphraseServer?: string;\n passphraseMode: 'env' | 'server' | 'none';\n executor?: ExecutorConfig;\n http?: boolean;\n}\n\nexport function loadConfig(overrides?: { http?: boolean }): ServerConfig {\n const passphrase = process.env.AGENTPAY_PASSPHRASE;\n const passphraseServer = process.env.AGENTPAY_PASSPHRASE_SERVER;\n\n let passphraseMode: ServerConfig['passphraseMode'] = 'none';\n if (passphrase) passphraseMode = 'env';\n else if (passphraseServer) passphraseMode = 'server';\n\n // Default: local Chromium via Stagehand. Only modelApiKey needed for AI navigation.\n const executor: ExecutorConfig = {\n modelApiKey: process.env.ANTHROPIC_API_KEY,\n };\n\n return {\n home: process.env.AGENTPAY_HOME || undefined,\n passphrase,\n passphraseServer,\n passphraseMode,\n executor,\n http: overrides?.http ?? process.env.MCP_TRANSPORT === 'http',\n };\n}\n\nexport async function getPassphrase(config: ServerConfig): Promise<string> {\n if (config.passphraseMode === 'env' && config.passphrase) {\n return config.passphrase;\n }\n\n if (config.passphraseMode === 'server' && config.passphraseServer) {\n const res = await fetch(config.passphraseServer);\n if (!res.ok) throw new Error(`Passphrase server returned ${res.status}`);\n const body = await res.text();\n return body.trim();\n }\n\n throw new Error(\n 'No passphrase configured. Set AGENTPAY_PASSPHRASE or AGENTPAY_PASSPHRASE_SERVER to enable purchase execution.'\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { AgentPay } from '@useagentpay/sdk';\nimport type { ServerConfig } from '../config.js';\nimport { getPassphrase } from '../config.js';\nimport { mapError } from '../errors.js';\n\nexport function registerExecuteTool(server: McpServer, ap: AgentPay, config: ServerConfig) {\n server.tool(\n 'agentpay_execute_purchase',\n 'Execute an approved purchase. Requires passphrase config. Decrypts credentials and completes checkout via browser.',\n {\n txId: z.string().describe('Transaction ID of an approved purchase'),\n },\n async ({ txId }) => {\n try {\n const passphrase = await getPassphrase(config);\n\n // Create a temporary instance with passphrase for execution\n const execAp = new AgentPay({\n home: ap.home,\n passphrase,\n executor: config.executor,\n });\n\n const receipt = await execAp.transactions.execute(txId);\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n receipt,\n nextAction: 'DONE - Purchase completed. Use agentpay_get_receipt for details.',\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { mapError } from '../errors.js';\n\nexport function registerReceiptTool(server: McpServer, ap: AgentPay) {\n server.tool(\n 'agentpay_get_receipt',\n 'Get the receipt for a completed purchase.',\n {\n txId: z.string().describe('Transaction ID of a completed purchase'),\n },\n async ({ txId }) => {\n try {\n const receipt = ap.transactions.getReceipt(txId);\n if (!receipt) {\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: false,\n error: 'NO_RECEIPT',\n message: `No receipt found for transaction ${txId}. Transaction may not be completed yet.`,\n nextAction: 'Check transaction status with agentpay_get_transaction',\n }),\n },\n ],\n };\n }\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n receipt,\n nextAction: 'DONE - Purchase confirmed.',\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { mapError } from '../errors.js';\n\nexport function registerMobileApproveTool(server: McpServer, ap: AgentPay) {\n server.tool(\n 'agentpay_request_mobile_approval',\n 'Send a mobile-friendly approval link to the user via Cloudflare Tunnel. Use this when mobileMode is ON. Requires cloudflared installed on the system.',\n {\n txId: z.string().describe('Transaction ID of a pending purchase'),\n },\n async ({ txId }) => {\n try {\n // Build notify options from config file, with env var overrides\n const cfg = ap.config.get();\n const notify: { command?: string; webhookUrl?: string } = {};\n notify.command = process.env.AGENTPAY_NOTIFY_COMMAND ?? cfg.notifyCommand;\n notify.webhookUrl = process.env.AGENTPAY_NOTIFY_WEBHOOK ?? cfg.notifyWebhook;\n\n const result = await ap.transactions.requestMobileApproval(txId, notify);\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n txId,\n approvalUrl: result.approvalUrl,\n notifyResults: result.notifyResults,\n action: result.action,\n nextAction: result.action === 'approved'\n ? `Approved! Call agentpay_execute_purchase with txId \"${txId}\".`\n : `Rejected. ${result.reason ? `Reason: ${result.reason}` : 'No reason given.'}`,\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport type { ServerConfig } from '../config.js';\nimport { registerStatusTools } from './status.js';\nimport { registerProposeTool } from './propose.js';\nimport { registerTransactionTools } from './transactions.js';\nimport { registerExecuteTool } from './execute.js';\nimport { registerReceiptTool } from './receipt.js';\nimport { registerMobileApproveTool } from './mobile-approve.js';\n\nexport function registerTools(server: McpServer, ap: AgentPay, config: ServerConfig) {\n registerStatusTools(server, ap);\n registerProposeTool(server, ap);\n registerTransactionTools(server, ap);\n registerExecuteTool(server, ap, config);\n registerReceiptTool(server, ap);\n registerMobileApproveTool(server, ap);\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\n\nexport function registerWalletResource(server: McpServer, ap: AgentPay) {\n server.resource('wallet', 'agentpay://wallet', async () => {\n try {\n const wallet = ap.wallet.getBalance();\n return {\n contents: [\n {\n uri: 'agentpay://wallet',\n mimeType: 'application/json',\n text: JSON.stringify(wallet, null, 2),\n },\n ],\n };\n } catch {\n return {\n contents: [\n {\n uri: 'agentpay://wallet',\n mimeType: 'application/json',\n text: JSON.stringify({ budget: 0, balance: 0, limitPerTx: 0, spent: 0 }),\n },\n ],\n };\n }\n });\n}\n","import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\n\nexport function registerTransactionResource(server: McpServer, ap: AgentPay) {\n server.resource(\n 'transaction',\n new ResourceTemplate('agentpay://transactions/{txId}', { list: undefined }),\n async (uri, { txId }) => {\n const tx = ap.transactions.get(txId as string);\n if (!tx) {\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify({ error: 'Transaction not found' }),\n },\n ],\n };\n }\n\n // Omit mandate internals for security\n const { mandate: _, ...safeTx } = tx;\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(safeTx, null, 2),\n },\n ],\n };\n }\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\n\nexport function registerAuditResource(server: McpServer, ap: AgentPay) {\n server.resource('audit-log', 'agentpay://audit-log', async () => {\n const lines = ap.audit.getLog();\n const last50 = lines.slice(-50);\n\n const entries = last50.map((line) => {\n const parts = line.split('\\t');\n return {\n timestamp: parts[0] ?? '',\n action: parts[1] ?? '',\n details: parts[2] ? JSON.parse(parts[2]) : {},\n };\n });\n\n return {\n contents: [\n {\n uri: 'agentpay://audit-log',\n mimeType: 'application/json',\n text: JSON.stringify(entries, null, 2),\n },\n ],\n };\n });\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { registerWalletResource } from './wallet.js';\nimport { registerTransactionResource } from './transaction.js';\nimport { registerAuditResource } from './audit.js';\n\nexport function registerResources(server: McpServer, ap: AgentPay) {\n registerWalletResource(server, ap);\n registerTransactionResource(server, ap);\n registerAuditResource(server, ap);\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerBuyPrompt(server: McpServer) {\n server.prompt(\n 'buy',\n 'Step-by-step purchase flow: check balance, propose, wait for approval, execute.',\n {\n merchant: z.string().describe('Merchant name'),\n amount: z.string().describe('Purchase amount in USD (e.g. \"29.99\")'),\n description: z.string().describe('What is being purchased'),\n url: z.string().describe('Product or checkout URL'),\n },\n async ({ merchant, amount, description, url }) => ({\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n `I need to purchase from ${merchant}.`,\n '',\n 'Follow these steps exactly:',\n '',\n '1. Call agentpay_check_balance to verify sufficient funds',\n `2. Call agentpay_propose_purchase with:`,\n ` - merchant: \"${merchant}\"`,\n ` - amount: ${amount}`,\n ` - description: \"${description}\"`,\n ` - url: \"${url}\"`,\n '3. Tell me the transaction ID and that I need to approve it',\n '4. Call agentpay_wait_for_approval with the transaction ID',\n '5. Once approved, call agentpay_execute_purchase',\n '6. Call agentpay_get_receipt to confirm',\n '',\n 'If any step fails, stop and explain what went wrong.',\n ].join('\\n'),\n },\n },\n ],\n })\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerBudgetCheckPrompt(server: McpServer) {\n server.prompt(\n 'budget-check',\n 'Check current balance, spending limits, and pending transactions.',\n {},\n async () => ({\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n 'Check my AgentPay budget status:',\n '',\n '1. Call agentpay_check_balance to get current balance and limits',\n '2. Call agentpay_list_pending to see any pending transactions',\n '3. Summarize:',\n ' - Available balance',\n ' - Per-transaction limit',\n ' - Total budget and amount spent',\n ' - Number of pending transactions (if any)',\n ].join('\\n'),\n },\n },\n ],\n })\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerPurchaseStatusPrompt(server: McpServer) {\n server.prompt(\n 'purchase-status',\n 'Review recent transactions and their receipts.',\n {\n limit: z.string().optional().describe('Number of recent transactions to show (default 5)'),\n },\n async ({ limit }) => ({\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n `Show me the status of my recent AgentPay transactions (last ${limit ?? '5'}):`,\n '',\n '1. Call agentpay_status to get recent transactions',\n '2. For each completed transaction, call agentpay_get_receipt',\n '3. Present a summary table with:',\n ' - Transaction ID',\n ' - Merchant',\n ' - Amount',\n ' - Status',\n ' - Confirmation ID (if completed)',\n ].join('\\n'),\n },\n },\n ],\n })\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { registerBuyPrompt } from './buy.js';\nimport { registerBudgetCheckPrompt } from './budget-check.js';\nimport { registerPurchaseStatusPrompt } from './purchase-status.js';\n\nexport function registerPrompts(server: McpServer) {\n registerBuyPrompt(server);\n registerBudgetCheckPrompt(server);\n registerPurchaseStatusPrompt(server);\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { AgentPay } from '@useagentpay/sdk';\nimport type { ServerConfig } from './config.js';\nimport { registerTools } from './tools/index.js';\nimport { registerResources } from './resources/index.js';\nimport { registerPrompts } from './prompts/index.js';\n\ndeclare const __PKG_VERSION__: string;\n\nexport function createServer(config: ServerConfig): McpServer {\n const server = new McpServer({\n name: 'agentpay',\n version: typeof __PKG_VERSION__ !== 'undefined' ? __PKG_VERSION__ : '0.0.0',\n });\n\n // Shared AgentPay instance (no passphrase — read-only by default)\n const ap = new AgentPay({\n home: config.home,\n executor: config.executor,\n });\n\n registerTools(server, ap, config);\n registerResources(server, ap);\n registerPrompts(server);\n\n return server;\n}\n","import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { fileURLToPath } from 'node:url';\nimport { realpathSync } from 'node:fs';\nimport { createServer } from './server.js';\nimport { loadConfig } from './config.js';\n\nexport { createServer } from './server.js';\nexport { loadConfig } from './config.js';\nexport type { ServerConfig } from './config.js';\n\nexport async function startServer(overrides?: { http?: boolean }) {\n const config = loadConfig(overrides);\n const server = createServer(config);\n\n if (config.http) {\n // Dynamic import to avoid loading HTTP deps when not needed\n const { createServer: createHttpServer } = await import('node:http');\n const { StreamableHTTPServerTransport } = await import(\n '@modelcontextprotocol/sdk/server/streamableHttp.js'\n );\n\n const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: () => crypto.randomUUID() });\n await server.connect(transport);\n\n const httpServer = createHttpServer((req, res) => {\n transport.handleRequest(req, res);\n });\n\n const port = parseInt(process.env.MCP_HTTP_PORT ?? '3100', 10);\n httpServer.listen(port, () => {\n console.error(`AgentPay MCP server listening on http://localhost:${port}`);\n });\n\n const shutdown = () => {\n httpServer.close();\n process.exit(0);\n };\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n } else {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n\n const shutdown = async () => {\n await server.close();\n process.exit(0);\n };\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n }\n}\n\n// Auto-start when run directly (handles npx, global install, and symlinks)\nlet isDirectRun = false;\ntry {\n const thisFile = fileURLToPath(import.meta.url);\n isDirectRun = !!process.argv[1] && realpathSync(process.argv[1]) === thisFile;\n} catch {\n // process.argv[1] doesn't exist or can't be resolved\n}\n\nif (isDirectRun) {\n const httpFlag = process.argv.includes('--http');\n startServer({ http: httpFlag }).catch((err) => {\n console.error('Failed to start MCP server:', err);\n process.exit(1);\n });\n}\n","import { startServer } from '../index.js';\n\nexport async function serveCommand(options: { http?: boolean }): Promise<void> {\n await startServer({ http: options.http });\n}\n","import { Command } from 'commander';\n\ndeclare const __PKG_VERSION__: string;\nconst VERSION = typeof __PKG_VERSION__ !== 'undefined' ? __PKG_VERSION__ : '0.0.0';\n\nconst program = new Command();\n\nprogram\n .name('agentpay')\n .description('AgentPay – MCP server & CLI for AI agent payments')\n .version(VERSION);\n\nprogram\n .command('init')\n .description('Initialize AgentPay in the current directory')\n .action(async () => {\n const { initCommand } = await import('./commands/init.js');\n initCommand();\n });\n\nprogram\n .command('setup')\n .description('Set up AgentPay with your billing credentials')\n .action(async () => {\n const { setupCommand } = await import('./commands/setup.js');\n await setupCommand();\n });\n\nprogram\n .command('budget')\n .description('View current spending budget (configure via dashboard)')\n .action(async () => {\n const { budgetCommand } = await import('./commands/budget.js');\n budgetCommand();\n });\n\nprogram\n .command('pending')\n .description('List pending purchase proposals')\n .action(async () => {\n const { pendingCommand } = await import('./commands/pending.js');\n pendingCommand();\n });\n\nprogram\n .command('propose')\n .description('Propose a purchase (creates a pending transaction)')\n .requiredOption('--merchant <name>', 'Merchant name')\n .requiredOption('--amount <amount>', 'Purchase amount in USD')\n .requiredOption('--description <desc>', 'Purchase description')\n .requiredOption('--url <url>', 'Product/checkout URL')\n .action(async (options: { merchant: string; amount: string; description: string; url: string }) => {\n const { proposeCommand } = await import('./commands/propose.js');\n proposeCommand(options);\n });\n\nprogram\n .command('approve <txId>')\n .description('Approve a pending purchase')\n .action(async (txId: string) => {\n const { approveCommand } = await import('./commands/approve.js');\n await approveCommand(txId);\n });\n\nprogram\n .command('reject <txId>')\n .description('Reject a pending purchase')\n .option('--reason <reason>', 'Reason for rejection')\n .action(async (txId: string, options: { reason?: string }) => {\n const { rejectCommand } = await import('./commands/reject.js');\n rejectCommand(txId, options);\n });\n\nprogram\n .command('status')\n .description('Show wallet status and recent transactions')\n .action(async () => {\n const { statusCommand } = await import('./commands/status.js');\n statusCommand();\n });\n\nprogram\n .command('history')\n .description('Show full transaction history')\n .action(async () => {\n const { historyCommand } = await import('./commands/history.js');\n historyCommand();\n });\n\nprogram\n .command('reset')\n .description('Delete all AgentPay data')\n .action(async () => {\n const { resetCommand } = await import('./commands/reset.js');\n await resetCommand();\n });\n\nprogram\n .command('dashboard')\n .description('Open the AgentPay dashboard in your browser')\n .option('--port <port>', 'Port for dashboard server', '3141')\n .action(async (options: { port: string }) => {\n const { dashboardCommand } = await import('./commands/dashboard.js');\n await dashboardCommand(options);\n });\n\nprogram\n .command('mobile <on|off>')\n .description('Enable or disable mobile approval mode (Cloudflare Tunnel)')\n .option('--notify-command <cmd>', 'Shell command to send notification ({{url}} = approval link)')\n .option('--notify-webhook <url>', 'Webhook URL to POST approval payload to')\n .action(async (mode: string, options: { notifyCommand?: string; notifyWebhook?: string }) => {\n const { mobileCommand } = await import('./commands/mobile.js');\n mobileCommand(mode, options);\n });\n\nprogram\n .command('serve')\n .description('Start AgentPay MCP server')\n .option('--http', 'Use HTTP transport instead of stdio')\n .action(async (options: { http?: boolean }) => {\n const { serveCommand } = await import('./commands/serve.js');\n await serveCommand(options);\n });\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;AACA,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAF9B;AAAA;AAAA;AAAA;AAAA;;;ACAO,SAAS,kBAA0B;AACxC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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EAClD,OAAO,OAAO,MAAc,YAAiC;AAC5D,QAAM,EAAE,eAAAC,eAAc,IAAI,MAAM;AAChC,EAAAA,eAAc,MAAM,OAAO;AAC7B,CAAC;AAEH,QACG,QAAQ,QAAQ,EAChB,YAAY,4CAA4C,EACxD,OAAO,YAAY;AAClB,QAAM,EAAE,eAAAC,eAAc,IAAI,MAAM;AAChC,EAAAA,eAAc;AAChB,CAAC;AAEH,QACG,QAAQ,SAAS,EACjB,YAAY,+BAA+B,EAC3C,OAAO,YAAY;AAClB,QAAM,EAAE,gBAAAC,gBAAe,IAAI,MAAM;AACjC,EAAAA,gBAAe;AACjB,CAAC;AAEH,QACG,QAAQ,OAAO,EACf,YAAY,0BAA0B,EACtC,OAAO,YAAY;AAClB,QAAM,EAAE,cAAAC,cAAa,IAAI,MAAM;AAC/B,QAAMA,cAAa;AACrB,CAAC;AAEH,QACG,QAAQ,WAAW,EACnB,YAAY,6CAA6C,EACzD,OAAO,iBAAiB,6BAA6B,MAAM,EAC3D,OAAO,OAAO,YAA8B;AAC3C,QAAM,EAAE,kBAAAC,kBAAiB,IAAI,MAAM;AACnC,QAAMA,kBAAiB,OAAO;AAChC,CAAC;AAEH,QACG,QAAQ,iBAAiB,EACzB,YAAY,4DAA4D,EACxE,OAAO,0BAA0B,8DAA8D,EAC/F,OAAO,0BAA0B,yCAAyC,EAC1E,OAAO,OAAO,MAAc,YAAgE;AAC3F,QAAM,EAAE,eAAAC,eAAc,IAAI,MAAM;AAChC,EAAAA,eAAc,MAAM,OAAO;AAC7B,CAAC;AAEH,QACG,QAAQ,OAAO,EACf,YAAY,2BAA2B,EACvC,OAAO,UAAU,qCAAqC,EACtD,OAAO,OAAO,YAAgC;AAC7C,QAAM,EAAE,cAAAC,cAAa,IAAI,MAAM;AAC/B,QAAMA,cAAa,OAAO;AAC5B,CAAC;AAEH,QAAQ,MAAM;","names":["formatCurrency","BudgetManager","TransactionManager","formatCurrency","TransactionManager","AuditLogger","formatCurrency","TransactionManager","AuditLogger","TransactionManager","formatCurrency","existsSync","init_status","init_propose","z","loadConfig","z","AgentPay","z","z","init_status","init_propose","z","z","AgentPay","fileURLToPath","loadConfig","initCommand","setupCommand","budgetCommand","pendingCommand","proposeCommand","approveCommand","rejectCommand","statusCommand","historyCommand","resetCommand","dashboardCommand","mobileCommand","serveCommand"]}
package/dist/index.js CHANGED
@@ -145,6 +145,8 @@ function registerProposeTool(server, ap) {
145
145
  async ({ merchant, amount, description, url }) => {
146
146
  try {
147
147
  const tx = ap.transactions.propose({ merchant, amount, description, url });
148
+ const { mobileMode } = ap.status();
149
+ const nextAction = mobileMode ? `Purchase proposed. Mobile mode is ON \u2014 call agentpay_request_mobile_approval with txId "${tx.id}" to send approval link to the user's phone. Then call agentpay_wait_for_approval.` : `Purchase proposed. Open the dashboard for the human to approve: npx -p @useagentpay/mcp-server agentpay dashboard \u2014 then call agentpay_wait_for_approval with txId "${tx.id}".`;
148
150
  return {
149
151
  content: [
150
152
  {
@@ -155,7 +157,8 @@ function registerProposeTool(server, ap) {
155
157
  status: tx.status,
156
158
  merchant: tx.merchant,
157
159
  amount: tx.amount,
158
- nextAction: `Purchase proposed. Open the dashboard for the human to approve: npx -p @useagentpay/mcp-server agentpay dashboard \u2014 then call agentpay_wait_for_approval with txId "${tx.id}".`
160
+ mobileMode,
161
+ nextAction
159
162
  })
160
163
  }
161
164
  ]
@@ -389,6 +392,44 @@ function registerReceiptTool(server, ap) {
389
392
  );
390
393
  }
391
394
 
395
+ // src/tools/mobile-approve.ts
396
+ import { z as z5 } from "zod";
397
+ function registerMobileApproveTool(server, ap) {
398
+ server.tool(
399
+ "agentpay_request_mobile_approval",
400
+ "Send a mobile-friendly approval link to the user via Cloudflare Tunnel. Use this when mobileMode is ON. Requires cloudflared installed on the system.",
401
+ {
402
+ txId: z5.string().describe("Transaction ID of a pending purchase")
403
+ },
404
+ async ({ txId }) => {
405
+ try {
406
+ const cfg = ap.config.get();
407
+ const notify = {};
408
+ notify.command = process.env.AGENTPAY_NOTIFY_COMMAND ?? cfg.notifyCommand;
409
+ notify.webhookUrl = process.env.AGENTPAY_NOTIFY_WEBHOOK ?? cfg.notifyWebhook;
410
+ const result = await ap.transactions.requestMobileApproval(txId, notify);
411
+ return {
412
+ content: [
413
+ {
414
+ type: "text",
415
+ text: JSON.stringify({
416
+ success: true,
417
+ txId,
418
+ approvalUrl: result.approvalUrl,
419
+ notifyResults: result.notifyResults,
420
+ action: result.action,
421
+ nextAction: result.action === "approved" ? `Approved! Call agentpay_execute_purchase with txId "${txId}".` : `Rejected. ${result.reason ? `Reason: ${result.reason}` : "No reason given."}`
422
+ })
423
+ }
424
+ ]
425
+ };
426
+ } catch (err) {
427
+ return { content: [{ type: "text", text: JSON.stringify(mapError(err)) }] };
428
+ }
429
+ }
430
+ );
431
+ }
432
+
392
433
  // src/tools/index.ts
393
434
  function registerTools(server, ap, config) {
394
435
  registerStatusTools(server, ap);
@@ -396,6 +437,7 @@ function registerTools(server, ap, config) {
396
437
  registerTransactionTools(server, ap);
397
438
  registerExecuteTool(server, ap, config);
398
439
  registerReceiptTool(server, ap);
440
+ registerMobileApproveTool(server, ap);
399
441
  }
400
442
 
401
443
  // src/resources/wallet.ts
@@ -492,16 +534,16 @@ function registerResources(server, ap) {
492
534
  }
493
535
 
494
536
  // src/prompts/buy.ts
495
- import { z as z5 } from "zod";
537
+ import { z as z6 } from "zod";
496
538
  function registerBuyPrompt(server) {
497
539
  server.prompt(
498
540
  "buy",
499
541
  "Step-by-step purchase flow: check balance, propose, wait for approval, execute.",
500
542
  {
501
- merchant: z5.string().describe("Merchant name"),
502
- amount: z5.string().describe('Purchase amount in USD (e.g. "29.99")'),
503
- description: z5.string().describe("What is being purchased"),
504
- url: z5.string().describe("Product or checkout URL")
543
+ merchant: z6.string().describe("Merchant name"),
544
+ amount: z6.string().describe('Purchase amount in USD (e.g. "29.99")'),
545
+ description: z6.string().describe("What is being purchased"),
546
+ url: z6.string().describe("Product or checkout URL")
505
547
  },
506
548
  async ({ merchant, amount, description, url }) => ({
507
549
  messages: [
@@ -565,13 +607,13 @@ function registerBudgetCheckPrompt(server) {
565
607
  }
566
608
 
567
609
  // src/prompts/purchase-status.ts
568
- import { z as z6 } from "zod";
610
+ import { z as z7 } from "zod";
569
611
  function registerPurchaseStatusPrompt(server) {
570
612
  server.prompt(
571
613
  "purchase-status",
572
614
  "Review recent transactions and their receipts.",
573
615
  {
574
- limit: z6.string().optional().describe("Number of recent transactions to show (default 5)")
616
+ limit: z7.string().optional().describe("Number of recent transactions to show (default 5)")
575
617
  },
576
618
  async ({ limit }) => ({
577
619
  messages: [
@@ -609,7 +651,7 @@ function registerPrompts(server) {
609
651
  function createServer(config) {
610
652
  const server = new McpServer({
611
653
  name: "agentpay",
612
- version: true ? "0.1.6" : "0.0.0"
654
+ version: true ? "0.1.8" : "0.0.0"
613
655
  });
614
656
  const ap = new AgentPay2({
615
657
  home: config.home,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/server.ts","../src/errors.ts","../src/tools/status.ts","../src/tools/propose.ts","../src/tools/transactions.ts","../src/tools/execute.ts","../src/config.ts","../src/tools/receipt.ts","../src/tools/index.ts","../src/resources/wallet.ts","../src/resources/transaction.ts","../src/resources/audit.ts","../src/resources/index.ts","../src/prompts/buy.ts","../src/prompts/budget-check.ts","../src/prompts/purchase-status.ts","../src/prompts/index.ts"],"sourcesContent":["import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { fileURLToPath } from 'node:url';\nimport { realpathSync } from 'node:fs';\nimport { createServer } from './server.js';\nimport { loadConfig } from './config.js';\n\nexport { createServer } from './server.js';\nexport { loadConfig } from './config.js';\nexport type { ServerConfig } from './config.js';\n\nexport async function startServer(overrides?: { http?: boolean }) {\n const config = loadConfig(overrides);\n const server = createServer(config);\n\n if (config.http) {\n // Dynamic import to avoid loading HTTP deps when not needed\n const { createServer: createHttpServer } = await import('node:http');\n const { StreamableHTTPServerTransport } = await import(\n '@modelcontextprotocol/sdk/server/streamableHttp.js'\n );\n\n const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: () => crypto.randomUUID() });\n await server.connect(transport);\n\n const httpServer = createHttpServer((req, res) => {\n transport.handleRequest(req, res);\n });\n\n const port = parseInt(process.env.MCP_HTTP_PORT ?? '3100', 10);\n httpServer.listen(port, () => {\n console.error(`AgentPay MCP server listening on http://localhost:${port}`);\n });\n\n const shutdown = () => {\n httpServer.close();\n process.exit(0);\n };\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n } else {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n\n const shutdown = async () => {\n await server.close();\n process.exit(0);\n };\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n }\n}\n\n// Auto-start when run directly (handles npx, global install, and symlinks)\nlet isDirectRun = false;\ntry {\n const thisFile = fileURLToPath(import.meta.url);\n isDirectRun = !!process.argv[1] && realpathSync(process.argv[1]) === thisFile;\n} catch {\n // process.argv[1] doesn't exist or can't be resolved\n}\n\nif (isDirectRun) {\n const httpFlag = process.argv.includes('--http');\n startServer({ http: httpFlag }).catch((err) => {\n console.error('Failed to start MCP server:', err);\n process.exit(1);\n });\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { AgentPay } from '@useagentpay/sdk';\nimport type { ServerConfig } from './config.js';\nimport { registerTools } from './tools/index.js';\nimport { registerResources } from './resources/index.js';\nimport { registerPrompts } from './prompts/index.js';\n\ndeclare const __PKG_VERSION__: string;\n\nexport function createServer(config: ServerConfig): McpServer {\n const server = new McpServer({\n name: 'agentpay',\n version: typeof __PKG_VERSION__ !== 'undefined' ? __PKG_VERSION__ : '0.0.0',\n });\n\n // Shared AgentPay instance (no passphrase — read-only by default)\n const ap = new AgentPay({\n home: config.home,\n executor: config.executor,\n });\n\n registerTools(server, ap, config);\n registerResources(server, ap);\n registerPrompts(server);\n\n return server;\n}\n","import {\n NotSetupError,\n DecryptError,\n InsufficientBalanceError,\n ExceedsTxLimitError,\n NotApprovedError,\n InvalidMandateError,\n AlreadyExecutedError,\n CheckoutFailedError,\n TimeoutError,\n} from '@useagentpay/sdk';\n\nexport interface ToolResult {\n success: boolean;\n error?: string;\n nextAction?: string;\n [key: string]: unknown;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst ERROR_MAP: Array<{\n type: new (...args: any[]) => Error;\n error: string;\n nextAction: string;\n}> = [\n { type: NotSetupError, error: 'NOT_SETUP', nextAction: 'STOP - Human must run: agentpay setup' },\n { type: InsufficientBalanceError, error: 'INSUFFICIENT_BALANCE', nextAction: 'STOP - Human must add budget' },\n { type: ExceedsTxLimitError, error: 'EXCEEDS_TX_LIMIT', nextAction: 'STOP - Human must increase limit' },\n { type: NotApprovedError, error: 'NOT_APPROVED', nextAction: 'WAIT - Needs approval first' },\n { type: InvalidMandateError, error: 'INVALID_MANDATE', nextAction: 'STOP - Security error' },\n { type: AlreadyExecutedError, error: 'ALREADY_EXECUTED', nextAction: 'STOP - Already processed' },\n { type: CheckoutFailedError, error: 'CHECKOUT_FAILED', nextAction: 'ERROR - Human should review' },\n { type: TimeoutError, error: 'TIMEOUT', nextAction: 'RETRY - Try again later' },\n { type: DecryptError, error: 'DECRYPT_FAILED', nextAction: 'STOP - Wrong passphrase' },\n];\n\nexport function mapError(err: unknown): ToolResult {\n if (err instanceof Error) {\n for (const mapping of ERROR_MAP) {\n if (err instanceof mapping.type) {\n return {\n success: false,\n error: mapping.error,\n message: err.message,\n nextAction: mapping.nextAction,\n };\n }\n }\n }\n\n return {\n success: false,\n error: 'UNKNOWN_ERROR',\n message: err instanceof Error ? err.message : String(err),\n };\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { mapError } from '../errors.js';\n\nexport function registerStatusTools(server: McpServer, ap: AgentPay) {\n server.tool(\n 'agentpay_status',\n 'Get AgentPay status: setup state, balance, budget, and pending transactions. Call this first.',\n {},\n async () => {\n try {\n const status = ap.status();\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n ...status,\n pendingCount: status.pending.length,\n nextAction: !status.isSetup\n ? 'STOP - Human must run: agentpay setup'\n : status.pending.length > 0\n ? 'Review pending transactions with agentpay_list_pending'\n : 'Ready for purchases. Use agentpay_check_balance before proposing.',\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n\n server.tool(\n 'agentpay_check_balance',\n 'Check current balance, budget, and per-transaction limit. Call BEFORE proposing a purchase.',\n {},\n async () => {\n try {\n const wallet = ap.wallet.getBalance();\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n ...wallet,\n nextAction:\n wallet.balance <= 0\n ? 'STOP - No balance remaining. Human must add budget.'\n : `Ready. Max single purchase: $${Math.min(wallet.balance, wallet.limitPerTx).toFixed(2)}`,\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n\n server.tool(\n 'agentpay_list_pending',\n 'List all pending transactions awaiting human approval.',\n {},\n async () => {\n try {\n const status = ap.status();\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n pending: status.pending,\n count: status.pending.length,\n nextAction:\n status.pending.length > 0\n ? 'Human must approve/reject via CLI. Use agentpay_wait_for_approval to poll.'\n : 'No pending transactions.',\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { mapError } from '../errors.js';\n\nexport function registerProposeTool(server: McpServer, ap: AgentPay) {\n server.tool(\n 'agentpay_propose_purchase',\n 'Propose a new purchase. Creates a pending transaction that requires human approval before execution.',\n {\n merchant: z.string().describe('Merchant name (e.g. \"Amazon\", \"Target\")'),\n amount: z.number().positive().describe('Purchase amount in USD'),\n description: z.string().describe('What is being purchased'),\n url: z.string().url().describe('Product or checkout URL'),\n },\n async ({ merchant, amount, description, url }) => {\n try {\n const tx = ap.transactions.propose({ merchant, amount, description, url });\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n txId: tx.id,\n status: tx.status,\n merchant: tx.merchant,\n amount: tx.amount,\n nextAction: `Purchase proposed. Open the dashboard for the human to approve: npx -p @useagentpay/mcp-server agentpay dashboard — then call agentpay_wait_for_approval with txId \"${tx.id}\".`,\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { mapError } from '../errors.js';\n\nfunction nextActionForStatus(status: string): string {\n switch (status) {\n case 'pending':\n return 'WAIT - Human must approve via CLI. Use agentpay_wait_for_approval to poll.';\n case 'approved':\n return 'READY - Use agentpay_execute_purchase to complete the purchase.';\n case 'rejected':\n return 'STOP - Transaction was rejected by human.';\n case 'executing':\n return 'WAIT - Purchase is being executed.';\n case 'completed':\n return 'DONE - Use agentpay_get_receipt for confirmation details.';\n case 'failed':\n return 'ERROR - Purchase failed. Human should review.';\n default:\n return 'Unknown status.';\n }\n}\n\nexport function registerTransactionTools(server: McpServer, ap: AgentPay) {\n server.tool(\n 'agentpay_get_transaction',\n 'Get the current status and details of a transaction.',\n {\n txId: z.string().describe('Transaction ID (e.g. \"tx_abc123\")'),\n },\n async ({ txId }) => {\n try {\n const tx = ap.transactions.get(txId);\n if (!tx) {\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: false,\n error: 'NOT_FOUND',\n message: `Transaction ${txId} not found.`,\n }),\n },\n ],\n };\n }\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n id: tx.id,\n status: tx.status,\n merchant: tx.merchant,\n amount: tx.amount,\n description: tx.description,\n url: tx.url,\n createdAt: tx.createdAt,\n nextAction: nextActionForStatus(tx.status),\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n\n server.tool(\n 'agentpay_wait_for_approval',\n 'Long-poll for human approval of a pending transaction. Blocks until approved, rejected, or timeout.',\n {\n txId: z.string().describe('Transaction ID to wait for'),\n pollInterval: z.number().positive().optional().describe('Poll interval in ms (default 2000)'),\n timeout: z.number().positive().optional().describe('Timeout in ms (default 300000 = 5 min)'),\n },\n async ({ txId, pollInterval, timeout }) => {\n try {\n const result = await ap.transactions.waitForApproval(txId, {\n pollInterval: pollInterval ?? 2000,\n timeout: timeout ?? 300000,\n });\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n txId,\n status: result.status,\n reason: result.reason,\n nextAction: nextActionForStatus(result.status),\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { AgentPay } from '@useagentpay/sdk';\nimport type { ServerConfig } from '../config.js';\nimport { getPassphrase } from '../config.js';\nimport { mapError } from '../errors.js';\n\nexport function registerExecuteTool(server: McpServer, ap: AgentPay, config: ServerConfig) {\n server.tool(\n 'agentpay_execute_purchase',\n 'Execute an approved purchase. Requires passphrase config. Decrypts credentials and completes checkout via browser.',\n {\n txId: z.string().describe('Transaction ID of an approved purchase'),\n },\n async ({ txId }) => {\n try {\n const passphrase = await getPassphrase(config);\n\n // Create a temporary instance with passphrase for execution\n const execAp = new AgentPay({\n home: ap.home,\n passphrase,\n executor: config.executor,\n });\n\n const receipt = await execAp.transactions.execute(txId);\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n receipt,\n nextAction: 'DONE - Purchase completed. Use agentpay_get_receipt for details.',\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import type { ExecutorConfig } from '@useagentpay/sdk';\n\nexport interface ServerConfig {\n home?: string;\n passphrase?: string;\n passphraseServer?: string;\n passphraseMode: 'env' | 'server' | 'none';\n executor?: ExecutorConfig;\n http?: boolean;\n}\n\nexport function loadConfig(overrides?: { http?: boolean }): ServerConfig {\n const passphrase = process.env.AGENTPAY_PASSPHRASE;\n const passphraseServer = process.env.AGENTPAY_PASSPHRASE_SERVER;\n\n let passphraseMode: ServerConfig['passphraseMode'] = 'none';\n if (passphrase) passphraseMode = 'env';\n else if (passphraseServer) passphraseMode = 'server';\n\n // Default: local Chromium via Stagehand. Only modelApiKey needed for AI navigation.\n const executor: ExecutorConfig = {\n modelApiKey: process.env.ANTHROPIC_API_KEY,\n };\n\n return {\n home: process.env.AGENTPAY_HOME || undefined,\n passphrase,\n passphraseServer,\n passphraseMode,\n executor,\n http: overrides?.http ?? process.env.MCP_TRANSPORT === 'http',\n };\n}\n\nexport async function getPassphrase(config: ServerConfig): Promise<string> {\n if (config.passphraseMode === 'env' && config.passphrase) {\n return config.passphrase;\n }\n\n if (config.passphraseMode === 'server' && config.passphraseServer) {\n const res = await fetch(config.passphraseServer);\n if (!res.ok) throw new Error(`Passphrase server returned ${res.status}`);\n const body = await res.text();\n return body.trim();\n }\n\n throw new Error(\n 'No passphrase configured. Set AGENTPAY_PASSPHRASE or AGENTPAY_PASSPHRASE_SERVER to enable purchase execution.'\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { mapError } from '../errors.js';\n\nexport function registerReceiptTool(server: McpServer, ap: AgentPay) {\n server.tool(\n 'agentpay_get_receipt',\n 'Get the receipt for a completed purchase.',\n {\n txId: z.string().describe('Transaction ID of a completed purchase'),\n },\n async ({ txId }) => {\n try {\n const receipt = ap.transactions.getReceipt(txId);\n if (!receipt) {\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: false,\n error: 'NO_RECEIPT',\n message: `No receipt found for transaction ${txId}. Transaction may not be completed yet.`,\n nextAction: 'Check transaction status with agentpay_get_transaction',\n }),\n },\n ],\n };\n }\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n receipt,\n nextAction: 'DONE - Purchase confirmed.',\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport type { ServerConfig } from '../config.js';\nimport { registerStatusTools } from './status.js';\nimport { registerProposeTool } from './propose.js';\nimport { registerTransactionTools } from './transactions.js';\nimport { registerExecuteTool } from './execute.js';\nimport { registerReceiptTool } from './receipt.js';\n\nexport function registerTools(server: McpServer, ap: AgentPay, config: ServerConfig) {\n registerStatusTools(server, ap);\n registerProposeTool(server, ap);\n registerTransactionTools(server, ap);\n registerExecuteTool(server, ap, config);\n registerReceiptTool(server, ap);\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\n\nexport function registerWalletResource(server: McpServer, ap: AgentPay) {\n server.resource('wallet', 'agentpay://wallet', async () => {\n try {\n const wallet = ap.wallet.getBalance();\n return {\n contents: [\n {\n uri: 'agentpay://wallet',\n mimeType: 'application/json',\n text: JSON.stringify(wallet, null, 2),\n },\n ],\n };\n } catch {\n return {\n contents: [\n {\n uri: 'agentpay://wallet',\n mimeType: 'application/json',\n text: JSON.stringify({ budget: 0, balance: 0, limitPerTx: 0, spent: 0 }),\n },\n ],\n };\n }\n });\n}\n","import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\n\nexport function registerTransactionResource(server: McpServer, ap: AgentPay) {\n server.resource(\n 'transaction',\n new ResourceTemplate('agentpay://transactions/{txId}', { list: undefined }),\n async (uri, { txId }) => {\n const tx = ap.transactions.get(txId as string);\n if (!tx) {\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify({ error: 'Transaction not found' }),\n },\n ],\n };\n }\n\n // Omit mandate internals for security\n const { mandate: _, ...safeTx } = tx;\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(safeTx, null, 2),\n },\n ],\n };\n }\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\n\nexport function registerAuditResource(server: McpServer, ap: AgentPay) {\n server.resource('audit-log', 'agentpay://audit-log', async () => {\n const lines = ap.audit.getLog();\n const last50 = lines.slice(-50);\n\n const entries = last50.map((line) => {\n const parts = line.split('\\t');\n return {\n timestamp: parts[0] ?? '',\n action: parts[1] ?? '',\n details: parts[2] ? JSON.parse(parts[2]) : {},\n };\n });\n\n return {\n contents: [\n {\n uri: 'agentpay://audit-log',\n mimeType: 'application/json',\n text: JSON.stringify(entries, null, 2),\n },\n ],\n };\n });\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { registerWalletResource } from './wallet.js';\nimport { registerTransactionResource } from './transaction.js';\nimport { registerAuditResource } from './audit.js';\n\nexport function registerResources(server: McpServer, ap: AgentPay) {\n registerWalletResource(server, ap);\n registerTransactionResource(server, ap);\n registerAuditResource(server, ap);\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerBuyPrompt(server: McpServer) {\n server.prompt(\n 'buy',\n 'Step-by-step purchase flow: check balance, propose, wait for approval, execute.',\n {\n merchant: z.string().describe('Merchant name'),\n amount: z.string().describe('Purchase amount in USD (e.g. \"29.99\")'),\n description: z.string().describe('What is being purchased'),\n url: z.string().describe('Product or checkout URL'),\n },\n async ({ merchant, amount, description, url }) => ({\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n `I need to purchase from ${merchant}.`,\n '',\n 'Follow these steps exactly:',\n '',\n '1. Call agentpay_check_balance to verify sufficient funds',\n `2. Call agentpay_propose_purchase with:`,\n ` - merchant: \"${merchant}\"`,\n ` - amount: ${amount}`,\n ` - description: \"${description}\"`,\n ` - url: \"${url}\"`,\n '3. Tell me the transaction ID and that I need to approve it',\n '4. Call agentpay_wait_for_approval with the transaction ID',\n '5. Once approved, call agentpay_execute_purchase',\n '6. Call agentpay_get_receipt to confirm',\n '',\n 'If any step fails, stop and explain what went wrong.',\n ].join('\\n'),\n },\n },\n ],\n })\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerBudgetCheckPrompt(server: McpServer) {\n server.prompt(\n 'budget-check',\n 'Check current balance, spending limits, and pending transactions.',\n {},\n async () => ({\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n 'Check my AgentPay budget status:',\n '',\n '1. Call agentpay_check_balance to get current balance and limits',\n '2. Call agentpay_list_pending to see any pending transactions',\n '3. Summarize:',\n ' - Available balance',\n ' - Per-transaction limit',\n ' - Total budget and amount spent',\n ' - Number of pending transactions (if any)',\n ].join('\\n'),\n },\n },\n ],\n })\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerPurchaseStatusPrompt(server: McpServer) {\n server.prompt(\n 'purchase-status',\n 'Review recent transactions and their receipts.',\n {\n limit: z.string().optional().describe('Number of recent transactions to show (default 5)'),\n },\n async ({ limit }) => ({\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n `Show me the status of my recent AgentPay transactions (last ${limit ?? '5'}):`,\n '',\n '1. Call agentpay_status to get recent transactions',\n '2. For each completed transaction, call agentpay_get_receipt',\n '3. Present a summary table with:',\n ' - Transaction ID',\n ' - Merchant',\n ' - Amount',\n ' - Status',\n ' - Confirmation ID (if completed)',\n ].join('\\n'),\n },\n },\n ],\n })\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { registerBuyPrompt } from './buy.js';\nimport { registerBudgetCheckPrompt } from './budget-check.js';\nimport { registerPurchaseStatusPrompt } from './purchase-status.js';\n\nexport function registerPrompts(server: McpServer) {\n registerBuyPrompt(server);\n registerBudgetCheckPrompt(server);\n registerPurchaseStatusPrompt(server);\n}\n"],"mappings":";;;AAAA,SAAS,4BAA4B;AACrC,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;;;ACF7B,SAAS,iBAAiB;AAC1B,SAAS,YAAAA,iBAAgB;;;ACDzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAUP,IAAM,YAID;AAAA,EACH,EAAE,MAAM,eAAe,OAAO,aAAa,YAAY,wCAAwC;AAAA,EAC/F,EAAE,MAAM,0BAA0B,OAAO,wBAAwB,YAAY,+BAA+B;AAAA,EAC5G,EAAE,MAAM,qBAAqB,OAAO,oBAAoB,YAAY,mCAAmC;AAAA,EACvG,EAAE,MAAM,kBAAkB,OAAO,gBAAgB,YAAY,8BAA8B;AAAA,EAC3F,EAAE,MAAM,qBAAqB,OAAO,mBAAmB,YAAY,wBAAwB;AAAA,EAC3F,EAAE,MAAM,sBAAsB,OAAO,oBAAoB,YAAY,2BAA2B;AAAA,EAChG,EAAE,MAAM,qBAAqB,OAAO,mBAAmB,YAAY,8BAA8B;AAAA,EACjG,EAAE,MAAM,cAAc,OAAO,WAAW,YAAY,0BAA0B;AAAA,EAC9E,EAA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AAQ,IAAI,iBAAiB,QAAQ,EAAE;AAC7D,eAAW,OAAO,MAAM,MAAM;AAC5B,cAAQ,MAAM,qDAAqD,IAAI,EAAE;AAAA,IAC3E,CAAC;AAED,UAAM,WAAW,MAAM;AACrB,iBAAW,MAAM;AACjB,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,YAAQ,GAAG,UAAU,QAAQ;AAC7B,YAAQ,GAAG,WAAW,QAAQ;AAAA,EAChC,OAAO;AACL,UAAM,YAAY,IAAI,qBAAqB;AAC3C,UAAM,OAAO,QAAQ,SAAS;AAE9B,UAAM,WAAW,YAAY;AAC3B,YAAM,OAAO,MAAM;AACnB,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,YAAQ,GAAG,UAAU,QAAQ;AAC7B,YAAQ,GAAG,WAAW,QAAQ;AAAA,EAChC;AACF;AAGA,IAAI,cAAc;AAClB,IAAI;AACF,QAAM,WAAW,cAAc,YAAY,GAAG;AAC9C,gBAAc,CAAC,CAAC,QAAQ,KAAK,CAAC,KAAK,aAAa,QAAQ,KAAK,CAAC,CAAC,MAAM;AACvE,QAAQ;AAER;AAEA,IAAI,aAAa;AACf,QAAM,WAAW,QAAQ,KAAK,SAAS,QAAQ;AAC/C,cAAY,EAAE,MAAM,SAAS,CAAC,EAAE,MAAM,CAAC,QAAQ;AAC7C,YAAQ,MAAM,+BAA+B,GAAG;AAChD,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AACH;","names":["AgentPay","z","z","z","z","z","z","z","z","AgentPay"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/server.ts","../src/errors.ts","../src/tools/status.ts","../src/tools/propose.ts","../src/tools/transactions.ts","../src/tools/execute.ts","../src/config.ts","../src/tools/receipt.ts","../src/tools/mobile-approve.ts","../src/tools/index.ts","../src/resources/wallet.ts","../src/resources/transaction.ts","../src/resources/audit.ts","../src/resources/index.ts","../src/prompts/buy.ts","../src/prompts/budget-check.ts","../src/prompts/purchase-status.ts","../src/prompts/index.ts"],"sourcesContent":["import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { fileURLToPath } from 'node:url';\nimport { realpathSync } from 'node:fs';\nimport { createServer } from './server.js';\nimport { loadConfig } from './config.js';\n\nexport { createServer } from './server.js';\nexport { loadConfig } from './config.js';\nexport type { ServerConfig } from './config.js';\n\nexport async function startServer(overrides?: { http?: boolean }) {\n const config = loadConfig(overrides);\n const server = createServer(config);\n\n if (config.http) {\n // Dynamic import to avoid loading HTTP deps when not needed\n const { createServer: createHttpServer } = await import('node:http');\n const { StreamableHTTPServerTransport } = await import(\n '@modelcontextprotocol/sdk/server/streamableHttp.js'\n );\n\n const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: () => crypto.randomUUID() });\n await server.connect(transport);\n\n const httpServer = createHttpServer((req, res) => {\n transport.handleRequest(req, res);\n });\n\n const port = parseInt(process.env.MCP_HTTP_PORT ?? '3100', 10);\n httpServer.listen(port, () => {\n console.error(`AgentPay MCP server listening on http://localhost:${port}`);\n });\n\n const shutdown = () => {\n httpServer.close();\n process.exit(0);\n };\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n } else {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n\n const shutdown = async () => {\n await server.close();\n process.exit(0);\n };\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n }\n}\n\n// Auto-start when run directly (handles npx, global install, and symlinks)\nlet isDirectRun = false;\ntry {\n const thisFile = fileURLToPath(import.meta.url);\n isDirectRun = !!process.argv[1] && realpathSync(process.argv[1]) === thisFile;\n} catch {\n // process.argv[1] doesn't exist or can't be resolved\n}\n\nif (isDirectRun) {\n const httpFlag = process.argv.includes('--http');\n startServer({ http: httpFlag }).catch((err) => {\n console.error('Failed to start MCP server:', err);\n process.exit(1);\n });\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { AgentPay } from '@useagentpay/sdk';\nimport type { ServerConfig } from './config.js';\nimport { registerTools } from './tools/index.js';\nimport { registerResources } from './resources/index.js';\nimport { registerPrompts } from './prompts/index.js';\n\ndeclare const __PKG_VERSION__: string;\n\nexport function createServer(config: ServerConfig): McpServer {\n const server = new McpServer({\n name: 'agentpay',\n version: typeof __PKG_VERSION__ !== 'undefined' ? __PKG_VERSION__ : '0.0.0',\n });\n\n // Shared AgentPay instance (no passphrase — read-only by default)\n const ap = new AgentPay({\n home: config.home,\n executor: config.executor,\n });\n\n registerTools(server, ap, config);\n registerResources(server, ap);\n registerPrompts(server);\n\n return server;\n}\n","import {\n NotSetupError,\n DecryptError,\n InsufficientBalanceError,\n ExceedsTxLimitError,\n NotApprovedError,\n InvalidMandateError,\n AlreadyExecutedError,\n CheckoutFailedError,\n TimeoutError,\n} from '@useagentpay/sdk';\n\nexport interface ToolResult {\n success: boolean;\n error?: string;\n nextAction?: string;\n [key: string]: unknown;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst ERROR_MAP: Array<{\n type: new (...args: any[]) => Error;\n error: string;\n nextAction: string;\n}> = [\n { type: NotSetupError, error: 'NOT_SETUP', nextAction: 'STOP - Human must run: agentpay setup' },\n { type: InsufficientBalanceError, error: 'INSUFFICIENT_BALANCE', nextAction: 'STOP - Human must add budget' },\n { type: ExceedsTxLimitError, error: 'EXCEEDS_TX_LIMIT', nextAction: 'STOP - Human must increase limit' },\n { type: NotApprovedError, error: 'NOT_APPROVED', nextAction: 'WAIT - Needs approval first' },\n { type: InvalidMandateError, error: 'INVALID_MANDATE', nextAction: 'STOP - Security error' },\n { type: AlreadyExecutedError, error: 'ALREADY_EXECUTED', nextAction: 'STOP - Already processed' },\n { type: CheckoutFailedError, error: 'CHECKOUT_FAILED', nextAction: 'ERROR - Human should review' },\n { type: TimeoutError, error: 'TIMEOUT', nextAction: 'RETRY - Try again later' },\n { type: DecryptError, error: 'DECRYPT_FAILED', nextAction: 'STOP - Wrong passphrase' },\n];\n\nexport function mapError(err: unknown): ToolResult {\n if (err instanceof Error) {\n for (const mapping of ERROR_MAP) {\n if (err instanceof mapping.type) {\n return {\n success: false,\n error: mapping.error,\n message: err.message,\n nextAction: mapping.nextAction,\n };\n }\n }\n }\n\n return {\n success: false,\n error: 'UNKNOWN_ERROR',\n message: err instanceof Error ? err.message : String(err),\n };\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { mapError } from '../errors.js';\n\nexport function registerStatusTools(server: McpServer, ap: AgentPay) {\n server.tool(\n 'agentpay_status',\n 'Get AgentPay status: setup state, balance, budget, and pending transactions. Call this first.',\n {},\n async () => {\n try {\n const status = ap.status();\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n ...status,\n pendingCount: status.pending.length,\n nextAction: !status.isSetup\n ? 'STOP - Human must run: agentpay setup'\n : status.pending.length > 0\n ? 'Review pending transactions with agentpay_list_pending'\n : 'Ready for purchases. Use agentpay_check_balance before proposing.',\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n\n server.tool(\n 'agentpay_check_balance',\n 'Check current balance, budget, and per-transaction limit. Call BEFORE proposing a purchase.',\n {},\n async () => {\n try {\n const wallet = ap.wallet.getBalance();\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n ...wallet,\n nextAction:\n wallet.balance <= 0\n ? 'STOP - No balance remaining. Human must add budget.'\n : `Ready. Max single purchase: $${Math.min(wallet.balance, wallet.limitPerTx).toFixed(2)}`,\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n\n server.tool(\n 'agentpay_list_pending',\n 'List all pending transactions awaiting human approval.',\n {},\n async () => {\n try {\n const status = ap.status();\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n pending: status.pending,\n count: status.pending.length,\n nextAction:\n status.pending.length > 0\n ? 'Human must approve/reject via CLI. Use agentpay_wait_for_approval to poll.'\n : 'No pending transactions.',\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { mapError } from '../errors.js';\n\nexport function registerProposeTool(server: McpServer, ap: AgentPay) {\n server.tool(\n 'agentpay_propose_purchase',\n 'Propose a new purchase. Creates a pending transaction that requires human approval before execution.',\n {\n merchant: z.string().describe('Merchant name (e.g. \"Amazon\", \"Target\")'),\n amount: z.number().positive().describe('Purchase amount in USD'),\n description: z.string().describe('What is being purchased'),\n url: z.string().url().describe('Product or checkout URL'),\n },\n async ({ merchant, amount, description, url }) => {\n try {\n const tx = ap.transactions.propose({ merchant, amount, description, url });\n const { mobileMode } = ap.status();\n\n const nextAction = mobileMode\n ? `Purchase proposed. Mobile mode is ON — call agentpay_request_mobile_approval with txId \"${tx.id}\" to send approval link to the user's phone. Then call agentpay_wait_for_approval.`\n : `Purchase proposed. Open the dashboard for the human to approve: npx -p @useagentpay/mcp-server agentpay dashboard — then call agentpay_wait_for_approval with txId \"${tx.id}\".`;\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n txId: tx.id,\n status: tx.status,\n merchant: tx.merchant,\n amount: tx.amount,\n mobileMode,\n nextAction,\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { mapError } from '../errors.js';\n\nfunction nextActionForStatus(status: string): string {\n switch (status) {\n case 'pending':\n return 'WAIT - Human must approve via CLI. Use agentpay_wait_for_approval to poll.';\n case 'approved':\n return 'READY - Use agentpay_execute_purchase to complete the purchase.';\n case 'rejected':\n return 'STOP - Transaction was rejected by human.';\n case 'executing':\n return 'WAIT - Purchase is being executed.';\n case 'completed':\n return 'DONE - Use agentpay_get_receipt for confirmation details.';\n case 'failed':\n return 'ERROR - Purchase failed. Human should review.';\n default:\n return 'Unknown status.';\n }\n}\n\nexport function registerTransactionTools(server: McpServer, ap: AgentPay) {\n server.tool(\n 'agentpay_get_transaction',\n 'Get the current status and details of a transaction.',\n {\n txId: z.string().describe('Transaction ID (e.g. \"tx_abc123\")'),\n },\n async ({ txId }) => {\n try {\n const tx = ap.transactions.get(txId);\n if (!tx) {\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: false,\n error: 'NOT_FOUND',\n message: `Transaction ${txId} not found.`,\n }),\n },\n ],\n };\n }\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n id: tx.id,\n status: tx.status,\n merchant: tx.merchant,\n amount: tx.amount,\n description: tx.description,\n url: tx.url,\n createdAt: tx.createdAt,\n nextAction: nextActionForStatus(tx.status),\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n\n server.tool(\n 'agentpay_wait_for_approval',\n 'Long-poll for human approval of a pending transaction. Blocks until approved, rejected, or timeout.',\n {\n txId: z.string().describe('Transaction ID to wait for'),\n pollInterval: z.number().positive().optional().describe('Poll interval in ms (default 2000)'),\n timeout: z.number().positive().optional().describe('Timeout in ms (default 300000 = 5 min)'),\n },\n async ({ txId, pollInterval, timeout }) => {\n try {\n const result = await ap.transactions.waitForApproval(txId, {\n pollInterval: pollInterval ?? 2000,\n timeout: timeout ?? 300000,\n });\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n txId,\n status: result.status,\n reason: result.reason,\n nextAction: nextActionForStatus(result.status),\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { AgentPay } from '@useagentpay/sdk';\nimport type { ServerConfig } from '../config.js';\nimport { getPassphrase } from '../config.js';\nimport { mapError } from '../errors.js';\n\nexport function registerExecuteTool(server: McpServer, ap: AgentPay, config: ServerConfig) {\n server.tool(\n 'agentpay_execute_purchase',\n 'Execute an approved purchase. Requires passphrase config. Decrypts credentials and completes checkout via browser.',\n {\n txId: z.string().describe('Transaction ID of an approved purchase'),\n },\n async ({ txId }) => {\n try {\n const passphrase = await getPassphrase(config);\n\n // Create a temporary instance with passphrase for execution\n const execAp = new AgentPay({\n home: ap.home,\n passphrase,\n executor: config.executor,\n });\n\n const receipt = await execAp.transactions.execute(txId);\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n receipt,\n nextAction: 'DONE - Purchase completed. Use agentpay_get_receipt for details.',\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import type { ExecutorConfig } from '@useagentpay/sdk';\n\nexport interface ServerConfig {\n home?: string;\n passphrase?: string;\n passphraseServer?: string;\n passphraseMode: 'env' | 'server' | 'none';\n executor?: ExecutorConfig;\n http?: boolean;\n}\n\nexport function loadConfig(overrides?: { http?: boolean }): ServerConfig {\n const passphrase = process.env.AGENTPAY_PASSPHRASE;\n const passphraseServer = process.env.AGENTPAY_PASSPHRASE_SERVER;\n\n let passphraseMode: ServerConfig['passphraseMode'] = 'none';\n if (passphrase) passphraseMode = 'env';\n else if (passphraseServer) passphraseMode = 'server';\n\n // Default: local Chromium via Stagehand. Only modelApiKey needed for AI navigation.\n const executor: ExecutorConfig = {\n modelApiKey: process.env.ANTHROPIC_API_KEY,\n };\n\n return {\n home: process.env.AGENTPAY_HOME || undefined,\n passphrase,\n passphraseServer,\n passphraseMode,\n executor,\n http: overrides?.http ?? process.env.MCP_TRANSPORT === 'http',\n };\n}\n\nexport async function getPassphrase(config: ServerConfig): Promise<string> {\n if (config.passphraseMode === 'env' && config.passphrase) {\n return config.passphrase;\n }\n\n if (config.passphraseMode === 'server' && config.passphraseServer) {\n const res = await fetch(config.passphraseServer);\n if (!res.ok) throw new Error(`Passphrase server returned ${res.status}`);\n const body = await res.text();\n return body.trim();\n }\n\n throw new Error(\n 'No passphrase configured. Set AGENTPAY_PASSPHRASE or AGENTPAY_PASSPHRASE_SERVER to enable purchase execution.'\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { mapError } from '../errors.js';\n\nexport function registerReceiptTool(server: McpServer, ap: AgentPay) {\n server.tool(\n 'agentpay_get_receipt',\n 'Get the receipt for a completed purchase.',\n {\n txId: z.string().describe('Transaction ID of a completed purchase'),\n },\n async ({ txId }) => {\n try {\n const receipt = ap.transactions.getReceipt(txId);\n if (!receipt) {\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: false,\n error: 'NO_RECEIPT',\n message: `No receipt found for transaction ${txId}. Transaction may not be completed yet.`,\n nextAction: 'Check transaction status with agentpay_get_transaction',\n }),\n },\n ],\n };\n }\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n receipt,\n nextAction: 'DONE - Purchase confirmed.',\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n }\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { mapError } from '../errors.js';\n\nexport function registerMobileApproveTool(server: McpServer, ap: AgentPay) {\n server.tool(\n 'agentpay_request_mobile_approval',\n 'Send a mobile-friendly approval link to the user via Cloudflare Tunnel. Use this when mobileMode is ON. Requires cloudflared installed on the system.',\n {\n txId: z.string().describe('Transaction ID of a pending purchase'),\n },\n async ({ txId }) => {\n try {\n // Build notify options from config file, with env var overrides\n const cfg = ap.config.get();\n const notify: { command?: string; webhookUrl?: string } = {};\n notify.command = process.env.AGENTPAY_NOTIFY_COMMAND ?? cfg.notifyCommand;\n notify.webhookUrl = process.env.AGENTPAY_NOTIFY_WEBHOOK ?? cfg.notifyWebhook;\n\n const result = await ap.transactions.requestMobileApproval(txId, notify);\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({\n success: true,\n txId,\n approvalUrl: result.approvalUrl,\n notifyResults: result.notifyResults,\n action: result.action,\n nextAction: result.action === 'approved'\n ? `Approved! Call agentpay_execute_purchase with txId \"${txId}\".`\n : `Rejected. ${result.reason ? `Reason: ${result.reason}` : 'No reason given.'}`,\n }),\n },\n ],\n };\n } catch (err) {\n return { content: [{ type: 'text' as const, text: JSON.stringify(mapError(err)) }] };\n }\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport type { ServerConfig } from '../config.js';\nimport { registerStatusTools } from './status.js';\nimport { registerProposeTool } from './propose.js';\nimport { registerTransactionTools } from './transactions.js';\nimport { registerExecuteTool } from './execute.js';\nimport { registerReceiptTool } from './receipt.js';\nimport { registerMobileApproveTool } from './mobile-approve.js';\n\nexport function registerTools(server: McpServer, ap: AgentPay, config: ServerConfig) {\n registerStatusTools(server, ap);\n registerProposeTool(server, ap);\n registerTransactionTools(server, ap);\n registerExecuteTool(server, ap, config);\n registerReceiptTool(server, ap);\n registerMobileApproveTool(server, ap);\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\n\nexport function registerWalletResource(server: McpServer, ap: AgentPay) {\n server.resource('wallet', 'agentpay://wallet', async () => {\n try {\n const wallet = ap.wallet.getBalance();\n return {\n contents: [\n {\n uri: 'agentpay://wallet',\n mimeType: 'application/json',\n text: JSON.stringify(wallet, null, 2),\n },\n ],\n };\n } catch {\n return {\n contents: [\n {\n uri: 'agentpay://wallet',\n mimeType: 'application/json',\n text: JSON.stringify({ budget: 0, balance: 0, limitPerTx: 0, spent: 0 }),\n },\n ],\n };\n }\n });\n}\n","import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\n\nexport function registerTransactionResource(server: McpServer, ap: AgentPay) {\n server.resource(\n 'transaction',\n new ResourceTemplate('agentpay://transactions/{txId}', { list: undefined }),\n async (uri, { txId }) => {\n const tx = ap.transactions.get(txId as string);\n if (!tx) {\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify({ error: 'Transaction not found' }),\n },\n ],\n };\n }\n\n // Omit mandate internals for security\n const { mandate: _, ...safeTx } = tx;\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(safeTx, null, 2),\n },\n ],\n };\n }\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\n\nexport function registerAuditResource(server: McpServer, ap: AgentPay) {\n server.resource('audit-log', 'agentpay://audit-log', async () => {\n const lines = ap.audit.getLog();\n const last50 = lines.slice(-50);\n\n const entries = last50.map((line) => {\n const parts = line.split('\\t');\n return {\n timestamp: parts[0] ?? '',\n action: parts[1] ?? '',\n details: parts[2] ? JSON.parse(parts[2]) : {},\n };\n });\n\n return {\n contents: [\n {\n uri: 'agentpay://audit-log',\n mimeType: 'application/json',\n text: JSON.stringify(entries, null, 2),\n },\n ],\n };\n });\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { AgentPay } from '@useagentpay/sdk';\nimport { registerWalletResource } from './wallet.js';\nimport { registerTransactionResource } from './transaction.js';\nimport { registerAuditResource } from './audit.js';\n\nexport function registerResources(server: McpServer, ap: AgentPay) {\n registerWalletResource(server, ap);\n registerTransactionResource(server, ap);\n registerAuditResource(server, ap);\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerBuyPrompt(server: McpServer) {\n server.prompt(\n 'buy',\n 'Step-by-step purchase flow: check balance, propose, wait for approval, execute.',\n {\n merchant: z.string().describe('Merchant name'),\n amount: z.string().describe('Purchase amount in USD (e.g. \"29.99\")'),\n description: z.string().describe('What is being purchased'),\n url: z.string().describe('Product or checkout URL'),\n },\n async ({ merchant, amount, description, url }) => ({\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n `I need to purchase from ${merchant}.`,\n '',\n 'Follow these steps exactly:',\n '',\n '1. Call agentpay_check_balance to verify sufficient funds',\n `2. Call agentpay_propose_purchase with:`,\n ` - merchant: \"${merchant}\"`,\n ` - amount: ${amount}`,\n ` - description: \"${description}\"`,\n ` - url: \"${url}\"`,\n '3. Tell me the transaction ID and that I need to approve it',\n '4. Call agentpay_wait_for_approval with the transaction ID',\n '5. Once approved, call agentpay_execute_purchase',\n '6. Call agentpay_get_receipt to confirm',\n '',\n 'If any step fails, stop and explain what went wrong.',\n ].join('\\n'),\n },\n },\n ],\n })\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerBudgetCheckPrompt(server: McpServer) {\n server.prompt(\n 'budget-check',\n 'Check current balance, spending limits, and pending transactions.',\n {},\n async () => ({\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n 'Check my AgentPay budget status:',\n '',\n '1. Call agentpay_check_balance to get current balance and limits',\n '2. Call agentpay_list_pending to see any pending transactions',\n '3. Summarize:',\n ' - Available balance',\n ' - Per-transaction limit',\n ' - Total budget and amount spent',\n ' - Number of pending transactions (if any)',\n ].join('\\n'),\n },\n },\n ],\n })\n );\n}\n","import { z } from 'zod';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nexport function registerPurchaseStatusPrompt(server: McpServer) {\n server.prompt(\n 'purchase-status',\n 'Review recent transactions and their receipts.',\n {\n limit: z.string().optional().describe('Number of recent transactions to show (default 5)'),\n },\n async ({ limit }) => ({\n messages: [\n {\n role: 'user' as const,\n content: {\n type: 'text' as const,\n text: [\n `Show me the status of my recent AgentPay transactions (last ${limit ?? '5'}):`,\n '',\n '1. Call agentpay_status to get recent transactions',\n '2. For each completed transaction, call agentpay_get_receipt',\n '3. Present a summary table with:',\n ' - Transaction ID',\n ' - Merchant',\n ' - Amount',\n ' - Status',\n ' - Confirmation ID (if completed)',\n ].join('\\n'),\n },\n },\n ],\n })\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { registerBuyPrompt } from './buy.js';\nimport { registerBudgetCheckPrompt } from './budget-check.js';\nimport { registerPurchaseStatusPrompt } from './purchase-status.js';\n\nexport function registerPrompts(server: McpServer) {\n registerBuyPrompt(server);\n registerBudgetCheckPrompt(server);\n registerPurchaseStatusPrompt(server);\n}\n"],"mappings":";;;AAAA,SAAS,4BAA4B;AACrC,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;;;ACF7B,SAAS,iBAAiB;AAC1B,SAAS,YAAAA,iBAAgB;;;ACDzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAUP,IAAM,YAID;AAAA,EACH,EAAE,MAAM,eAAe,OAAO,aAAa,YAAY,wCAAwC;AAAA,EAC/F,EAAE,MAAM,0BAA0B,OAAO,wBAAwB,YAAY,+BAA+B;AAAA,EAC5G,EAAE,MAAM,qBAAqB,OAAO,oBAAoB,YAAY,mCAAmC;AAAA,EACvG,EAAE,MAAM,kBAAkB,OAAO,gBAAgB,YAAY,8BAA8B;AAAA,EAC3F,EAAE,MAAM,qBAAqB,OAAO,mBAAmB,YAAY,wBAAwB;AAAA,EAC3F,EAAE,MAA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AM,OAAO,SAAS,QAAQ,IAAI,iBAAiB,QAAQ,EAAE;AAC7D,eAAW,OAAO,MAAM,MAAM;AAC5B,cAAQ,MAAM,qDAAqD,IAAI,EAAE;AAAA,IAC3E,CAAC;AAED,UAAM,WAAW,MAAM;AACrB,iBAAW,MAAM;AACjB,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,YAAQ,GAAG,UAAU,QAAQ;AAC7B,YAAQ,GAAG,WAAW,QAAQ;AAAA,EAChC,OAAO;AACL,UAAM,YAAY,IAAI,qBAAqB;AAC3C,UAAM,OAAO,QAAQ,SAAS;AAE9B,UAAM,WAAW,YAAY;AAC3B,YAAM,OAAO,MAAM;AACnB,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,YAAQ,GAAG,UAAU,QAAQ;AAC7B,YAAQ,GAAG,WAAW,QAAQ;AAAA,EAChC;AACF;AAGA,IAAI,cAAc;AAClB,IAAI;AACF,QAAM,WAAW,cAAc,YAAY,GAAG;AAC9C,gBAAc,CAAC,CAAC,QAAQ,KAAK,CAAC,KAAK,aAAa,QAAQ,KAAK,CAAC,CAAC,MAAM;AACvE,QAAQ;AAER;AAEA,IAAI,aAAa;AACf,QAAM,WAAW,QAAQ,KAAK,SAAS,QAAQ;AAC/C,cAAY,EAAE,MAAM,SAAS,CAAC,EAAE,MAAM,CAAC,QAAQ;AAC7C,YAAQ,MAAM,+BAA+B,GAAG;AAChD,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AACH;","names":["AgentPay","z","z","z","z","z","z","z","z","z","z","AgentPay"]}
package/package.json CHANGED
@@ -1,8 +1,41 @@
1
1
  {
2
2
  "name": "@useagentpay/mcp-server",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "mcpName": "io.github.kar69-96/agentpay",
5
- "description": "MCP server for AgentPay exposes payment tools to AI agents",
5
+ "description": "MCP server that lets AI agents make purchases with human approval. Local-first payments, encrypted credentials, budget controls.",
6
+ "keywords": [
7
+ "mcp",
8
+ "mcp-server",
9
+ "model-context-protocol",
10
+ "ai-agent",
11
+ "agent-payments",
12
+ "ai-payments",
13
+ "agentic-commerce",
14
+ "agent-checkout",
15
+ "payments",
16
+ "checkout",
17
+ "wallet",
18
+ "claude",
19
+ "cursor",
20
+ "windsurf",
21
+ "claude-code",
22
+ "claude-desktop",
23
+ "local-first",
24
+ "encrypted",
25
+ "human-approval",
26
+ "budget-controls",
27
+ "ed25519",
28
+ "ap2",
29
+ "purchase",
30
+ "headless-browser",
31
+ "open-source"
32
+ ],
33
+ "homepage": "https://useagentpay.com",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/kar69-96/useagentpay",
37
+ "directory": "packages/mcp-server"
38
+ },
6
39
  "type": "module",
7
40
  "exports": {
8
41
  ".": {
@@ -26,7 +59,7 @@
26
59
  "clean": "rm -rf dist"
27
60
  },
28
61
  "dependencies": {
29
- "@useagentpay/sdk": "^0.1.2",
62
+ "@useagentpay/sdk": "workspace:^",
30
63
  "@modelcontextprotocol/sdk": "^1.12.0",
31
64
  "commander": "^13.0.0",
32
65
  "zod": "^3.25.0 || ^4.0.0"