agentwallet-mcp 1.7.0 → 1.7.2

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.
Files changed (3) hide show
  1. package/README.md +56 -13
  2. package/build/index.js +88 -5
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # AgentWallet MCP Server
2
2
 
3
- Permissionless wallet infrastructure for AI agents. Create wallets, sign transactions, and broadcast on-chain — on any EVM chain and Solana. Up to 50% less expensive than Coinbase.
3
+ Permissionless wallet infrastructure for AI agents. Create wallets, sign transactions, and broadcast on-chain — on any EVM chain and Solana. Up to 50% less expensive than Coinbase. Built-in guards. No KYC. The only AI agent wallet that accepts crypto for its own API fees.
4
4
 
5
- **No KYC. No KYT. No transaction monitoring. No one can block your wallet.**
5
+ **No KYC. No KYT. No approval process. No transaction monitoring. No one can block your wallet. Pay with USDC on-chain — no credit card required.**
6
6
 
7
7
  <p align="center">
8
8
  <img src="assets/demo.svg" alt="AgentWallet demo — AI agent pays x402 invoice automatically" width="800">
@@ -10,12 +10,14 @@ Permissionless wallet infrastructure for AI agents. Create wallets, sign transac
10
10
 
11
11
  ## Features
12
12
 
13
- - **28 MCP tools** — create wallets, send transactions, approve tokens, wrap ETH, pay and accept x402 payments, and more
13
+ - **29 MCP tools** — create wallets, send transactions, approve tokens, wrap ETH, transfer SPL tokens, pay and accept x402 payments, and more
14
14
  - **EVM + Solana** — Ethereum, Base, Polygon, BSC, Arbitrum, Optimism, Avalanche, Zora, PulseChain, Solana, and any other EVM-compatible chain
15
15
  - **SOL + SPL tokens** — native SOL transfers and SPL token transfers (USDC, USDT, etc.) with automatic account creation
16
+ - **Built-in guards** — daily spending limits, gas price protection, emergency pause, rate limiting, replay protection, and on-chain verification — all active by default
16
17
  - **x402 payments** — pay for x402-enabled APIs automatically, or accept x402 payments on your own endpoints (EVM and Solana)
17
18
  - **Secure** — Private keys encrypted at rest, decrypted only during signing, zeroed from memory immediately after
18
- - **Permissionless** — No identity verification, no compliance gatekeeping. Create a wallet and transact immediately.
19
+ - **Permissionless** — No KYC. No KYT. No identity verification. No approval process. No compliance gatekeeping. Sign up, get an API key, and start transacting immediately.
20
+ - **30-second setup** — three lines of config. No SDK to install. No dependencies to manage.
19
21
 
20
22
  ## Pricing
21
23
 
@@ -23,11 +25,12 @@ Permissionless wallet infrastructure for AI agents. Create wallets, sign transac
23
25
  - **6,000 free operations/month**
24
26
  - **$0.0005 per x402 verification** (50% less expensive than Coinbase)
25
27
  - **1,000 free x402 verifications/month**
28
+ - **Pay with USDC on-chain** via x402 — no credit card required
26
29
  - No monthly fee, no tiers — just pay as you go
27
30
 
28
31
  ## Quick Start
29
32
 
30
- Get your free API key at [hifriendbot.com/wallet](https://hifriendbot.com/wallet) (no credit card required).
33
+ Get your free API key at [hifriendbot.com/wallet](https://hifriendbot.com/wallet) — no credit card required, no KYC, no approval wait.
31
34
 
32
35
  ### Claude Desktop / OpenClaw
33
36
 
@@ -41,19 +44,23 @@ Add to your config:
41
44
  "args": ["-y", "agentwallet-mcp"],
42
45
  "env": {
43
46
  "AGENTWALLET_USER": "your_username",
44
- "AGENTWALLET_PASS": "your_api_key"
47
+ "AGENTWALLET_PASS": "your_api_key",
48
+ "AGENTWALLET_WALLET_ID": "1"
45
49
  }
46
50
  }
47
51
  }
48
52
  }
49
53
  ```
50
54
 
55
+ > `AGENTWALLET_WALLET_ID` is optional. Set it to enable x402 auto-pay — when you exceed the free tier without a credit card, the MCP server will automatically pay for operations with USDC from this wallet.
56
+
51
57
  ### Claude Code
52
58
 
53
59
  ```bash
