agentpay-mcp 1.2.0 → 4.0.0

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 (79) hide show
  1. package/.env.example +37 -0
  2. package/LICENSE +21 -0
  3. package/README.md +732 -33
  4. package/claude_desktop_config.json +17 -0
  5. package/dist/index.d.ts +3 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +248 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/session/manager.d.ts +90 -0
  10. package/dist/session/manager.d.ts.map +1 -0
  11. package/dist/session/manager.js +262 -0
  12. package/dist/session/manager.js.map +1 -0
  13. package/dist/session/types.d.ts +113 -0
  14. package/dist/session/types.d.ts.map +1 -0
  15. package/dist/session/types.js +16 -0
  16. package/dist/session/types.js.map +1 -0
  17. package/dist/tools/bridge.d.ts +52 -0
  18. package/dist/tools/bridge.d.ts.map +1 -0
  19. package/dist/tools/bridge.js +97 -0
  20. package/dist/tools/bridge.js.map +1 -0
  21. package/dist/tools/budget.d.ts +84 -0
  22. package/dist/tools/budget.d.ts.map +1 -0
  23. package/dist/tools/budget.js +163 -0
  24. package/dist/tools/budget.js.map +1 -0
  25. package/dist/tools/deploy.d.ts +49 -0
  26. package/dist/tools/deploy.d.ts.map +1 -0
  27. package/dist/tools/deploy.js +123 -0
  28. package/dist/tools/deploy.js.map +1 -0
  29. package/dist/tools/escrow.d.ts +73 -0
  30. package/dist/tools/escrow.d.ts.map +1 -0
  31. package/dist/tools/escrow.js +146 -0
  32. package/dist/tools/escrow.js.map +1 -0
  33. package/dist/tools/history.d.ts +59 -0
  34. package/dist/tools/history.d.ts.map +1 -0
  35. package/dist/tools/history.js +202 -0
  36. package/dist/tools/history.js.map +1 -0
  37. package/dist/tools/identity.d.ts +65 -0
  38. package/dist/tools/identity.d.ts.map +1 -0
  39. package/dist/tools/identity.js +158 -0
  40. package/dist/tools/identity.js.map +1 -0
  41. package/dist/tools/payments.d.ts +71 -0
  42. package/dist/tools/payments.d.ts.map +1 -0
  43. package/dist/tools/payments.js +158 -0
  44. package/dist/tools/payments.js.map +1 -0
  45. package/dist/tools/session.d.ts +240 -0
  46. package/dist/tools/session.d.ts.map +1 -0
  47. package/dist/tools/session.js +678 -0
  48. package/dist/tools/session.js.map +1 -0
  49. package/dist/tools/swap.d.ts +65 -0
  50. package/dist/tools/swap.d.ts.map +1 -0
  51. package/dist/tools/swap.js +101 -0
  52. package/dist/tools/swap.js.map +1 -0
  53. package/dist/tools/tokens.d.ts +129 -0
  54. package/dist/tools/tokens.d.ts.map +1 -0
  55. package/dist/tools/tokens.js +138 -0
  56. package/dist/tools/tokens.js.map +1 -0
  57. package/dist/tools/transfers.d.ts +86 -0
  58. package/dist/tools/transfers.d.ts.map +1 -0
  59. package/dist/tools/transfers.js +136 -0
  60. package/dist/tools/transfers.js.map +1 -0
  61. package/dist/tools/wallet.d.ts +107 -0
  62. package/dist/tools/wallet.d.ts.map +1 -0
  63. package/dist/tools/wallet.js +271 -0
  64. package/dist/tools/wallet.js.map +1 -0
  65. package/dist/tools/x402.d.ts +90 -0
  66. package/dist/tools/x402.d.ts.map +1 -0
  67. package/dist/tools/x402.js +268 -0
  68. package/dist/tools/x402.js.map +1 -0
  69. package/dist/utils/client.d.ts +46 -0
  70. package/dist/utils/client.d.ts.map +1 -0
  71. package/dist/utils/client.js +123 -0
  72. package/dist/utils/client.js.map +1 -0
  73. package/dist/utils/format.d.ts +59 -0
  74. package/dist/utils/format.d.ts.map +1 -0
  75. package/dist/utils/format.js +161 -0
  76. package/dist/utils/format.js.map +1 -0
  77. package/package.json +62 -12
  78. package/index.d.ts +0 -1
  79. package/index.js +0 -13
package/README.md CHANGED
@@ -1,54 +1,753 @@
1
- # agentpay-mcp
1
+ # AgentPay MCP
2
2
 
