agentwallet-mcp 1.7.1 → 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.
- package/README.md +24 -6
- package/build/index.js +88 -5
- 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. Built-in guards. No KYC.
|
|
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 approval process. 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,7 +10,7 @@ Permissionless wallet infrastructure for AI agents. Create wallets, sign transac
|
|
|
10
10
|
|
|
11
11
|
## Features
|
|
12
12
|
|
|
13
|
-
- **
|
|
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
16
|
- **Built-in guards** — daily spending limits, gas price protection, emergency pause, rate limiting, replay protection, and on-chain verification — all active by default
|
|
@@ -25,6 +25,7 @@ Permissionless wallet infrastructure for AI agents. Create wallets, sign transac
|
|
|
25
25
|
- **6,000 free operations/month**
|
|
26
26
|
- **$0.0005 per x402 verification** (50% less expensive than Coinbase)
|
|
27
27
|
- **1,000 free x402 verifications/month**
|
|
28
|
+
- **Pay with USDC on-chain** via x402 — no credit card required
|
|
28
29
|
- No monthly fee, no tiers — just pay as you go
|
|
29
30
|
|
|
30
31
|
## Quick Start
|
|
@@ -43,19 +44,23 @@ Add to your config:
|
|
|
43
44
|
"args": ["-y", "agentwallet-mcp"],
|
|
44
45
|
"env": {
|
|
45
46
|
"AGENTWALLET_USER": "your_username",
|
|
46
|
-
"AGENTWALLET_PASS": "your_api_key"
|
|
47
|
+
"AGENTWALLET_PASS": "your_api_key",
|
|
48
|
+
"AGENTWALLET_WALLET_ID": "1"
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
```
|
|
52
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
|
+
|
|
53
57
|
### Claude Code
|
|
54
58
|
|
|
55
59
|
```bash
|
|
56
60
|
claude mcp add agentwallet \
|
|
57
61
|
-e AGENTWALLET_USER=your_username \
|
|
58
62
|
-e AGENTWALLET_PASS=your_api_key \
|
|
63
|
+
-e AGENTWALLET_WALLET_ID=1 \
|
|
59
64
|
-- npx -y agentwallet-mcp
|
|
60
65
|
```
|
|
61
66
|
|
|
@@ -72,7 +77,8 @@ Add to your settings:
|
|
|
72
77
|
"args": ["-y", "agentwallet-mcp"],
|
|
73
78
|
"env": {
|
|
74
79
|
"AGENTWALLET_USER": "your_username",
|
|
75
|
-
"AGENTWALLET_PASS": "your_api_key"
|
|
80
|
+
"AGENTWALLET_PASS": "your_api_key",
|
|
81
|
+
"AGENTWALLET_WALLET_ID": "1"
|
|
76
82
|
}
|
|
77
83
|
}
|
|
78
84
|
}
|
|
@@ -107,6 +113,7 @@ Add to your settings:
|
|
|
107
113
|
| `delete_paywall` | Delete a paywall |
|
|
108
114
|
| `get_paywall_payments` | View payment history for a paywall |
|
|
109
115
|
| `get_x402_revenue` | Aggregate revenue stats across all paywalls |
|
|
116
|
+
| `buy_verification_credits` | Buy x402 verification credits with USDC on-chain |
|
|
110
117
|
| `get_usage` | Check your monthly usage and billing |
|
|
111
118
|
| `get_chains` | List all supported chains |
|
|
112
119
|
| `pause_wallet` | Emergency pause a wallet |
|
|
@@ -200,9 +207,20 @@ On-chain verification ensures every payment is real. Replay protection prevents
|
|
|
200
207
|
| Free Operations / Month | 5,000 | **6,000** |
|
|
201
208
|
| Cost Per Operation | $0.005 | **$0.00345** |
|
|
202
209
|
| x402 Verification Cost | $0.001 | **$0.0005** |
|
|
210
|
+
| Free x402 Verifications / Month | 1,000 | **1,000** |
|
|
203
211
|
| x402 Acceptance (Paywalls) | No | **Yes** |
|
|
212
|
+
| Pay for API Fees with Crypto | No (credit card only) | **Yes (USDC via x402)** |
|
|
204
213
|
| Supported Chains | 8 EVM + Solana | **Any EVM + Solana** |
|
|
205
|
-
| Token Tools | Yes | **ERC-20 + SPL (
|
|
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.
|
|
206
224
|
|
|
207
225
|
## Built-in Guards
|
|
208
226
|
|
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
|
-
//
|
|
20
|
-
|
|
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 (
|
|
619
|
-
throw new Error('Only
|
|
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.
|
|
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",
|