54
60
  claude mcp add agentwallet \
55
61
  -e AGENTWALLET_USER=your_username \
56
62
  -e AGENTWALLET_PASS=your_api_key \
63
+ -e AGENTWALLET_WALLET_ID=1 \
57
64
  -- npx -y agentwallet-mcp
58
65
  ```
59
66
 
@@ -70,7 +77,8 @@ Add to your settings:
70
77
  "args": ["-y", "agentwallet-mcp"],
71
78
  "env": {
72
79
  "AGENTWALLET_USER": "your_username",
73
- "AGENTWALLET_PASS": "your_api_key"
80
+ "AGENTWALLET_PASS": "your_api_key",
81
+ "AGENTWALLET_WALLET_ID": "1"
74
82
  }
75
83
  }
76
84
  }
@@ -105,6 +113,7 @@ Add to your settings:
105
113
  | `delete_paywall` | Delete a paywall |
106
114
  | `get_paywall_payments` | View payment history for a paywall |
107
115
  | `get_x402_revenue` | Aggregate revenue stats across all paywalls |
116
+ | `buy_verification_credits` | Buy x402 verification credits with USDC on-chain |
108
117
  | `get_usage` | Check your monthly usage and billing |
109
118
  | `get_chains` | List all supported chains |
110
119
  | `pause_wallet` | Emergency pause a wallet |
@@ -185,12 +194,46 @@ When an agent hits the paywall URL:
185
194
 
186
195
  On-chain verification ensures every payment is real. Replay protection prevents double-spending. Revenue tracking shows you who paid, how much, and when. 1,000 free verifications/month, then $0.0005 each — 50% less expensive than Coinbase.
187
196
 
188
- ## Security
189
-
190
- - Private keys are generated server-side and encrypted at rest
191
- - Keys are decrypted only during transaction signing and zeroed from memory immediately after
192
- - EIP-1559 transactions on EVM with gas safety caps
193
- - Ed25519 signing on Solana with finalized commitment level
197
+ ## How We Compare
198
+
199
+ | Feature | Coinbase CDP | AgentWallet |
200
+ |---------|-------------|-------------|
201
+ | Setup Time | Install SDK + configure | **3 lines of config** |
202
+ | Approval Process | Identity verification required | **None — instant access** |
203
+ | KYC Required | Yes | **No** |
204
+ | KYT / Transaction Monitoring | Yes | **No** |
205
+ | Can Block Your Wallet | Yes | **No** |
206
+ | Built-in Guards | Yes (requires setup) | **Yes (active by default)** |
207
+ | Free Operations / Month | 5,000 | **6,000** |
208
+ | Cost Per Operation | $0.005 | **$0.00345** |
209
+ | x402 Verification Cost | $0.001 | **$0.0005** |
210
+ | Free x402 Verifications / Month | 1,000 | **1,000** |
211
+ | x402 Acceptance (Paywalls) | No | **Yes** |
212
+ | Pay for API Fees with Crypto | No (credit card only) | **Yes (USDC via x402)** |
213
+ | Supported Chains | 8 EVM + Solana | **Any EVM + Solana** |
214
+ | Token Tools | Yes | **ERC-20 + SPL (29 tools)** |
215
+ | MCP Server | Yes | **Yes** |
216
+
217
+ ## Pay with Crypto — No Credit Card Required
218
+
219
+ AgentWallet is the only AI agent wallet infrastructure that accepts crypto for its own API fees. Every competitor — Coinbase CDP, Circle, MoonPay, Crossmint, Turnkey — requires a credit card or monthly invoice. With AgentWallet, your agent can pay for operations with USDC on-chain via the x402 protocol. No credit card, no invoice, no billing portal. Just on-chain payments.
220
+
221
+ When your agent exceeds the free tier (6,000 ops/month) without a credit card configured, the API returns HTTP 402 with USDC payment instructions. Your agent pays on-chain, retries with proof of payment, and the operation executes. Fully automated via the MCP server.
222
+
223
+ You can also pre-purchase x402 verification credits with USDC using the `buy_verification_credits` tool — keeping your paywalls running beyond the free 1,000 verifications/month without needing a credit card.
224
+
225
+ ## Built-in Guards
226
+
227
+ All guards are active by default — no configuration required.
228
+
229
+ - **Encrypted at rest** — private keys encrypted before storage and never leave the server
230
+ - **Memory zeroing** — keys wiped from memory immediately after every signing operation
231
+ - **Daily spending limits** — set a per-wallet daily cap in USD, enforced automatically on every transaction
232
+ - **Gas price protection** — transactions blocked when gas prices spike above safe thresholds
233
+ - **Emergency pause** — instantly freeze any wallet or all wallets with one click
234
+ - **Rate limiting** — API requests capped per minute to prevent abuse and brute force attacks
235
+ - **Replay protection** — every x402 payment verified on-chain with unique transaction tracking
236
+ - **On-chain verification** — x402 payments verified directly on the blockchain with finalized commitment
194
237
  - Bug bounty program: $50–$500 for responsible disclosure ([details](https://hifriendbot.com/wallet))
195
238
 
196
239
  ## Links
package/build/index.js CHANGED
@@ -16,13 +16,17 @@ import { z } from 'zod';
16
16
  const API_BASE = process.env.AGENTWALLET_API_URL || 'https://hifriendbot.com/wp-json/agentwallet/v1';
17
17
  const API_USER = process.env.AGENTWALLET_USER || '';
18
18
  const API_PASS = process.env.AGENTWALLET_PASS || ''; // WordPress application password
19
- // ─── API Helper ─────────────────────────────────────────────────
20
- async function api(path, method = 'GET', body) {
19
+ const X402_WALLET_ID = process.env.AGENTWALLET_WALLET_ID || ''; // Wallet ID for x402 auto-pay
20
+ /**
21
+ * Make an API call. If the response is 402 and auto-pay is configured,
22
+ * automatically pay via x402 and retry the request.
23
+ */
24
+ async function api(path, method = 'GET', body, extraHeaders) {
21
25
  const url = `${API_BASE}${path}`;
22
26
  const headers = {
23
27
  'Content-Type': 'application/json',
28
+ ...extraHeaders,
24
29
  };
25
- // Add basic auth if credentials provided
26
30
  if (API_USER && API_PASS) {
27
31
  headers['Authorization'] = 'Basic ' + Buffer.from(`${API_USER}:${API_PASS}`).toString('base64');
28
32
  }
@@ -32,12 +36,80 @@ async function api(path, method = 'GET', body) {
32
36
  }
33
37
  const res = await fetch(url, options);
34
38
  const data = await res.json();
39
+ // Handle 402 Payment Required — auto-pay if wallet configured
40
+ if (res.status === 402 && X402_WALLET_ID && !extraHeaders?.['X-PAYMENT']) {
41
+ return handleX402Payment(data, path, method, body);
42
+ }
35
43
  if (!res.ok) {
36
44
  const error = data.error || `HTTP ${res.status}`;
37
45
  throw new Error(error);
38
46
  }
39
47
  return data;
40
48
  }
49
+ /**
50
+ * Handle x402 auto-payment: pay on-chain, then retry the original request
51
+ */
52
+ async function handleX402Payment(x402Data, originalPath, originalMethod, originalBody) {
53
+ const accepts = x402Data.accepts;
54
+ if (!accepts || accepts.length === 0) {
55
+ throw new Error('402 Payment Required but no payment options available.');
56
+ }
57
+ const accept = accepts[0]; // Use first option
58
+ const tokenAddress = accept.extra?.token || '';
59
+ const amount = accept.maxAmountRequired;
60
+ const payTo = accept.payTo;
61
+ const decimals = accept.requiredDecimals || 6;
62
+ // Determine chain_id from network string (CAIP-2, plain name, or raw ID)
63
+ const network = accept.network || '';
64
+ const chainId = resolveChainId(network) ?? 8453;
65
+ // Convert human-readable amount to raw (e.g. "0.01" with 6 decimals = "10000")
66
+ const rawAmount = parseUnits(amount, decimals);
67
+ // Send payment using our wallet (with X-AGW-SKIP-X402 to prevent recursion)
68
+ let txHash;
69
+ try {
70
+ if (tokenAddress) {
71
+ // ERC-20/SPL token transfer
72
+ const isSOL = isSolanaChain(chainId);
73
+ const sendResult = await api(`/wallets/${X402_WALLET_ID}/send`, 'POST', isSOL
74
+ ? { chain_id: chainId, to: payTo, value: rawAmount, token_mint: tokenAddress, token_decimals: decimals }
75
+ : { chain_id: chainId, to: tokenAddress, value: '0', data: buildErc20TransferData(payTo, rawAmount) }, { 'X-AGW-SKIP-X402': 'true' });
76
+ txHash = sendResult.tx_hash || sendResult.signature || '';
77
+ }
78
+ else {
79
+ // Native transfer
80
+ const sendResult = await api(`/wallets/${X402_WALLET_ID}/send`, 'POST', { chain_id: chainId, to: payTo, value: rawAmount }, { 'X-AGW-SKIP-X402': 'true' });
81
+ txHash = sendResult.tx_hash || sendResult.signature || '';
82
+ }
83
+ }
84
+ catch (e) {
85
+ throw new Error(`x402 auto-pay failed: ${e.message}. Original error: ${x402Data.error}`);
86
+ }
87
+ if (!txHash) {
88
+ throw new Error('x402 auto-pay: no transaction hash returned.');
89
+ }
90
+ // Build X-PAYMENT header (base64-encoded JSON proof)
91
+ const proof = {
92
+ x402Version: 1,
93
+ scheme: 'exact',
94
+ network: network,
95
+ payload: { txHash },
96
+ };
97
+ const paymentHeader = Buffer.from(JSON.stringify(proof)).toString('base64');
98
+ // Wait briefly for tx confirmation (EVM ~2s, Solana ~6s)
99
+ const waitMs = isSolanaChain(chainId) ? 8000 : 3000;
100
+ await new Promise(resolve => setTimeout(resolve, waitMs));
101
+ // Retry original request with payment proof
102
+ return api(originalPath, originalMethod, originalBody, { 'X-PAYMENT': paymentHeader });
103
+ }
104
+ /**
105
+ * Build ERC-20 transfer(address,uint256) calldata
106
+ */
107
+ function buildErc20TransferData(to, amount) {
108
+ // transfer(address,uint256) selector = 0xa9059cbb
109
+ const addressPadded = to.slice(2).toLowerCase().padStart(64, '0');
110
+ const amountHex = BigInt(amount).toString(16).padStart(64, '0');
111
+ return '0xa9059cbb' + addressPadded + amountHex;
112
+ }
41
113
  function jsonResponse(data) {
42
114
  return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
43
115
  }
@@ -615,8 +687,8 @@ server.tool('pay_x402', 'Handle an x402 payment flow. Fetches a URL, and if the
615
687
  if (blockedHosts.includes(hostname) || blockedPrefixes.some(p => hostname.startsWith(p))) {
616
688
  throw new Error('URL points to a private/internal address. Only public URLs are allowed.');
617
689
  }
618
- if (!['http:', 'https:'].includes(urlObj.protocol)) {
619
- throw new Error('Only http: and https: URLs are supported.');
690
+ if (urlObj.protocol !== 'https:') {
691
+ throw new Error('Only HTTPS URLs are supported for x402 payments.');
620
692
  }
621
693
  // Step 1: Make initial request
622
694
  const reqOptions = {
@@ -783,6 +855,17 @@ server.tool('get_usage', 'Get the current month\'s usage statistics. ' +
783
855
  const data = await api('/usage');
784
856
  return jsonResponse(data);
785
857
  });
858
+ // ─── Tool: buy_verification_credits ─────────────────────────────
859
+ server.tool('buy_verification_credits', 'Buy x402 verification credits with USDC on-chain. ' +
860
+ 'Paywall owners need credits to process verifications beyond the free tier (1,000/month) ' +
861
+ 'when they don\'t have Stripe billing configured. ' +
862
+ 'Returns 402 payment instructions — pay on-chain and retry with proof.', {
863
+ count: z.number().int().min(100).default(1000)
864
+ .describe('Number of verification credits to purchase (min 100, default 1000)'),
865
+ }, async ({ count }) => {
866
+ const data = await api('/billing/verification-credits', 'POST', { count });
867
+ return jsonResponse(data);
868
+ });
786
869
  // ─── Tool: pause_wallet ──────────────────────────────────────────
787
870
  server.tool('pause_wallet', 'Emergency pause a wallet. No transactions can be signed while paused.', {
788
871
  wallet_id: z.number().int().describe('Wallet ID to pause'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentwallet-mcp",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "description": "MCP server for AgentWallet — lets AI agents create wallets, sign transactions, broadcast on EVM + Solana, pay x402 invoices, and accept x402 payments",
5
5
  "type": "module",
6
6
  "main": "build/index.js",