@useagentpay/mcp-server 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -28,7 +28,7 @@ You have access to AgentPay for making purchases on behalf of the user.
28
28
 
29
29
  1. **Check balance** \u2014 call \`agentpay_check_balance\` before proposing
30
30
  2. **Propose** \u2014 call \`agentpay_propose_purchase\` with merchant, amount, description, and URL
31
- 3. **Open the dashboard** \u2014 run \`npx agentpay dashboard\` so the human can approve
31
+ 3. **Open the dashboard** \u2014 run \`npx -p @useagentpay/mcp-server agentpay dashboard\` so the human can approve
32
32
  4. **Wait** \u2014 call \`agentpay_wait_for_approval\` to poll until approved or rejected
33
33
  5. **Execute** \u2014 call \`agentpay_execute_purchase\` once approved
34
34
  6. **Receipt** \u2014 call \`agentpay_get_receipt\` and share the result with the human
@@ -49,13 +49,13 @@ You have access to AgentPay for making purchases on behalf of the user.
49
49
  Budget, 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:
50
50
 
51
51
  \`\`\`
52
- npx agentpay dashboard
52
+ npx -p @useagentpay/mcp-server agentpay dashboard
53
53
  \`\`\`
54
54
 
55
55
  If AgentPay isn't set up yet, run setup for them:
56
56
 
57
57
  \`\`\`
58
- npx agentpay setup
58
+ npx -p @useagentpay/mcp-server agentpay setup
59
59
  \`\`\`
60
60
 
61
61
  After setup completes, these files are created in \`agentpay/\`:
@@ -591,7 +591,7 @@ function registerProposeTool(server, ap) {
591
591
  status: tx.status,
592
592
  merchant: tx.merchant,
593
593
  amount: tx.amount,
594
- nextAction: `Purchase proposed. Open the dashboard for the human to approve: npx agentpay dashboard \u2014 then call agentpay_wait_for_approval with txId "${tx.id}".`
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}".`
595
595
  })
596
596
  }
597
597
  ]
@@ -1145,7 +1145,7 @@ import { AgentPay as AgentPay3 } from "@useagentpay/sdk";
1145
1145
  function createServer(config) {
1146
1146
  const server = new McpServer({
1147
1147
  name: "agentpay",
1148
- version: true ? "0.1.5" : "0.0.0"
1148
+ version: true ? "0.1.6" : "0.0.0"
1149
1149
  });
1150
1150
  const ap = new AgentPay3({
1151
1151
  home: config.home,
@@ -1246,7 +1246,7 @@ var init_serve = __esm({
1246
1246
  // src/cli.ts
1247
1247
  init_esm_shims();
1248
1248
  import { Command } from "commander";
1249
- var VERSION = true ? "0.1.5" : "0.0.0";
1249
+ var VERSION = true ? "0.1.6" : "0.0.0";
1250
1250
  var program = new Command();
1251
1251
  program.name("agentpay").description("AgentPay \u2013 MCP server & CLI for AI agent payments").version(VERSION);
1252
1252
  program.command("init").description("Initialize AgentPay in the current directory").action(async () => {
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 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 agentpay dashboard\n\\`\\`\\`\n\nIf AgentPay isn't set up yet, run setup for them:\n\n\\`\\`\\`\nnpx 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 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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqDT;AAtDA;AAAA;AAAA;AAAA;AAAA;AAAA;;;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AAc,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,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","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/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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqDT;AAtDA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA,SAAS,WAAW,kBAAkB;AACtC,SAAS,qBAAqB;AAC9B,SAAS,YAAY;AAGd,SAAS,cAAoB;AAClC,QAAM,MAAM,KAAK,QAAQ,IAAI,GAAG,UAAU;AAE1C,MAAI,WAAW,GAAG,GAAG;AACnB,YAAQ,IAAI,mCAAmC,GAAG,EAAE;AACpD;AAAA,EACF;AAEA,YAAU,KAAK,EAAE,WAAW,KAAK,CAAC;AAClC,gBAAc,KAAK,KAAK,UAAU,GAAG,gBAAgB,GAAG,OAAO;AAE/D,UAAQ,IAAI,6EAA6E;AAC3F;AAjBA;AAAA;AAAA;AAAA;AAGA;AAAA;AAAA;;;ACHA;AAAA;AAAA;AAAA;AAAA,SAAS,2BAA2B;AAEpC,eAAsB,eAA8B;AAClD,UAAQ,IAAI,gBAAgB;AAC5B,UAAQ,IAAI,wFAAkB;AAC9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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,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","z","AgentPay","z","init_status","init_propose","z","z","AgentPay","fileURLToPath","initCommand","setupCommand","budgetCommand","pendingCommand","proposeCommand","approveCommand","rejectCommand","statusCommand","historyCommand","resetCommand","dashboardCommand","serveCommand"]}
package/dist/index.js CHANGED
@@ -155,7 +155,7 @@ function registerProposeTool(server, ap) {
155
155
  status: tx.status,
156
156
  merchant: tx.merchant,
157
157
  amount: tx.amount,
158
- nextAction: `Purchase proposed. Open the dashboard for the human to approve: npx agentpay dashboard \u2014 then call agentpay_wait_for_approval with txId "${tx.id}".`
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}".`
159
159
  })
160
160
  }
161
161
  ]
@@ -609,7 +609,7 @@ function registerPrompts(server) {
609
609
  function createServer(config) {
610
610
  const server = new McpServer({
611
611
  name: "agentpay",
612
- version: true ? "0.1.5" : "0.0.0"
612
+ version: true ? "0.1.6" : "0.0.0"
613
613
  });
614
614
  const ap = new AgentPay2({
615
615
  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 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;A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AAQ;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/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,EAAE,MAAM,cAAc,OAAO,kBAAkB,YAAY,0BAA0B;AACvF;AAEO,SAAS,SAAS,KAA0B;AACjD,MAAI,eAAe,OAAO;AACxB,eAAW,WAAW,WAAW;AAC/B,UAAI,eAAe,QAAQ,MAAM;AAC/B,eAAO;AAAA,UACL,SAAS;AAAA,UACT,OAAO,QAAQ;AAAA,UACf,SAAS,IAAI;AAAA,UACb,YAAY,QAAQ;AAAA,QACtB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,SAAS;AAAA,IAC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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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useagentpay/mcp-server",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "mcpName": "io.github.kar69-96/agentpay",
5
5
  "description": "MCP server for AgentPay – exposes payment tools to AI agents",
6
6
  "type": "module",