agentpay-mcp 3.1.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.
package/README.md CHANGED
@@ -1,58 +1,38 @@
1
1
  # AgentPay MCP
2
2
 
3
- > _Formerly ClawPay MCP_ — Non-custodial x402 payment layer for AI agents. Base (live), Etherlink, Polygon, and Stellar (coming Q2 2026).
4
-
5
- [![npm version](https://img.shields.io/npm/v/agentpay-mcp)](https://www.npmjs.com/package/agentpay-mcp)
3
+ [![npm version](https://img.shields.io/npm/v/agentpay-mcp.svg)](https://www.npmjs.com/package/agentpay-mcp)
6
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
7
- [![MCP Compatible](https://img.shields.io/badge/MCP-Compatible-green)](https://modelcontextprotocol.io)
8
-
9
- > **Migration notice:** The npm package has been renamed from `clawpay-mcp` to `agentpay-mcp`. Install with `npm install -g agentpay-mcp`. The old package name will continue to redirect but receives no further updates.
10
-
11
- ---
12
-
13
- ## What is AgentPay MCP?
14
-
15
- AgentPay MCP is a [Model Context Protocol](https://modelcontextprotocol.io) server that wraps the [Agent Wallet SDK (`agentwallet-sdk`)](https://www.npmjs.com/package/agentwallet-sdk) — enabling any MCP-compatible AI client (Claude Desktop, Cursor, Windsurf, etc.) to make on-chain payments with built-in spend limit enforcement.
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)
16
7
 
17
- **Key properties:**
8
+ > MCP server that gives AI agents a complete crypto wallet — send tokens, swap, bridge, manage budgets, verify identity.
18
9
 
19
- - 🔐 **Non-custodial**You hold your keys. The wallet is a smart contract you own via NFT.
20
- - 💸 **Spend-limited** — On-chain limits cap what agents can spend per-tx and per-period. Over-limit transactions queue for your approval.
21
- - ⚡ **x402-native** — Automatic HTTP 402 payment handling (pay-per-API-call, pay-per-token, etc.)
22
- - 🌐 **Multi-chain** — Base (live), Etherlink, Polygon, Stellar (coming Q2 2026)
10
+ **Patent Pending** — USPTO provisional filed March 2026.
23
11
 
24
- **Part of the [Agent Wallet](https://github.com/up2itnow0822/agent-wallet-sdk) ecosystem.**
12
+ Built by [AI Agent Economy](https://ai-agent-economy.com). Payment infrastructure integrated into **NVIDIA's official NeMo Agent Toolkit Examples catalog**.
25
13
 
26
14
  ---
27
15
 
28
- ## x402 Multi-Chain Support
16
+ ## What's New in v4.0.0
29
17
 
30
- x402 is live on multiple chains, and AgentPay MCP is designed to be the abstraction layer so your agent doesn't need chain-specific payment code.
31
-
32
- | Chain | Status | Settlement | Notes |
33
- |-------|--------|------------|-------|
34
- | **Base** (Coinbase L2) | ✅ Live | USDC native | Primary chain. Production-ready. |
35
- | **Etherlink** (Tezos L2) | 🔜 Coming | USDC via bridge | Live on Etherlink since Mar 9, 2026. AgentPay integration in progress. |
36
- | **Polygon** | 🔜 Coming | USDC native | Agent CLI support live since Mar 8, 2026. AgentPay integration in progress. |
37
- | **Stellar** | 🔜 Coming | USDC native | x402 support live ~Mar 10, 2026. AgentPay integration in progress. |
38
- | **Circle Testnet** | 🧪 Testing | USDC (12 chains) | Multi-chain CCTP testnet for cross-chain USDC settlement. |
39
-
40
- **How multi-chain works with AgentPay MCP:**
41
-
42
- Your agent calls `x402_pay` with a URL. The MCP server detects the x402 payment requirements from the HTTP 402 response - including which chain the provider expects payment on. As we add chain support, the agent's integration stays the same: one tool call, automatic chain routing.
43
-
44
- ```bash
45
- # Your agent code doesn't change when new chains are added
46
- x402_pay({ url: "https://api.example.com/data", max_payment_eth: "0.001" })
47
- ```
18
+ **11 new MCP tools** powered by full **agentwallet-sdk v6.0.0** integration:
48
19
 
49
- **Multi-chain roadmap:**
50
- 1. Base - live now
51
- 2. Etherlink - Q2 2026
52
- 3. Polygon - Q2 2026
53
- 4. Stellar - Q2 2026
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` |
54
28
 
55
- Want a specific chain prioritized? [Open an issue](https://github.com/up2itnow0822/agentpay-mcp/issues).
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
56
36
 
57
37
  ---
58
38
 
@@ -64,31 +44,39 @@ Want a specific chain prioritized? [Open an issue](https://github.com/up2itnow08
64
44
  npm install -g agentpay-mcp
65
45
  ```
66
46
 
67
- ### 2. Configure environment
47
+ ### 2. Environment Variables
68
48
 
69
- Create a `.env` file (or set env vars for your MCP client):
49
+ Copy `.env.example` to `.env` and fill in the required values:
70
50
 
71
51
  ```bash
72
52
  # Required
73
- AGENT_PRIVATE_KEY=0x... # Agent hot wallet private key
74
- AGENT_WALLET_ADDRESS=0x... # Your deployed AgentAccountV2 address
53
+ AGENT_PRIVATE_KEY=0x... # Agent hot wallet private key (0x-prefixed hex)
54
+ AGENT_WALLET_ADDRESS=0x... # Deployed AgentAccountV2 wallet address
75
55
 
76
56
  # Optional (defaults shown)
77
- CHAIN_ID=8453 # 8453 = Base Mainnet, 84532 = Base Sepolia
78
- RPC_URL=https://mainnet.base.org
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
79
66
  ```
80
67
 
81
- > **Security note:** `AGENT_PRIVATE_KEY` is the agent's *hot wallet* signing key — not the owner key. On-chain spend limits protect your funds. Even if the key is compromised, the agent can only spend within your configured limits.
68
+ ### 3. MCP Configuration
82
69
 
83
- ### 3. Add to Claude Desktop
70
+ #### Claude Desktop
84
71
 
85
- Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:
72
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
86
73
 
87
74
  ```json
88
75
  {
89
76
  "mcpServers": {
90
77
  "agentpay": {
91
- "command": "agentpay-mcp",
78
+ "command": "npx",
79
+ "args": ["agentpay-mcp"],
92
80
  "env": {
93
81
  "AGENT_PRIVATE_KEY": "0x...",
94
82
  "AGENT_WALLET_ADDRESS": "0x...",
@@ -99,305 +87,667 @@ Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:
99
87
  }
100
88
  ```
101
89
 
102
- Then restart Claude Desktop. You'll see the 🔧 AgentPay tools available in your conversation.
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
+ ```
103
109
 
104
110
  ---
105
111
 
106
- ## Tools Reference
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
+ ---
107
148
 
108
- ### 1. `deploy_wallet`
149
+ ## Detailed Tool Documentation
109
150
 
110
- Deploy a new AgentAccountV2 wallet via the factory contract.
151
+ ### `deploy_wallet`
111
152
 
112
- **Input:**
153
+ Deploy a new AgentAccountV2 smart contract wallet. The wallet is deterministically addressed (CREATE2) and owned by an NFT.
113
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:**
114
163
  ```json
164
+ // Request
165
+ { "token_id": "42" }
166
+
167
+ // Response
115
168
  {
116
- "token_id": "1",
117
- "factory_address": "0x...",
118
- "nft_contract_address": "0x..."
169
+ "walletAddress": "0xabc...def",
170
+ "txHash": "0x123...456",
171
+ "explorerUrl": "https://basescan.org/address/0xabc...def"
119
172
  }
120
173
  ```
121
174
 
122
- **Output:**
175
+ ---
123
176
 
124
- ```text
125
- ✅ Agent Wallet deployed successfully!
177
+ ### `get_wallet_info`
126
178
 
127
- 📍 Wallet Address: 0xabc...
128
- 🔗 Explorer: https://basescan.org/address/0xabc...
179
+ Get comprehensive wallet information: address, on-chain balance, spend limits, period utilization, and pending queue depth.
129
180
 
130
- 📋 Transaction: 0xdef...
131
- 🔑 Owner NFT: 0xnft... #1
132
- 🌐 Chain: Base Mainnet
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
+ {}
133
190
 
134
- ℹ️ Next steps:
135
- 1. Set AGENT_WALLET_ADDRESS=0xabc... in your .env
136
- 2. Use set_spend_policy to configure spending limits
137
- 3. Fund the wallet with ETH or USDC
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% 🟢"
138
201
  ```
139
202
 
140
203
  ---
141
204
 
142
- ### 2. `get_wallet_info`
205
+ ### `send_payment`
143
206
 
144
- Get wallet address, balance, spend limits, and remaining allowance.
207
+ Execute an ETH or ERC-20 transfer via the AgentAccountV2 contract. Subject to on-chain spend limits.
145
208
 
146
- **Input:**
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) |
147
217
 
218
+ **Example:**
148
219
  ```json
149
- {
150
- "token": "0x0000000000000000000000000000000000000000"
151
- }
220
+ // Request
221
+ { "to": "0xrecipient...", "amount_eth": "0.01" }
222
+
223
+ // Response
224
+ "✅ Payment sent: 0.01 ETH → 0xrecipient...
225
+ Tx: 0xtxhash..."
152
226
  ```
153
227
 
154
- *`token` is optional — omit for native ETH.*
228
+ ---
155
229
 
156
- **Output:**
230
+ ### `check_spend_limit`
157
231
 
158
- ```text
159
- 📊 Agent Wallet Info
232
+ Check the remaining spend limit for the current period for a given token.
160
233
 
161
- 📍 Address: 0xabc...
162
- 🌐 Chain: Base Mainnet
163
- 💰 ETH Balance: 0.5 ETH
234
+ **Parameters:**
235
+ | Name | Type | Required | Description |
236
+ |---|---|---|---|
237
+ | `token` | string | ❌ | Token address (omit for ETH) |
164
238
 
165
- 📈 Spend Limits (ETH)
166
- Per-tx limit: 0.01 ETH
167
- Period limit: 0.1 ETH
168
- Period spent: 0.03 ETH
169
- Remaining: 0.07 ETH
170
- Utilization: 30% 🟢 Healthy
171
- Period length: 24h
172
- Resets in: 18h 22m
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": "{ ... }" }
173
276
  ```
174
277
 
175
278
  ---
176
279
 
177
- ### 3. `send_payment`
280
+ ### `get_transaction_history`
178
281
 
179
- Send ETH or ERC20 tokens within spend limits.
282
+ Query on-chain event logs for the wallet's transaction history. Filter by event type or block range.
180
283
 
181
- **Input:**
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` |
182
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:**
183
307
  ```json
184
- {
185
- "to": "0xrecipient...",
186
- "amount_eth": "0.001",
187
- "memo": "Payment for API access"
188
- }
308
+ // Request
309
+ { "endpoint": "https://api.example.com/", "ttl_seconds": 3600 }
310
+
311
+ // Response
312
+ { "session_id": "sess_abc123", "token": "eyJ...", "expires_at": 1741000000 }
189
313
  ```
190
314
 
191
- For ERC20 (e.g. USDC):
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) |
192
363
 
364
+ **Example:**
193
365
  ```json
194
- {
195
- "to": "0xrecipient...",
196
- "amount_eth": "5.00",
197
- "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
198
- "token_decimals": 6
199
- }
366
+ // Request
367
+ { "symbol": "USDC", "chainId": 8453 }
368
+
369
+ // Response
370
+ { "found": true, "symbol": "USDC", "address": "0x833589...", "decimals": 6, "chainId": 8453 }
200
371
  ```
201
372
 
202
- **Output:**
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`.
203
378
 
204
- ```text
205
- Payment Sent
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 |
206
387
 
207
- To: 0xrecipient...
208
- Amount: 0.001 ETH
209
- Network: Base Mainnet
210
- TX Hash: 0xabc...
211
- 🔗 https://basescan.org/tx/0xabc...
212
- 📝 Memo: Payment for API access
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" }
213
395
  ```
214
396
 
215
- > If the payment exceeds spend limits, it's automatically queued for your approval. Use `queue_approval` to manage the queue.
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
+ ```
216
416
 
217
417
  ---
218
418
 
219
- ### 4. `check_spend_limit`
419
+ ### `send_token`
220
420
 
221
- Check if a proposed payment is within autonomous limits before sending.
421
+ Send any ERC-20 token using the symbol-based registry. Resolves address and decimals automatically.
222
422
 
223
- **Input:**
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"`) |
224
430
 
431
+ **Example:**
225
432
  ```json
226
- {
227
- "amount_eth": "0.005"
228
- }
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..." }
229
438
  ```
230
439
 
231
- **Output:**
440
+ ---
232
441
 
233
- ```text
234
- 🔍 Spend Limit Check
442
+ ### `get_balances`
235
443
 
236
- Token: ETH
237
- Amount: 0.005 ETH
444
+ Get token balances for the Agent Wallet across one or more tokens on a given chain.
238
445
 
239
- Per-tx limit: 0.01 ETH
240
- Within per-tx: ✅ Yes
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) |
241
451
 
242
- Remaining period: 0.07 ETH
243
- Within period: ✅ Yes
244
- Resets in: 18h 22m
452
+ **Example:**
453
+ ```json
454
+ // Request
455
+ { "chainId": 8453, "tokens": ["USDC", "WETH"] }
245
456
 
246
- APPROVED — This payment can execute autonomously.
457
+ // Response
458
+ { "balances": [{ "symbol": "USDC", "balance": "500.00", "decimals": 6 }, { "symbol": "WETH", "balance": "0.05", "decimals": 18 }] }
247
459
  ```
248
460
 
249
461
  ---
250
462
 
251
- ### 5. `queue_approval`
463
+ ### `swap_tokens`
252
464
 
253
- Manage over-limit transactions queued for owner review.
465
+ Swap one ERC-20 token for another using Uniswap V3. Supported chains: Base, Arbitrum, Optimism, Polygon.
254
466
 
255
- **List pending:**
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%) |
256
475
 
476
+ **Example:**
257
477
  ```json
258
- { "action": "list" }
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" }
259
483
  ```
260
484
 
261
- **Approve:**
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.
262
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:**
263
501
  ```json
264
- { "action": "approve", "tx_id": "0" }
502
+ // Request
503
+ { "fromChain": "base", "toChain": "arbitrum", "amount": "500" }
504
+
505
+ // Response
506
+ { "success": true, "burnTxHash": "0x...", "mintTxHash": "0x...", "amount": "500 USDC" }
265
507
  ```
266
508
 
267
- **Cancel:**
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.
268
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:**
269
523
  ```json
270
- { "action": "cancel", "tx_id": "0" }
524
+ // Request
525
+ { "dailyLimitEth": "0.5", "perTxCapEth": "0.05", "allowedRecipients": ["0xrecipient..."] }
526
+
527
+ // Response
528
+ { "success": true, "policy": { "dailyLimitEth": "0.5", "perTxCapEth": "0.05" } }
271
529
  ```
272
530
 
273
531
  ---
274
532
 
275
- ### 6. `x402_pay`
533
+ ### `check_budget`
276
534
 
277
- Fetch a URL and automatically handle HTTP 402 Payment Required responses.
535
+ Query the on-chain remaining budget for a given spender and token.
278
536
 
279
- **Input:**
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) |
280
542
 
543
+ **Example:**
281
544
  ```json
282
- {
283
- "url": "https://api.example.com/premium-data",
284
- "max_payment_eth": "0.001",
285
- "timeout_ms": 15000
286
- }
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" }
287
550
  ```
288
551
 
289
552
  ---
290
553
 
291
- ### 7. `get_transaction_history`
554
+ ### `verify_agent_identity`
292
555
 
293
- Retrieve on-chain transaction history from event logs.
556
+ Verify an agent's on-chain identity using ERC-8004. Returns identity details including agent ID, URI, and registration file.
294
557
 
295
- **Input:**
558
+ **Parameters:**
559
+ | Name | Type | Required | Description |
560
+ |---|---|---|---|
561
+ | `agentAddress` | string | ✅ | Agent owner address (0x-prefixed) |
296
562
 
563
+ **Example:**
297
564
  ```json
298
- {
299
- "limit": 10,
300
- "event_type": "execution"
301
- }
565
+ // Request
566
+ { "agentAddress": "0xagent..." }
567
+
568
+ // Response
569
+ { "found": true, "agentId": "42", "owner": "0xagent...", "uri": "ipfs://Qm...", "registrationFile": { "name": "MyAgent", "version": "1.0" } }
302
570
  ```
303
571
 
304
572
  ---
305
573
 
306
- ## Security Model
574
+ ### `get_reputation`
307
575
 
308
- ### Non-Custodial Architecture
576
+ Fetch an agent's on-chain reputation score and history.
309
577
 
310
- AgentPay MCP wraps **AgentAccountV2** — a smart contract wallet that you own via an NFT. The security model:
578
+ **Parameters:**
579
+ | Name | Type | Required | Description |
580
+ |---|---|---|---|
581
+ | `agentAddress` | string | ✅ | Agent address (0x-prefixed) |
311
582
 
312
- 1. **You own the NFT** → You own the wallet. If you transfer the NFT, the new holder controls the wallet.
313
- 2. **Agent hot key** → `AGENT_PRIVATE_KEY` is a *limited* operator key. It can execute transactions only within the on-chain spend limits you set.
314
- 3. **On-chain spend limits** → Set via `setSpendPolicy`. Caps per-transaction and per-period spending. Even if the agent key is compromised, the attacker is limited to your configured spend limits.
315
- 4. **Approval queue** → Over-limit transactions are queued on-chain for your explicit approval. The agent cannot bypass this.
583
+ **Example:**
584
+ ```json
585
+ // Request
586
+ { "agentAddress": "0xagent..." }
316
587
 
317
- ### Threat Model
588
+ // Response
589
+ { "agentAddress": "0xagent...", "score": 92, "level": "trusted", "totalInteractions": 1250, "successRate": 0.98 }
590
+ ```
318
591
 
319
- | Threat | Mitigation |
320
- |--------|------------|
321
- | Compromised agent private key | On-chain spend limits cap exposure |
322
- | Runaway agent (infinite payment loop) | Period limits + queue-on-exceed |
323
- | x402 price manipulation | `max_payment_eth` cap parameter |
324
- | Over-spending a single service | x402 per-service budget controls |
325
- | Lost private key | Owner (NFT holder) remains in control |
592
+ ---
326
593
 
327
- ### Isolation Architecture — Why ContextCrush-Style Attacks Don't Apply
594
+ ### `create_escrow`
328
595
 
329
- In March 2026, Noma Security disclosed "ContextCrush" (CVE-2026-31841): MCP servers delivering poisoned documentation into AI coding assistants (Claude Desktop, Cursor, Windsurf, VS Code). The attack injects malicious instructions via the context window, causing the AI to execute destructive commands including deleting local files.
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.
330
597
 
331
- AgentPay MCP is architecturally immune to this class of attack. Here's why.
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) |
332
607
 
333
- **ContextCrush attack vector:**
334
- - A malicious MCP server (e.g. a documentation provider like Context7) returns poisoned content when the AI queries it
335
- - That content contains hidden instructions injected into the AI's context window
336
- - The AI, following what looks like legitimate documentation, executes the attacker's commands
608
+ **Example:**
609
+ ```json
610
+ // Request
611
+ { "counterpartyAddress": "0xseller...", "stakeAmount": "100", "terms": "Deliver logo design by 2026-04-01" }
337
612
 
338
- **Why AgentPay MCP doesn't have this surface:**
613
+ // Response
614
+ { "success": true, "escrowAddress": "0xvault...", "txHash": "0x...", "deadline": "2026-03-29T00:00:00Z" }
615
+ ```
616
+
617
+ ---
339
618
 
340
- 1. **Payment-only tool surface** — AgentPay MCP exposes exactly 7 tools: `deploy_wallet`, `get_wallet_info`, `send_payment`, `check_spend_limit`, `queue_approval`, `x402_pay`, `get_transaction_history`. It does not fetch or return arbitrary content from external URLs. There is no documentation retrieval pathway, no web browsing tool, no file system access. The attack surface is bounded by the payment domain.
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 |
341
635
 
342
- 2. **No content pass-through** — ContextCrush works because the compromised MCP server passes external content (poisoned docs) directly into the AI's context. AgentPay MCP only returns structured JSON objects describing payment state and transaction results. It cannot inject arbitrary text into the AI's reasoning context.
636
+ ---
343
637
 
344
- 3. **On-chain enforcement independent of context** — Even if an attacker somehow caused the AI to issue a malicious `send_payment` call, the on-chain spend limits enforce the authorization policy regardless of what the AI believes it's doing. The smart contract validates against the configured `SpendingPolicy` — it doesn't trust the AI's interpretation of the situation.
638
+ ## Supported Tokens
345
639
 
346
- 4. **Process isolation** — AgentPay MCP runs as a separate process (`npx agentpay-mcp`). It communicates with the AI client via stdio, not shared memory. It cannot read or write files in your project directory, cannot access your clipboard, cannot execute shell commands. The process has no filesystem permissions beyond reading its own `.env` configuration.
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:
347
641
 
348
- 5. **No naming collisions** CVE-2026-30856 (Tencent WeKnora) exploited tool naming collisions between MCP servers. AgentPay MCP's tool names are payment-specific and unlikely to collide with documentation or utility tools in legitimate agent setups.
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
349
646
 
350
- **Summary:** AgentPay MCP cannot be weaponized as a ContextCrush-style vector because it serves no content, accesses no external URLs, writes no files, and executes no shell commands. Its on-chain authorization layer enforces payment policy independently of AI context. Enterprise teams evaluating MCP governance should treat payment-specific, isolated MCP servers differently from general-purpose documentation or utility servers.
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.
351
648
 
352
649
  ---
353
650
 
354
651
  ## Configuration
355
652
 
356
- | Variable | Required | Default | Description |
357
- |----------|----------|---------|-------------|
358
- | `AGENT_PRIVATE_KEY` | ✅ | — | Agent hot wallet private key (0x-prefixed hex) |
653
+ | Env Var | Required | Default | Description |
654
+ |---|---|---|---|
655
+ | `AGENT_PRIVATE_KEY` | ✅ | — | Agent signing key (0x-prefixed hex). NOT the owner key. |
359
656
  | `AGENT_WALLET_ADDRESS` | ✅ | — | Deployed AgentAccountV2 contract address |
360
- | `CHAIN_ID` | | `8453` | Chain ID (8453 = Base Mainnet, 84532 = Base Sepolia) |
361
- | `RPC_URL` | | Public Base RPC | Custom RPC endpoint (recommended for production) |
362
- | `FACTORY_ADDRESS` | | | Required for `deploy_wallet` only |
363
- | `NFT_CONTRACT_ADDRESS` | | — | Required for `deploy_wallet` only |
364
-
365
- > **Minimum to get started:** Just `AGENT_PRIVATE_KEY` + `AGENT_WALLET_ADDRESS`. Everything else has sensible defaults.
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`) |
366
662
 
367
663
  ---
368
664
 
369
- ## Integration Examples
665
+ ## Security
370
666
 
371
- ### Cursor / Windsurf
667
+ ### Non-Custodial Design
372
668
 
373
- ```json
374
- {
375
- "mcpServers": {
376
- "agentpay": {
377
- "command": "npx",
378
- "args": ["-y", "agentpay-mcp"],
379
- "env": {
380
- "AGENT_PRIVATE_KEY": "0x...",
381
- "AGENT_WALLET_ADDRESS": "0x...",
382
- "CHAIN_ID": "8453"
383
- }
384
- }
385
- }
386
- }
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
+ └─────────────────────────────────────────┘
387
717
  ```
388
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
+
389
725
  ---
390
726
 
391
- ## Ecosystem
727
+ ## Contributing
392
728
 
393
- - **[Agent Wallet SDK](https://www.npmjs.com/package/agentwallet-sdk)** Non-custodial wallet SDK for AI agents
394
- - **[@agent-wallet/mastra-plugin](https://www.npmjs.com/package/@agent-wallet/mastra-plugin)** — Mastra framework integration
395
- - **[AgentPay MCP](https://www.npmjs.com/package/agentpay-mcp)** — This package (MCP server)
396
- - **[x402 Protocol](https://x402.org)** — HTTP 402 payment standard
397
- - **[Base Network](https://base.org)** — L2 chain
729
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on submitting issues and pull requests.
730
+
731
+ ```bash
732
+ git clone https://github.com/up2itnow0822/agentpay-mcp
733
+ cd agentpay-mcp
734
+ npm install
735
+ npm run build
736
+ npm test
737
+ ```
398
738
 
399
739
  ---
400
740
 
401
741
  ## License
402
742
 
403
- MIT see [LICENSE](LICENSE)
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.
750
+
751
+ > Payment infrastructure integrated into **NVIDIA's official NeMo Agent Toolkit Examples catalog**.
752
+
753
+ **Patent Pending** — USPTO provisional application filed March 2026.