3
- Non-custodial x402 payment layer for AI agents. Part of the [AI Agent Economy](https://ai-agent-economy.com) ecosystem.
3
+ [![npm version](https://img.shields.io/npm/v/agentpay-mcp.svg)](https://www.npmjs.com/package/agentpay-mcp)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
5
+ [![Tests](https://img.shields.io/badge/tests-149%20passing-brightgreen.svg)](tests/)
6
+ [![Patent Pending](https://img.shields.io/badge/patent-pending-orange.svg)](https://uspto.gov)
4
7
 
5
- > **Previously known as:** `clawpay-mcp`renamed as part of the AI Agent Economy rebrand.
8
+ > MCP server that gives AI agents a complete crypto wallet send tokens, swap, bridge, manage budgets, verify identity.
6
9
 
7
- ## Install
10
+ **Patent Pending** — USPTO provisional filed March 2026.
11
+
12
+ Built by [AI Agent Economy](https://ai-agent-economy.com). Payment infrastructure integrated into **NVIDIA's official NeMo Agent Toolkit Examples catalog**.
13
+
14
+ ---
15
+
16
+ ## What's New in v4.0.0
17
+
18
+ **11 new MCP tools** powered by full **agentwallet-sdk v6.0.0** integration:
19
+
20
+ | Category | New Tools |
21
+ |---|---|
22
+ | Token Registry | `lookup_token`, `add_custom_token`, `list_chain_tokens` |
23
+ | Token Transfers | `send_token`, `get_balances` |
24
+ | DeFi | `swap_tokens` (Uniswap V3), `bridge_usdc` (CCTP V2) |
25
+ | Spending Controls | `set_spend_policy`, `check_budget` |
26
+ | Agent Identity | `verify_agent_identity`, `get_reputation` |
27
+ | Escrow | `create_escrow` |
28
+
29
+ Other highlights:
30
+ - **12 supported chains** — Base, Ethereum, Arbitrum, Optimism, Polygon, Avalanche, Linea, Unichain, Sonic, Worldchain, Base Sepolia, Arbitrum Sepolia
31
+ - **100+ pre-loaded tokens** via TokenRegistry
32
+ - **CCTP V2** cross-chain USDC bridging (10 EVM chains)
33
+ - **Uniswap V3** swaps on Base, Arbitrum, Optimism, Polygon
34
+ - **ERC-8004** on-chain agent identity verification
35
+ - 42 new tests (149 total), 99.6% type coverage
36
+
37
+ ---
38
+
39
+ ## Quick Start
40
+
41
+ ### 1. Install
8
42
 
9
43
  ```bash
10
- npm install agentpay-mcp
11
- # or use the scoped package directly:
12
- npm install @agenteconomy/pay
44
+ npm install -g agentpay-mcp
13
45
  ```
14
46
 
15
- ## Features
47
+ ### 2. Environment Variables
16
48
 
17
- - **x402 protocol** HTTP-native machine-to-machine payments
18
- - **Non-custodial** — agents sign locally, no vendor holds keys
19
- - **MCP compatible** — works with Claude, Cursor, Windsurf, any MCP client
20
- - **USDC on Base** — stable, fast, low-fee
21
- - **Spend limits** — on-chain enforcement via ERC-6551
49
+ Copy `.env.example` to `.env` and fill in the required values:
22
50
 
23
- ## Quick Start
51
+ ```bash
52
+ # Required
53
+ AGENT_PRIVATE_KEY=0x... # Agent hot wallet private key (0x-prefixed hex)
54
+ AGENT_WALLET_ADDRESS=0x... # Deployed AgentAccountV2 wallet address
55
+
56
+ # Optional (defaults shown)
57
+ CHAIN_ID=8453 # 8453 = Base Mainnet (default)
58
+ RPC_URL=https://mainnet.base.org # Custom RPC URL
59
+
60
+ # For x402 session payments
61
+ SESSION_TTL_SECONDS=3600 # Session lifetime (default: 1 hour)
62
+
63
+ # For deploy_wallet tool
64
+ FACTORY_ADDRESS=0x... # AgentAccountFactoryV2 address
65
+ NFT_CONTRACT_ADDRESS=0x... # NFT contract that owns the wallet
66
+ ```
67
+
68
+ ### 3. MCP Configuration
69
+
70
+ #### Claude Desktop
71
+
72
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
73
+
74
+ ```json
75
+ {
76
+ "mcpServers": {
77
+ "agentpay": {
78
+ "command": "npx",
79
+ "args": ["agentpay-mcp"],
80
+ "env": {
81
+ "AGENT_PRIVATE_KEY": "0x...",
82
+ "AGENT_WALLET_ADDRESS": "0x...",
83
+ "CHAIN_ID": "8453"
84
+ }
85
+ }
86
+ }
87
+ }
88
+ ```
89
+
90
+ #### Cursor
91
+
92
+ Add to `.cursor/mcp.json` in your project or `~/.cursor/mcp.json` globally:
93
+
94
+ ```json
95
+ {
96
+ "mcpServers": {
97
+ "agentpay": {
98
+ "command": "npx",
99
+ "args": ["agentpay-mcp"],
100
+ "env": {
101
+ "AGENT_PRIVATE_KEY": "0x...",
102
+ "AGENT_WALLET_ADDRESS": "0x...",
103
+ "CHAIN_ID": "8453"
104
+ }
105
+ }
106
+ }
107
+ }
108
+ ```
109
+
110
+ ---
111
+
112
+ ## All 23 Tools Reference
113
+
114
+ ### Original Tools (v1.0.0–v3.1.0)
115
+
116
+ | Tool | Description | Key Parameters |
117
+ |---|---|---|
118
+ | `deploy_wallet` | Deploy a new AgentAccountV2 wallet via factory | `token_id`, `nft_contract_address?`, `factory_address?` |
119
+ | `get_wallet_info` | Wallet address, balances, spend limits, queue depth | `token?` (address) |
120
+ | `send_payment` | Send ETH or ERC-20 via AgentAccountV2 contract | `to`, `amount_eth`, `token?`, `token_decimals?`, `memo?` |
121
+ | `check_spend_limit` | Check remaining spend limit for a token | `token?` |
122
+ | `queue_approval` | Approve or cancel a queued transaction | `action`, `tx_id`, `token?` |
123
+ | `x402_pay` | Auto-pay x402 paywalled URLs | `url`, `method?`, `headers?`, `body?`, `max_payment_eth?` |
124
+ | `get_transaction_history` | Query on-chain event logs | `limit?`, `from_block?`, `to_block?`, `event_type?` |
125
+ | `x402_session_start` | Pay once, get reusable session token | `endpoint`, `scope?`, `ttl_seconds?`, `label?` |
126
+ | `x402_session_fetch` | Make calls within an active session | `url`, `method?`, `headers?`, `body?`, `session_id?` |
127
+ | `x402_session_status` | Inspect active sessions and TTL | `session_id?` |
128
+ | `x402_session_end` | Explicitly close a session | `session_id` |
129
+
130
+ ### New Tools (v4.0.0)
131
+
132
+ | Tool | Description | Key Parameters |
133
+ |---|---|---|
134
+ | `lookup_token` | Look up token address and decimals by symbol | `symbol`, `chainId` |
135
+ | `add_custom_token` | Register a custom ERC-20 in the token registry | `symbol`, `address`, `decimals`, `chainId`, `name?` |
136
+ | `list_chain_tokens` | List all registered tokens for a chain | `chainId` |
137
+ | `send_token` | Send any registry token to a recipient | `tokenSymbol`, `chainId`, `recipientAddress`, `amount` |
138
+ | `get_balances` | Get balances for multiple tokens | `chainId`, `tokens?` |
139
+ | `swap_tokens` | Swap tokens via Uniswap V3 | `fromSymbol`, `toSymbol`, `amount`, `chainId`, `slippageBps?` |
140
+ | `bridge_usdc` | Bridge USDC cross-chain via CCTP V2 | `fromChain`, `toChain`, `amount` |
141
+ | `set_spend_policy` | Configure daily limits and recipient allowlists | `dailyLimitEth?`, `perTxCapEth?`, `allowedRecipients?` |
142
+ | `check_budget` | Query on-chain remaining budget | `token?`, `spender?` |
143
+ | `verify_agent_identity` | Verify agent ERC-8004 on-chain identity | `agentAddress` |
144
+ | `get_reputation` | Fetch agent reputation score | `agentAddress` |
145
+ | `create_escrow` | Create mutual-stake USDC escrow vault | `counterpartyAddress`, `stakeAmount`, `terms`, `factoryAddress?`, `deadlineDays?`, `challengeWindowHours?` |
146
+
147
+ ---
148
+
149
+ ## Detailed Tool Documentation
150
+
151
+ ### `deploy_wallet`
152
+
153
+ Deploy a new AgentAccountV2 smart contract wallet. The wallet is deterministically addressed (CREATE2) and owned by an NFT.
154
+
155
+ **Parameters:**
156
+ | Name | Type | Required | Description |
157
+ |---|---|---|---|
158
+ | `token_id` | string | ✅ | NFT token ID that will own the wallet (e.g. `"1"`) |
159
+ | `nft_contract_address` | string | ❌ | NFT contract address (defaults to `NFT_CONTRACT_ADDRESS` env) |
160
+ | `factory_address` | string | ❌ | Factory contract address (defaults to `FACTORY_ADDRESS` env) |
161
+
162
+ **Example:**
163
+ ```json
164
+ // Request
165
+ { "token_id": "42" }
166
+
167
+ // Response
168
+ {
169
+ "walletAddress": "0xabc...def",
170
+ "txHash": "0x123...456",
171
+ "explorerUrl": "https://basescan.org/address/0xabc...def"
172
+ }
173
+ ```
174
+
175
+ ---
176
+
177
+ ### `get_wallet_info`
178
+
179
+ Get comprehensive wallet information: address, on-chain balance, spend limits, period utilization, and pending queue depth.
180
+
181
+ **Parameters:**
182
+ | Name | Type | Required | Description |
183
+ |---|---|---|---|
184
+ | `token` | string | ❌ | Token address to check budget for. Omit for ETH. |
185
+
186
+ **Example:**
187
+ ```json
188
+ // Request
189
+ {}
190
+
191
+ // Response (text)
192
+ "📊 Agent Wallet Info
193
+ 📍 Address: 0xabc...def
194
+ 🌐 Chain: Base Mainnet
195
+ 💰 ETH Balance: 0.05 ETH
196
+ 📈 Spend Limits (ETH)
197
+ Per-tx limit: 0.01 ETH
198
+ Period limit: 0.1 ETH
199
+ Remaining: 0.085 ETH
200
+ Utilization: 15% 🟢"
201
+ ```
202
+
203
+ ---
204
+
205
+ ### `send_payment`
206
+
207
+ Execute an ETH or ERC-20 transfer via the AgentAccountV2 contract. Subject to on-chain spend limits.
208
+
209
+ **Parameters:**
210
+ | Name | Type | Required | Description |
211
+ |---|---|---|---|
212
+ | `to` | string | ✅ | Recipient address (0x-prefixed) |
213
+ | `amount_eth` | string | ✅ | Amount in ETH (or token's human-readable units) |
214
+ | `token` | string | ❌ | ERC-20 contract address. Omit for native ETH. |
215
+ | `token_decimals` | number | ❌ | Token decimals (default: 18; use 6 for USDC) |
216
+ | `memo` | string | ❌ | Optional memo (logged locally, not on-chain) |
217
+
218
+ **Example:**
219
+ ```json
220
+ // Request
221
+ { "to": "0xrecipient...", "amount_eth": "0.01" }
222
+
223
+ // Response
224
+ "✅ Payment sent: 0.01 ETH → 0xrecipient...
225
+ Tx: 0xtxhash..."
226
+ ```
227
+
228
+ ---
229
+
230
+ ### `check_spend_limit`
231
+
232
+ Check the remaining spend limit for the current period for a given token.
233
+
234
+ **Parameters:**
235
+ | Name | Type | Required | Description |
236
+ |---|---|---|---|
237
+ | `token` | string | ❌ | Token address (omit for ETH) |
238
+
239
+ ---
240
+
241
+ ### `queue_approval`
242
+
243
+ Approve or cancel a queued transaction that exceeded the per-tx cap.
244
+
245
+ **Parameters:**
246
+ | Name | Type | Required | Description |
247
+ |---|---|---|---|
248
+ | `action` | string | ✅ | `"approve"` or `"cancel"` |
249
+ | `tx_id` | string | ✅ | Queued transaction ID |
250
+ | `token` | string | ❌ | Token address (omit for ETH) |
251
+
252
+ ---
253
+
254
+ ### `x402_pay`
255
+
256
+ Fetch a URL, automatically handling HTTP 402 Payment Required by paying with the Agent Wallet and retrying. Supports auto-session detection — if an active session covers the URL, no new payment is made.
257
+
258
+ **Parameters:**
259
+ | Name | Type | Required | Description |
260
+ |---|---|---|---|
261
+ | `url` | string | ✅ | URL to fetch |
262
+ | `method` | string | ❌ | HTTP method (default: `GET`) |
263
+ | `headers` | object | ❌ | Additional request headers |
264
+ | `body` | string | ❌ | Request body (JSON string for JSON APIs) |
265
+ | `max_payment_eth` | string | ❌ | Max ETH to pay (rejects if exceeded) |
266
+ | `timeout_ms` | number | ❌ | Timeout in ms (default: 30000) |
267
+ | `skip_session_check` | boolean | ❌ | Force fresh payment even if session exists |
268
+
269
+ **Example:**
270
+ ```json
271
+ // Request
272
+ { "url": "https://api.example.com/data", "max_payment_eth": "0.001" }
273
+
274
+ // Response
275
+ { "status": 200, "body": "{ ... }" }
276
+ ```
277
+
278
+ ---
279
+
280
+ ### `get_transaction_history`
281
+
282
+ Query on-chain event logs for the wallet's transaction history. Filter by event type or block range.
283
+
284
+ **Parameters:**
285
+ | Name | Type | Required | Description |
286
+ |---|---|---|---|
287
+ | `limit` | number | ❌ | Max entries (default: 20, max: 100) |
288
+ | `from_block` | string | ❌ | Start block number (hex or decimal) |
289
+ | `to_block` | string | ❌ | End block (default: latest) |
290
+ | `event_type` | string | ❌ | Filter: `all`, `execution`, `queued`, `approved`, `cancelled`, `policy_update`, `operator_update` |
291
+
292
+ ---
293
+
294
+ ### `x402_session_start`
295
+
296
+ Pay once, receive a signed x402 V2 session token. Subsequent requests to the endpoint use the session token without additional payments.
297
+
298
+ **Parameters:**
299
+ | Name | Type | Required | Description |
300
+ |---|---|---|---|
301
+ | `endpoint` | string | ✅ | Base URL to establish a session for |
302
+ | `scope` | string | ❌ | `"prefix"` (default) or `"exact"` |
303
+ | `ttl_seconds` | number | ❌ | Session lifetime in seconds (min: 60, max: 2592000) |
304
+ | `label` | string | ❌ | Human-readable session label |
305
+
306
+ **Example:**
307
+ ```json
308
+ // Request
309
+ { "endpoint": "https://api.example.com/", "ttl_seconds": 3600 }
310
+
311
+ // Response
312
+ { "session_id": "sess_abc123", "token": "eyJ...", "expires_at": 1741000000 }
313
+ ```
314
+
315
+ ---
316
+
317
+ ### `x402_session_fetch`
318
+
319
+ Make an HTTP call within an active session. No new payment required.
320
+
321
+ **Parameters:**
322
+ | Name | Type | Required | Description |
323
+ |---|---|---|---|
324
+ | `url` | string | ✅ | URL to fetch within the session |
325
+ | `method` | string | ❌ | HTTP method (default: `GET`) |
326
+ | `headers` | object | ❌ | Additional headers |
327
+ | `body` | string | ❌ | Request body |
328
+ | `session_id` | string | ❌ | Explicit session ID (auto-detected if omitted) |
329
+
330
+ ---
331
+
332
+ ### `x402_session_status`
333
+
334
+ Inspect active sessions, TTL remaining, and call counts.
335
+
336
+ **Parameters:**
337
+ | Name | Type | Required | Description |
338
+ |---|---|---|---|
339
+ | `session_id` | string | ❌ | Specific session to inspect (omit for all active sessions) |
340
+
341
+ ---
342
+
343
+ ### `x402_session_end`
344
+
345
+ Explicitly close and invalidate a session.
346
+
347
+ **Parameters:**
348
+ | Name | Type | Required | Description |
349
+ |---|---|---|---|
350
+ | `session_id` | string | ✅ | Session ID to close |
351
+
352
+ ---
353
+
354
+ ### `lookup_token`
355
+
356
+ Look up a token's address, decimals, and metadata from the global token registry by symbol and chain.
357
+
358
+ **Parameters:**
359
+ | Name | Type | Required | Description |
360
+ |---|---|---|---|
361
+ | `symbol` | string | ✅ | Token symbol (e.g. `"USDC"`, `"WETH"`) |
362
+ | `chainId` | number | ✅ | Chain ID (e.g. `8453` for Base Mainnet) |
363
+
364
+ **Example:**
365
+ ```json
366
+ // Request
367
+ { "symbol": "USDC", "chainId": 8453 }
368
+
369
+ // Response
370
+ { "found": true, "symbol": "USDC", "address": "0x833589...", "decimals": 6, "chainId": 8453 }
371
+ ```
372
+
373
+ ---
374
+
375
+ ### `add_custom_token`
376
+
377
+ Register a custom ERC-20 token in the global registry so it can be used by `send_token`, `get_balances`, and `swap_tokens`.
378
+
379
+ **Parameters:**
380
+ | Name | Type | Required | Description |
381
+ |---|---|---|---|
382
+ | `symbol` | string | ✅ | Token symbol |
383
+ | `address` | string | ✅ | Contract address (0x-prefixed) |
384
+ | `decimals` | number | ✅ | Token decimal precision (0–18) |
385
+ | `chainId` | number | ✅ | Chain ID |
386
+ | `name` | string | ❌ | Human-readable token name |
387
+
388
+ **Example:**
389
+ ```json
390
+ // Request
391
+ { "symbol": "MYTKN", "address": "0xabc...", "decimals": 18, "chainId": 8453 }
392
+
393
+ // Response
394
+ { "success": true, "message": "Token MYTKN registered on chain 8453" }
395
+ ```
396
+
397
+ ---
398
+
399
+ ### `list_chain_tokens`
400
+
401
+ List all tokens registered in the global registry for a specific chain.
402
+
403
+ **Parameters:**
404
+ | Name | Type | Required | Description |
405
+ |---|---|---|---|
406
+ | `chainId` | number | ✅ | Chain ID (e.g. `8453`) |
407
+
408
+ **Example:**
409
+ ```json
410
+ // Request
411
+ { "chainId": 8453 }
412
+
413
+ // Response
414
+ { "chainId": 8453, "count": 47, "tokens": [{ "symbol": "USDC", "address": "0x833589...", "decimals": 6 }, ...] }
415
+ ```
416
+
417
+ ---
418
+
419
+ ### `send_token`
420
+
421
+ Send any ERC-20 token using the symbol-based registry. Resolves address and decimals automatically.
24
422
 
25
- ```javascript
26
- const { AgentPay } = require('agentpay-mcp');
423
+ **Parameters:**
424
+ | Name | Type | Required | Description |
425
+ |---|---|---|---|
426
+ | `tokenSymbol` | string | ✅ | Token symbol (e.g. `"USDC"`) |
427
+ | `chainId` | number | ✅ | Chain ID |
428
+ | `recipientAddress` | string | ✅ | Recipient wallet address (0x-prefixed) |
429
+ | `amount` | string | ✅ | Amount in human-readable units (e.g. `"10.5"`) |
27
430
 
28
- const pay = new AgentPay({ wallet: yourAgentWallet });
29
- await pay.handlePaymentRequest(request402);
431
+ **Example:**
432
+ ```json
433
+ // Request
434
+ { "tokenSymbol": "USDC", "chainId": 8453, "recipientAddress": "0xrecipient...", "amount": "100" }
435
+
436
+ // Response
437
+ { "success": true, "txHash": "0x...", "amount": "100", "token": "USDC", "recipient": "0xrecipient..." }
30
438
  ```
31
439
 
32
- ## Migration from clawpay-mcp
440
+ ---
441
+
442
+ ### `get_balances`
443
+
444
+ Get token balances for the Agent Wallet across one or more tokens on a given chain.
445
+
446
+ **Parameters:**
447
+ | Name | Type | Required | Description |
448
+ |---|---|---|---|
449
+ | `chainId` | number | ✅ | Chain ID |
450
+ | `tokens` | string[] | ❌ | Token symbols to check (omit for all registered tokens on chain) |
451
+
452
+ **Example:**
453
+ ```json
454
+ // Request
455
+ { "chainId": 8453, "tokens": ["USDC", "WETH"] }
456
+
457
+ // Response
458
+ { "balances": [{ "symbol": "USDC", "balance": "500.00", "decimals": 6 }, { "symbol": "WETH", "balance": "0.05", "decimals": 18 }] }
459
+ ```
460
+
461
+ ---
462
+
463
+ ### `swap_tokens`
464
+
465
+ Swap one ERC-20 token for another using Uniswap V3. Supported chains: Base, Arbitrum, Optimism, Polygon.
466
+
467
+ **Parameters:**
468
+ | Name | Type | Required | Description |
469
+ |---|---|---|---|
470
+ | `fromSymbol` | string | ✅ | Symbol of token to sell (e.g. `"USDC"`) |
471
+ | `toSymbol` | string | ✅ | Symbol of token to buy (e.g. `"WETH"`) |
472
+ | `amount` | string | ✅ | Amount to sell in human-readable units |
473
+ | `chainId` | number | ✅ | Chain ID (8453, 42161, 10, or 137) |
474
+ | `slippageBps` | number | ❌ | Slippage in basis points (default: 50 = 0.5%) |
475
+
476
+ **Example:**
477
+ ```json
478
+ // Request
479
+ { "fromSymbol": "USDC", "toSymbol": "WETH", "amount": "100", "chainId": 8453 }
480
+
481
+ // Response
482
+ { "success": true, "txHash": "0x...", "amountIn": "100 USDC", "amountOut": "0.0412 WETH" }
483
+ ```
484
+
485
+ ---
486
+
487
+ ### `bridge_usdc`
488
+
489
+ Bridge USDC cross-chain using Circle's CCTP V2 protocol. Burns on source, polls Circle IRIS for attestation, mints on destination.
490
+
491
+ **Parameters:**
492
+ | Name | Type | Required | Description |
493
+ |---|---|---|---|
494
+ | `fromChain` | string | ✅ | Source chain name (e.g. `"base"`) |
495
+ | `toChain` | string | ✅ | Destination chain name (e.g. `"arbitrum"`) |
496
+ | `amount` | string | ✅ | Amount of USDC in human-readable units (e.g. `"100"`) |
497
+
498
+ Supported chains: `base`, `ethereum`, `optimism`, `arbitrum`, `polygon`, `avalanche`, `linea`, `unichain`, `sonic`, `worldchain`
499
+
500
+ **Example:**
501
+ ```json
502
+ // Request
503
+ { "fromChain": "base", "toChain": "arbitrum", "amount": "500" }
504
+
505
+ // Response
506
+ { "success": true, "burnTxHash": "0x...", "mintTxHash": "0x...", "amount": "500 USDC" }
507
+ ```
508
+
509
+ ---
510
+
511
+ ### `set_spend_policy`
512
+
513
+ Configure the Agent Wallet spend policy. Sets a daily limit, per-transaction cap, and optional recipient allowlist. Enforced for the lifetime of the MCP server.
514
+
515
+ **Parameters:**
516
+ | Name | Type | Required | Description |
517
+ |---|---|---|---|
518
+ | `dailyLimitEth` | string | ❌ | Daily spend limit in ETH-equivalent (e.g. `"0.1"`) |
519
+ | `perTxCapEth` | string | ❌ | Per-transaction cap in ETH-equivalent (e.g. `"0.01"`) |
520
+ | `allowedRecipients` | string[] | ❌ | Allowlist of recipient addresses. Empty = all allowed. |
521
+
522
+ **Example:**
523
+ ```json
524
+ // Request
525
+ { "dailyLimitEth": "0.5", "perTxCapEth": "0.05", "allowedRecipients": ["0xrecipient..."] }
526
+
527
+ // Response
528
+ { "success": true, "policy": { "dailyLimitEth": "0.5", "perTxCapEth": "0.05" } }
529
+ ```
530
+
531
+ ---
532
+
533
+ ### `check_budget`
534
+
535
+ Query the on-chain remaining budget for a given spender and token.
536
+
537
+ **Parameters:**
538
+ | Name | Type | Required | Description |
539
+ |---|---|---|---|
540
+ | `token` | string | ❌ | Token address (omit for ETH / zero address) |
541
+ | `spender` | string | ❌ | Spender address (defaults to Agent Wallet address) |
542
+
543
+ **Example:**
544
+ ```json
545
+ // Request
546
+ {}
547
+
548
+ // Response
549
+ { "remaining": "0.085 ETH", "spent": "0.015 ETH", "limit": "0.1 ETH", "periodEnds": "2026-03-23T00:00:00Z" }
550
+ ```
551
+
552
+ ---
553
+
554
+ ### `verify_agent_identity`
555
+
556
+ Verify an agent's on-chain identity using ERC-8004. Returns identity details including agent ID, URI, and registration file.
557
+
558
+ **Parameters:**
559
+ | Name | Type | Required | Description |
560
+ |---|---|---|---|
561
+ | `agentAddress` | string | ✅ | Agent owner address (0x-prefixed) |
562
+
563
+ **Example:**
564
+ ```json
565
+ // Request
566
+ { "agentAddress": "0xagent..." }
567
+
568
+ // Response
569
+ { "found": true, "agentId": "42", "owner": "0xagent...", "uri": "ipfs://Qm...", "registrationFile": { "name": "MyAgent", "version": "1.0" } }
570
+ ```
571
+
572
+ ---
573
+
574
+ ### `get_reputation`
575
+
576
+ Fetch an agent's on-chain reputation score and history.
577
+
578
+ **Parameters:**
579
+ | Name | Type | Required | Description |
580
+ |---|---|---|---|
581
+ | `agentAddress` | string | ✅ | Agent address (0x-prefixed) |
582
+
583
+ **Example:**
584
+ ```json
585
+ // Request
586
+ { "agentAddress": "0xagent..." }
587
+
588
+ // Response
589
+ { "agentAddress": "0xagent...", "score": 92, "level": "trusted", "totalInteractions": 1250, "successRate": 0.98 }
590
+ ```
591
+
592
+ ---
593
+
594
+ ### `create_escrow`
595
+
596
+ Create a mutual-stake escrow vault between the Agent Wallet (buyer) and a counterparty (seller). Both parties lock collateral equal to the payment amount, ensuring aligned incentives. Uses USDC as the payment token.
597
+
598
+ **Parameters:**
599
+ | Name | Type | Required | Description |
600
+ |---|---|---|---|
601
+ | `counterpartyAddress` | string | ✅ | Seller/counterparty address (0x-prefixed) |
602
+ | `stakeAmount` | string | ✅ | Payment amount in USDC (e.g. `"100"`) |
603
+ | `terms` | string | ✅ | Human-readable escrow terms |
604
+ | `factoryAddress` | string | ❌ | StakeVaultFactory address (defaults to `FACTORY_ADDRESS` env) |
605
+ | `deadlineDays` | number | ❌ | Deadline in days (default: 7) |
606
+ | `challengeWindowHours` | number | ❌ | Challenge window in hours after fulfillment (default: 24) |
607
+
608
+ **Example:**
609
+ ```json
610
+ // Request
611
+ { "counterpartyAddress": "0xseller...", "stakeAmount": "100", "terms": "Deliver logo design by 2026-04-01" }
612
+
613
+ // Response
614
+ { "success": true, "escrowAddress": "0xvault...", "txHash": "0x...", "deadline": "2026-03-29T00:00:00Z" }
615
+ ```
616
+
617
+ ---
618
+
619
+ ## Supported Chains
620
+
621
+ | Chain | Chain ID | Features |
622
+ |---|---|---|
623
+ | Base Mainnet | 8453 | All features (recommended) |
624
+ | Ethereum Mainnet | 1 | Identity, bridge, transfers |
625
+ | Arbitrum One | 42161 | All features, swaps |
626
+ | Optimism | 10 | All features, swaps |
627
+ | Polygon | 137 | All features, swaps |
628
+ | Avalanche | 43114 | Bridge, transfers |
629
+ | Linea | 59144 | Bridge, transfers |
630
+ | Unichain | 1301 | Bridge, transfers |
631
+ | Sonic | 146 | Bridge, transfers |
632
+ | Worldchain | 480 | Bridge, transfers |
633
+ | Base Sepolia | 84532 | Testnet — all features |
634
+ | Arbitrum Sepolia | 421614 | Testnet — identity, transfers |
635
+
636
+ ---
637
+
638
+ ## Supported Tokens
639
+
640
+ AgentPay MCP ships with **100+ pre-loaded tokens** across all supported chains via `agentwallet-sdk`'s TokenRegistry. Common tokens available on every major chain include:
641
+
642
+ - **Stablecoins:** USDC, USDT, DAI, FRAX, LUSD
643
+ - **Native Wrapped:** WETH, WBTC, WMATIC, WAVAX
644
+ - **DeFi:** UNI, AAVE, LINK, CRV, LDO
645
+ - **L2 Tokens:** cbETH, rETH, weETH, ezETH
646
+
647
+ **Custom tokens** can be registered at runtime with `add_custom_token` and will be available to `send_token`, `get_balances`, and `swap_tokens` immediately.
648
+
649
+ ---
650
+
651
+ ## Configuration
652
+
653
+ | Env Var | Required | Default | Description |
654
+ |---|---|---|---|
655
+ | `AGENT_PRIVATE_KEY` | ✅ | — | Agent signing key (0x-prefixed hex). NOT the owner key. |
656
+ | `AGENT_WALLET_ADDRESS` | ✅ | — | Deployed AgentAccountV2 contract address |
657
+ | `CHAIN_ID` | ❌ | `8453` | Chain ID (8453 = Base Mainnet) |
658
+ | `RPC_URL` | ❌ | Public Base RPC | Custom RPC endpoint (Alchemy, Infura, etc. recommended) |
659
+ | `SESSION_TTL_SECONDS` | ❌ | `3600` | Default x402 session lifetime (60–2592000 seconds) |
660
+ | `FACTORY_ADDRESS` | ❌ | — | AgentAccountFactoryV2 address (for `deploy_wallet`, `create_escrow`) |
661
+ | `NFT_CONTRACT_ADDRESS` | ❌ | — | NFT contract address (for `deploy_wallet`) |
662
+
663
+ ---
664
+
665
+ ## Security
666
+
667
+ ### Non-Custodial Design
668
+
669
+ AgentPay MCP is **non-custodial** — the agent signs all transactions locally with its private key. No third party holds or validates keys at any point.
670
+
671
+ ### On-Chain Spending Controls
672
+
673
+ - **Per-transaction caps** — transactions exceeding the cap are queued for human approval via `queue_approval`
674
+ - **Daily period limits** — aggregate spending is enforced on-chain by the AgentAccountV2 contract
675
+ - **Recipient allowlists** — restrict which addresses the agent can send to via `set_spend_policy`
676
+
677
+ ### Separation of Roles
678
+
679
+ The agent's signing key (`AGENT_PRIVATE_KEY`) can **only** transact within the limits set by the wallet owner. The owner (NFT holder) can:
680
+ - Adjust spend limits without redeploying
681
+ - Revoke the agent's operator access
682
+ - Cancel queued transactions
683
+
684
+ This means even if the agent's key is compromised, the attacker can only spend up to the configured limit.
685
+
686
+ ### x402 Session Tokens
687
+
688
+ Session tokens are self-contained ECDSA-signed claims. Any server implementing x402 V2 can independently verify them — no central session store required.
689
+
690
+ ---
691
+
692
+ ## Architecture
693
+
694
+ ```
695
+ ┌─────────────────────────────────────────┐
696
+ │ AI Agent (Claude / Cursor / Windsurf) │
697
+ └────────────────┬────────────────────────┘
698
+ │ MCP (stdio/SSE)
699
+ ┌────────────────▼────────────────────────┐
700
+ │ AgentPay MCP Server │
701
+ │ ┌────────────┐ ┌────────────────────┐ │
702
+ │ │ 23 Tools │ │ Session Manager │ │
703
+ │ └─────┬──────┘ └────────────────────┘ │
704
+ │ │ │
705
+ │ ┌─────▼──────────────────────────────┐ │
706
+ │ │ agentwallet-sdk v6.0.0 │ │
707
+ │ │ TokenRegistry SwapModule │ │
708
+ │ │ BridgeModule ERC8004Client │ │
709
+ │ │ ReputationClient MutualStake... │ │
710
+ │ └─────┬──────────────────────────────┘ │
711
+ └────────┼────────────────────────────────┘
712
+ │ viem + RPC
713
+ ┌────────▼────────────────────────────────┐
714
+ │ AgentAccountV2 Smart Contract │
715
+ │ (12 chains — Base, ETH, ARB, OP, ...) │
716
+ └─────────────────────────────────────────┘
717
+ ```
718
+
719
+ **MCP Transport:** The server uses `stdio` transport by default (compatible with Claude Desktop, Cursor, Windsurf, any MCP-compatible host). SSE transport is available for remote/networked deployments.
720
+
721
+ **Tool Routing:** Each MCP tool call is routed to the corresponding handler in `src/tools/`. All handlers are typed with Zod schemas and return structured `{ content: [{ type: "text", text: "..." }] }` responses.
722
+
723
+ **Token Resolution:** `send_token`, `get_balances`, and `swap_tokens` use the agentwallet-sdk `TokenRegistry` to resolve symbols to on-chain addresses and decimals, eliminating the need for agents to manage contract addresses manually.
724
+
725
+ ---
726
+
727
+ ## Contributing
728
+
729
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on submitting issues and pull requests.
33
730
 
34
731
  ```bash
35
- npm uninstall clawpay-mcp
36
- npm install agentpay-mcp
732
+ git clone https://github.com/up2itnow0822/agentpay-mcp
733
+ cd agentpay-mcp
734
+ npm install
735
+ npm run build
736
+ npm test
37
737
  ```
38
738
 
39
- Your imports work identically — all exports are re-exported unchanged.
739
+ ---
40
740
 
41
- ## Ecosystem
741
+ ## License
42
742
 
43
- | Package | Description |
44
- |---|---|
45
- | [`@agenteconomy/wallet`](https://www.npmjs.com/package/@agenteconomy/wallet) | Non-custodial agent wallets |
46
- | [`agentpay-mcp`](https://www.npmjs.com/package/agentpay-mcp) | x402 payment layer (this package) |
47
- | [`@agenteconomy/webmcp`](https://www.npmjs.com/package/@agenteconomy/webmcp) | Agent-friendly web protocol |
48
- | [`@agenteconomy/escrow`](https://www.npmjs.com/package/@agenteconomy/escrow) | Trustless agent escrow *(coming soon)* |
743
+ MIT © [AI Agent Economy](https://ai-agent-economy.com)
744
+
745
+ ---
746
+
747
+ ## About
748
+
749
+ Built by **AI Agent Economy** — infrastructure for autonomous agent commerce.
49
750
 
50
- ## Links
751
+ > Payment infrastructure integrated into **NVIDIA's official NeMo Agent Toolkit Examples catalog**.
51
752
 
52
- - [Website](https://ai-agent-economy.com)
53
- - [npm (@agenteconomy/pay)](https://www.npmjs.com/package/@agenteconomy/pay)
54
- - [Discord](https://discord.gg/958AACqf7Y)
753
+ **Patent Pending** — USPTO provisional application filed March 2026.