agentwallet-mcp 1.7.1 → 1.7.3
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 +165 -6
- 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
|
}
|
|
@@ -144,7 +216,83 @@ function resolveChainId(network) {
|
|
|
144
216
|
// ─── Server ──────────────────────────────────────────────────────
|
|
145
217
|
const server = new McpServer({
|
|
146
218
|
name: 'agentwallet',
|
|
147
|
-
version: '1.7.
|
|
219
|
+
version: '1.7.2',
|
|
220
|
+
}, {
|
|
221
|
+
instructions: `AgentWallet gives AI agents their own blockchain wallets. Private keys are encrypted server-side and never exposed — agents sign and broadcast transactions without ever touching raw keys.
|
|
222
|
+
|
|
223
|
+
## Getting Started
|
|
224
|
+
1. Call list_wallets to see existing wallets, or create_wallet to make a new one.
|
|
225
|
+
2. Fund the wallet by sending tokens to its address from an external source.
|
|
226
|
+
3. Use transfer (native tokens) or transfer_token (ERC-20/SPL tokens) to send funds.
|
|
227
|
+
|
|
228
|
+
## Supported Chains
|
|
229
|
+
- **EVM chains:** Ethereum (1), Base (8453), Arbitrum (42161), Optimism (10), Polygon (137), Avalanche (43114), BSC (56), Zora (7777777), PulseChain (369)
|
|
230
|
+
- **Solana:** Mainnet (900), Devnet (901)
|
|
231
|
+
- Call get_chains for the full list with native tokens and stablecoin contract addresses.
|
|
232
|
+
|
|
233
|
+
## EVM vs Solana
|
|
234
|
+
- **Addresses:** EVM uses 0x-prefixed hex (42 chars). Solana uses Base58 (32-44 chars).
|
|
235
|
+
- **Native tokens:** EVM = ETH/POL/BNB/etc (18 decimals, wei). Solana = SOL (9 decimals, lamports).
|
|
236
|
+
- **Token standards:** EVM uses ERC-20. Solana uses SPL tokens.
|
|
237
|
+
- **EVM-only tools:** approve_token, get_allowance, wrap_eth, unwrap_eth, call_contract, get_token_info. These do not work on Solana.
|
|
238
|
+
- **Works on both:** create_wallet, transfer, transfer_token, send_transaction, sign_transaction, get_balance, get_token_balance.
|
|
239
|
+
|
|
240
|
+
## Common Workflows
|
|
241
|
+
|
|
242
|
+
### Send native tokens (ETH, SOL, etc.)
|
|
243
|
+
Use the transfer tool with a human-readable amount (e.g. "0.1" ETH). It auto-converts to wei/lamports.
|
|
244
|
+
|
|
245
|
+
### Send ERC-20 or SPL tokens
|
|
246
|
+
Use transfer_token. You need: wallet_id, token contract address, recipient, amount, chain_id, and decimals (6 for USDC, 18 for most ERC-20s). Call get_chains to find stablecoin addresses.
|
|
247
|
+
|
|
248
|
+
### Interact with DeFi (EVM only)
|
|
249
|
+
1. Check allowance with get_allowance.
|
|
250
|
+
2. If needed, call approve_token to let the DeFi contract spend your tokens.
|
|
251
|
+
3. Use send_transaction with the contract's calldata to execute the interaction.
|
|
252
|
+
|
|
253
|
+
### Wrap/unwrap native tokens (EVM only)
|
|
254
|
+
Use wrap_eth to convert ETH → WETH (required by many DeFi protocols). Use unwrap_eth to convert back.
|
|
255
|
+
|
|
256
|
+
### Read on-chain data (EVM only)
|
|
257
|
+
Use call_contract for gas-free read-only calls (eth_call). Provide ABI-encoded calldata.
|
|
258
|
+
|
|
259
|
+
## x402 Payments — Paying for Resources
|
|
260
|
+
The pay_x402 tool handles the full x402 payment flow automatically:
|
|
261
|
+
1. Fetches the URL.
|
|
262
|
+
2. If the server returns HTTP 402, parses the payment requirements.
|
|
263
|
+
3. Pays on-chain using your wallet.
|
|
264
|
+
4. Retries the request with proof of payment.
|
|
265
|
+
Always set max_payment to prevent overspending (e.g. "1.00" for max 1 USDC).
|
|
266
|
+
|
|
267
|
+
## x402 Paywalls — Accepting Payments
|
|
268
|
+
Create paywalls to charge other agents for accessing your resources:
|
|
269
|
+
1. create_paywall — set price, token, chain, and the resource URL to protect.
|
|
270
|
+
2. Share the access URL. Clients that pay on-chain get the resource; others get HTTP 402.
|
|
271
|
+
3. list_paywalls and get_paywall_payments to track revenue.
|
|
272
|
+
4. get_x402_revenue for aggregate stats across all paywalls.
|
|
273
|
+
|
|
274
|
+
## Wallet Security
|
|
275
|
+
- Use pause_wallet to immediately freeze a wallet if compromised. No transactions can be signed while paused.
|
|
276
|
+
- Use unpause_wallet to resume operations.
|
|
277
|
+
- Use delete_wallet to permanently disable a wallet.
|
|
278
|
+
- Wallets have server-enforced spending limits.
|
|
279
|
+
|
|
280
|
+
## Tool Selection Guide
|
|
281
|
+
| Goal | Tool |
|
|
282
|
+
|------|------|
|
|
283
|
+
| Send ETH/SOL/native tokens | transfer |
|
|
284
|
+
| Send USDC/ERC-20/SPL tokens | transfer_token |
|
|
285
|
+
| Check native balance | get_balance |
|
|
286
|
+
| Check token balance | get_token_balance |
|
|
287
|
+
| Look up token details | get_token_info (EVM only) |
|
|
288
|
+
| Approve DeFi spending | approve_token (EVM only) |
|
|
289
|
+
| Check approval amount | get_allowance (EVM only) |
|
|
290
|
+
| Read smart contract | call_contract (EVM only) |
|
|
291
|
+
| Custom transaction | send_transaction |
|
|
292
|
+
| Sign without broadcasting | sign_transaction |
|
|
293
|
+
| Pay for x402 resource | pay_x402 |
|
|
294
|
+
| Charge for your resource | create_paywall |
|
|
295
|
+
| Check usage/billing | get_usage |`,
|
|
148
296
|
});
|
|
149
297
|
// ─── Tool: create_wallet ─────────────────────────────────────────
|
|
150
298
|
server.tool('create_wallet', 'Create a new EVM or Solana wallet. Returns the wallet ID and address. ' +
|
|
@@ -615,8 +763,8 @@ server.tool('pay_x402', 'Handle an x402 payment flow. Fetches a URL, and if the
|
|
|
615
763
|
if (blockedHosts.includes(hostname) || blockedPrefixes.some(p => hostname.startsWith(p))) {
|
|
616
764
|
throw new Error('URL points to a private/internal address. Only public URLs are allowed.');
|
|
617
765
|
}
|
|
618
|
-
if (
|
|
619
|
-
throw new Error('Only
|
|
766
|
+
if (urlObj.protocol !== 'https:') {
|
|
767
|
+
throw new Error('Only HTTPS URLs are supported for x402 payments.');
|
|
620
768
|
}
|
|
621
769
|
// Step 1: Make initial request
|
|
622
770
|
const reqOptions = {
|
|
@@ -783,6 +931,17 @@ server.tool('get_usage', 'Get the current month\'s usage statistics. ' +
|
|
|
783
931
|
const data = await api('/usage');
|
|
784
932
|
return jsonResponse(data);
|
|
785
933
|
});
|
|
934
|
+
// ─── Tool: buy_verification_credits ─────────────────────────────
|
|
935
|
+
server.tool('buy_verification_credits', 'Buy x402 verification credits with USDC on-chain. ' +
|
|
936
|
+
'Paywall owners need credits to process verifications beyond the free tier (1,000/month) ' +
|
|
937
|
+
'when they don\'t have Stripe billing configured. ' +
|
|
938
|
+
'Returns 402 payment instructions — pay on-chain and retry with proof.', {
|
|
939
|
+
count: z.number().int().min(100).default(1000)
|
|
940
|
+
.describe('Number of verification credits to purchase (min 100, default 1000)'),
|
|
941
|
+
}, async ({ count }) => {
|
|
942
|
+
const data = await api('/billing/verification-credits', 'POST', { count });
|
|
943
|
+
return jsonResponse(data);
|
|
944
|
+
});
|
|
786
945
|
// ─── Tool: pause_wallet ──────────────────────────────────────────
|
|
787
946
|
server.tool('pause_wallet', 'Emergency pause a wallet. No transactions can be signed while paused.', {
|
|
788
947
|
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.3",
|
|
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",
|