agentpay-mcp 3.1.0 → 4.0.1

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,104 @@
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)
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)
8
7
 
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.
8
+ **The MCP server that lets your agent pay for APIs safely.**
10
9
 
11
- ---
10
+ When your agent hits HTTP 402 Payment Required, it needs to pay and retry — with your approval, within limits you set. AgentPay MCP is a Model Context Protocol server that gives Claude, Cursor, and any MCP-compatible agent a payment wallet with hard spend caps, human-approval mode, and a full on-chain audit trail.
11
+
12
+ Payment infrastructure integrated into **[NVIDIA's official NeMo Agent Toolkit Examples](https://github.com/NVIDIA/NeMo-Agent-Toolkit-Examples/pull/17)**.
13
+
14
+ ## Why Trust Matters
15
+
16
+ McKinsey's 2026 AI Trust Maturity Survey quantifies what builders already feel: agent capability has outpaced agent governance.
12
17
 
13
- ## What is AgentPay MCP?
18
+ | Finding | Stat |
19
+ |---------|------|
20
+ | Enterprises that formally approve agents before deployment | **14.4%** |
21
+ | Enterprises reporting at least one agent security incident | **88%** |
22
+ | Enterprises confident in agent IAM for payments | **18%** |
14
23
 
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.
24
+ The trust gap is the deployment gap. Enterprises aren't saying agents don't workthey're saying the oversight infrastructure (approval workflows, spending guardrails, identity verification, audit trails) hasn't kept pace.
16
25
 
17
- **Key properties:**
26
+ AgentPay MCP addresses this directly:
18
27
 
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)
28
+ - **Human-approval mode** — transactions above your threshold require explicit human confirmation before executing
29
+ - **On-chain spend caps** enforced by smart contract, not application code. The agent cannot override them.
30
+ - **Full audit trail** — every payment attempt logged with merchant, amount, timestamp, approval status
31
+ - **Fail-closed** — any policy engine error produces rejection, never approval
32
+ - **Non-custodial** — private keys never leave the local machine
23
33
 
24
- **Part of the [Agent Wallet](https://github.com/up2itnow0822/agent-wallet-sdk) ecosystem.**
34
+ When 88% of enterprises have had an agent security incident, "trust by default" is not a viable architecture. AgentPay MCP is built for "verify, then trust" — which is the only model that scales.
25
35
 
26
36
  ---
27
37
 
28
- ## x402 Multi-Chain Support
38
+ ## Security & Dependencies
29
39
 
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.
40
+ AgentPay MCP is built for enterprise MCP deployments where supply chain security matters.
31
41
 
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. |
42
+ - **Zero LiteLLM dependency.** No direct or transitive dependency on LiteLLM or any heavyweight LLM routing layer. When LiteLLM versions 1.82.7-1.82.8 were [compromised on PyPI](https://github.com/berriai/litellm/issues) (March 2026), AgentPay MCP users were unaffected.
43
+ - **Auditable, minimal dependency tree.** The server runs on `viem`, `@modelcontextprotocol/sdk`, and a small set of auditable npm packages. No PyPI. No Python runtime required.
44
+ - **Enterprise trust signal.** Integrated into [NVIDIA's official NeMo Agent Toolkit Examples](https://github.com/NVIDIA/NeMo-Agent-Toolkit-Examples/pull/17) (PR #17, merged). NVIDIA's review process validated the security posture before merge.
45
+ - **Non-custodial architecture.** Private keys never leave the local machine. On-chain spend caps enforce limits even if the agent or its key is compromised.
39
46
 
40
- **How multi-chain works with AgentPay MCP:**
47
+ If your security team is auditing MCP server dependencies after the LiteLLM incident, `npm ls` on agentpay-mcp gives you a short, reviewable tree with zero Python supply chain exposure.
41
48
 
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.
49
+ ---
43
50
 
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" })
51
+ ## AI Agent Discovery
52
+
53
+ AgentPay MCP is designed to be discovered and used by AI agents. Compatible with:
54
+
55
+ - **[claude-mem](https://github.com/thedotmack/claude-mem)** - Payment state (transaction history, budgets, session tokens) persists as agent memory across sessions via claude-mem's observation layer
56
+ - **[AgentSkills](https://agentskills.io)** - Installable as a cross-framework skill in any AgentSkills-compatible harness (Claude Code, Cursor, Gemini CLI, Antigravity)
57
+ - **[Chrome DevTools MCP](https://github.com/ChromeDevTools/chrome-devtools-mcp)** - Pairs as the payment layer for browser-native agents
58
+
59
+ ### Install as a Skill
60
+
61
+ Add to any MCP-compatible harness config:
62
+
63
+ ```json
64
+ {
65
+ "mcpServers": {
66
+ "agentpay": {
67
+ "command": "npx",
68
+ "args": ["agentpay-mcp"],
69
+ "env": {
70
+ "AGENT_PRIVATE_KEY": "0x...",
71
+ "AGENT_WALLET_ADDRESS": "0x..."
72
+ }
73
+ }
74
+ }
75
+ }
47
76
  ```
48
77
 
49
- **Multi-chain roadmap:**
50
- 1. Base - live now
51
- 2. Etherlink - Q2 2026
52
- 3. Polygon - Q2 2026
53
- 4. Stellar - Q2 2026
78
+ Works with Claude Code, Cursor, Gemini CLI, OpenClaw, Windsurf, and any MCP client.
54
79
 
55
- Want a specific chain prioritized? [Open an issue](https://github.com/up2itnow0822/agentpay-mcp/issues).
80
+ ---
81
+
82
+ ## The 402 Flow — What This Actually Does
83
+
84
+ ```
85
+ Agent calls a paid API
86
+
87
+
88
+ HTTP 402 ←── "Payment required: 0.50 USDC on Base"
89
+
90
+
91
+ AgentPay MCP evaluates your policy:
92
+ • Is 0.50 USDC under your per-tx cap? ($5 limit → ✅)
93
+ • Is this recipient allowlisted? (api.example.com → ✅)
94
+ • Require human approval? (under $1 threshold → auto)
95
+
96
+
97
+ Payment sent → API retried with payment proof → 200 OK
98
+
99
+
100
+ Agent gets the data. Full tx on basescan.org.
101
+ ```
56
102
 
57
103
  ---
58
104
 
@@ -64,31 +110,36 @@ Want a specific chain prioritized? [Open an issue](https://github.com/up2itnow08
64
110
  npm install -g agentpay-mcp
65
111
  ```
66
112
 
67
- ### 2. Configure environment
68
-
69
- Create a `.env` file (or set env vars for your MCP client):
113
+ ### 2. Configure Claude Desktop
70
114
 
71
- ```bash
72
- # Required
73
- AGENT_PRIVATE_KEY=0x... # Agent hot wallet private key
74
- AGENT_WALLET_ADDRESS=0x... # Your deployed AgentAccountV2 address
115
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
75
116
 
76
- # Optional (defaults shown)
77
- CHAIN_ID=8453 # 8453 = Base Mainnet, 84532 = Base Sepolia
78
- RPC_URL=https://mainnet.base.org
117
+ ```json
118
+ {
119
+ "mcpServers": {
120
+ "agentpay": {
121
+ "command": "npx",
122
+ "args": ["agentpay-mcp"],
123
+ "env": {
124
+ "AGENT_PRIVATE_KEY": "0x...",
125
+ "AGENT_WALLET_ADDRESS": "0x...",
126
+ "CHAIN_ID": "8453"
127
+ }
128
+ }
129
+ }
130
+ }
79
131
  ```
80
132
 
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.
133
+ ### 3. Configure Cursor
82
134
 
83
- ### 3. Add to Claude Desktop
84
-
85
- Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:
135
+ Add to `.cursor/mcp.json` or `~/.cursor/mcp.json`:
86
136
 
87
137
  ```json
88
138
  {
89
139
  "mcpServers": {
90
140
  "agentpay": {
91
- "command": "agentpay-mcp",
141
+ "command": "npx",
142
+ "args": ["agentpay-mcp"],
92
143
  "env": {
93
144
  "AGENT_PRIVATE_KEY": "0x...",
94
145
  "AGENT_WALLET_ADDRESS": "0x...",
@@ -99,305 +150,403 @@ Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:
99
150
  }
100
151
  ```
101
152
 
102
- Then restart Claude Desktop. You'll see the 🔧 AgentPay tools available in your conversation.
103
-
104
- ---
105
-
106
- ## Tools Reference
153
+ ### 4. Set Spend Caps
107
154
 
108
- ### 1. `deploy_wallet`
155
+ Once running, tell your agent:
109
156
 
110
- Deploy a new AgentAccountV2 wallet via the factory contract.
157
+ ```
158
+ Set my spend policy: $1 per transaction, $10 per day, only send to allowlisted addresses.
159
+ ```
111
160
 
112
- **Input:**
161
+ Or call `set_spend_policy` directly:
113
162
 
114
163
  ```json
115
164
  {
116
- "token_id": "1",
117
- "factory_address": "0x...",
118
- "nft_contract_address": "0x..."
165
+ "tool": "set_spend_policy",
166
+ "arguments": {
167
+ "perTxCapEth": "0.0004",
168
+ "dailyLimitEth": "0.004",
169
+ "allowedRecipients": ["0xapi-provider-address..."]
170
+ }
119
171
  }
120
172
  ```
121
173
 
122
- **Output:**
174
+ Now your agent can pay for APIs — and can't spend more than $1 at a time or $10 in a day, regardless of what it's instructed to do.
123
175
 
124
- ```text
125
- ✅ Agent Wallet deployed successfully!
176
+ ---
126
177
 
127
- 📍 Wallet Address: 0xabc...
128
- 🔗 Explorer: https://basescan.org/address/0xabc...
178
+ ## Human-Approval Mode (the Default)
129
179
 
130
- 📋 Transaction: 0xdef...
131
- 🔑 Owner NFT: 0xnft... #1
132
- 🌐 Chain: Base Mainnet
180
+ By default, transactions above your auto-approve threshold queue for human review. The agent cannot bypass this.
133
181
 
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
182
+ ```
183
+ $0.50 USDC request under $1 threshold → auto-approved → paid → result returned
184
+ $5.00 USDC request over $1 threshold → queued → you get notified → approve or reject
138
185
  ```
139
186
 
140
- ---
141
-
142
- ### 2. `get_wallet_info`
187
+ To approve a queued payment:
143
188
 
144
- Get wallet address, balance, spend limits, and remaining allowance.
189
+ ```json
190
+ {
191
+ "tool": "queue_approval",
192
+ "arguments": {
193
+ "action": "approve",
194
+ "tx_id": "0x..."
195
+ }
196
+ }
197
+ ```
145
198
 
146
- **Input:**
199
+ To reject it:
147
200
 
148
201
  ```json
149
202
  {
150
- "token": "0x0000000000000000000000000000000000000000"
203
+ "tool": "queue_approval",
204
+ "arguments": {
205
+ "action": "cancel",
206
+ "tx_id": "0x..."
207
+ }
151
208
  }
152
209
  ```
153
210
 
154
- *`token` is optional omit for native ETH.*
211
+ The agent sees the outcome and decides what to do next (use cached data, ask user, abort).
155
212
 
156
- **Output:**
213
+ ---
214
+
215
+ ## Value Packs — Three Production Workflow Patterns
216
+
217
+ ### 1. Paid API Agent
218
+
219
+ **What it does:** Finds the right paid API for a data need, pays once, caches the result.
157
220
 
158
- ```text
159
- 📊 Agent Wallet Info
221
+ **When to use it:** Your agent needs data (market data, enrichment, geocoding) and you want it to handle payment automatically rather than failing with a 402.
160
222
 
161
- 📍 Address: 0xabc...
162
- 🌐 Chain: Base Mainnet
163
- 💰 ETH Balance: 0.5 ETH
223
+ ```
224
+ Agent: "I need current options flow data for AAPL"
225
+
226
+ ├─ Tries free sources → insufficient data
227
+ ├─ Finds paid API → gets 402 for $0.25 USDC
228
+ ├─ Checks: $0.25 < $1 cap → auto-approved
229
+ ├─ Pays with x402_pay → gets data
230
+ ├─ Caches result at ~/.clawpowers/state/market:AAPL:options
231
+ └─ Returns data + payment receipt
232
+ ```
164
233
 
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
234
+ **Tools used:** `x402_pay`, `check_spend_limit`, `get_transaction_history`
235
+
236
+ **Example exchange:**
237
+ ```
238
+ User: Get me the options flow for AAPL for the last 7 days.
239
+
240
+ Agent: Checking free sources... insufficient. Found paid API at data.example.com.
241
+ Cost: $0.25 USDC (under your $1 auto-approve cap). Paying now.
242
+ [x402_pay → 200 OK, paid 0.25 USDC, tx: 0xabc...]
243
+ Here's the options flow data: [results]
244
+ Total cost today: $0.25 of your $10 daily budget.
173
245
  ```
174
246
 
175
247
  ---
176
248
 
177
- ### 3. `send_payment`
249
+ ### 2. Research Agent
178
250
 
179
- Send ETH or ERC20 tokens within spend limits.
251
+ **What it does:** Gathers from free sources first, fills gaps with paid data, compiles a structured output.
180
252
 
181
- **Input:**
253
+ **When to use it:** You need a comprehensive research report and want the agent to spend money only where free data is genuinely insufficient.
182
254
 
183
- ```json
184
- {
185
- "to": "0xrecipient...",
186
- "amount_eth": "0.001",
187
- "memo": "Payment for API access"
188
- }
255
+ ```
256
+ Agent: "Research competitive landscape for real-time flight tracking APIs"
257
+
258
+ ├─ Scrapes free sources (GitHub, HN, docs) → baseline data
259
+ ├─ Identifies gaps: pricing data, SLA guarantees, enterprise contacts
260
+ ├─ Proposes paid lookups totaling $2.75 USDC → presents for approval
261
+ ├─ Human approves
262
+ ├─ Pays for Apollo contact enrichment ($1.50) + Crunchbase data ($1.25)
263
+ └─ Compiles: free data + paid data → structured report
189
264
  ```
190
265
 
191
- For ERC20 (e.g. USDC):
266
+ **Tools used:** `x402_pay`, `x402_session_start`, `x402_session_fetch`, `check_budget`
192
267
 
193
- ```json
194
- {
195
- "to": "0xrecipient...",
196
- "amount_eth": "5.00",
197
- "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
198
- "token_decimals": 6
199
- }
268
+ **Example exchange:**
200
269
  ```
270
+ User: Research the real-time flight tracking API market. Budget up to $5.
201
271
 
202
- **Output:**
272
+ Agent: Starting with free sources... [scrapes 12 sources, builds baseline]
273
+ Gaps identified:
274
+ - Vendor pricing (not public for 3 of 5 vendors)
275
+ - Contact info for enterprise sales at FlightAware
276
+ - Recent funding data for two startups
203
277
 
204
- ```text
205
- Payment Sent
278
+ To fill these I'd spend ~$2.75 USDC:
279
+ - Apollo contact enrichment: $1.50
280
+ - Crunchbase firmographics: $1.25
206
281
 
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
213
- ```
282
+ Approve? (y/n)
214
283
 
215
- > If the payment exceeds spend limits, it's automatically queued for your approval. Use `queue_approval` to manage the queue.
284
+ User: y
285
+
286
+ Agent: [pays, fetches, compiles]
287
+ Report ready. Spent $2.75 of your $5 budget. [structured report attached]
288
+ ```
216
289
 
217
290
  ---
218
291
 
219
- ### 4. `check_spend_limit`
292
+ ### 3. Automation Agent
220
293
 
221
- Check if a proposed payment is within autonomous limits before sending.
294
+ **What it does:** Completes real tasks end-to-end, paying for whatever services are needed along the way.
222
295
 
223
- **Input:**
296
+ **When to use it:** You want an agent that can actually finish work — book a call, run an enrichment pipeline, deploy something — not just research it.
224
297
 
225
- ```json
226
- {
227
- "amount_eth": "0.005"
228
- }
298
+ ```
299
+ Agent: "Enrich this list of 50 leads and add to CRM"
300
+
301
+ ├─ Processes first 10 free (from existing data)
302
+ ├─ Remaining 40 need enrichment → $0.10/contact = $4.00 USDC
303
+ ├─ Presents plan: 40 contacts × $0.10 = $4.00 total → user approves
304
+ ├─ Runs enrichment in batches of 10 (staying under per-tx cap)
305
+ ├─ Writes enriched data to CRM via API
306
+ └─ Reports: 50 leads enriched, $4.00 spent, 47 successful
229
307
  ```
230
308
 
231
- **Output:**
232
-
233
- ```text
234
- 🔍 Spend Limit Check
235
-
236
- Token: ETH
237
- Amount: 0.005 ETH
309
+ **Tools used:** `x402_pay`, `x402_session_start`, `set_spend_policy`, `get_transaction_history`
238
310
 
239
- Per-tx limit: 0.01 ETH
240
- Within per-tx: ✅ Yes
311
+ ---
241
312
 
242
- Remaining period: 0.07 ETH
243
- Within period: ✅ Yes
244
- Resets in: 18h 22m
313
+ ## Environment Variables
245
314
 
246
- ✅ APPROVED — This payment can execute autonomously.
315
+ ```bash
316
+ # Required
317
+ AGENT_PRIVATE_KEY=0x... # Agent hot wallet key (0x-prefixed hex)
318
+ AGENT_WALLET_ADDRESS=0x... # Deployed AgentAccountV2 contract address
319
+
320
+ # Optional
321
+ CHAIN_ID=8453 # 8453 = Base Mainnet (default, recommended)
322
+ RPC_URL=https://mainnet.base.org # Custom RPC (Alchemy/Infura recommended for production)
323
+ SESSION_TTL_SECONDS=3600 # x402 session lifetime (default: 1 hour)
324
+ FACTORY_ADDRESS=0x... # For deploy_wallet and create_escrow
325
+ NFT_CONTRACT_ADDRESS=0x... # For deploy_wallet
247
326
  ```
248
327
 
249
328
  ---
250
329
 
251
- ### 5. `queue_approval`
330
+ ## All 23 Tools
252
331
 
253
- Manage over-limit transactions queued for owner review.
332
+ ### Payments & 402 Flow
254
333
 
255
- **List pending:**
334
+ | Tool | What It Does |
335
+ |------|-------------|
336
+ | `x402_pay` | Fetch a URL, automatically pay 402, retry — the core use case |
337
+ | `x402_session_start` | Pay once, get reusable session token for a base URL |
338
+ | `x402_session_fetch` | Make calls within an active session (no new payment) |
339
+ | `x402_session_status` | Inspect active sessions and TTL |
340
+ | `x402_session_end` | Explicitly close a session |
256
341
 
257
- ```json
258
- { "action": "list" }
259
- ```
342
+ ### Wallet & Spend Control
260
343
 
261
- **Approve:**
344
+ | Tool | What It Does |
345
+ |------|-------------|
346
+ | `get_wallet_info` | Address, balances, spend limits, queue depth |
347
+ | `send_payment` | Send ETH or ERC-20 via the AgentAccountV2 contract |
348
+ | `check_spend_limit` | Remaining spend limit for current period |
349
+ | `set_spend_policy` | Configure daily limits, per-tx caps, recipient allowlists |
350
+ | `check_budget` | Query on-chain remaining budget |
351
+ | `queue_approval` | Approve or cancel a queued transaction |
352
+ | `get_transaction_history` | On-chain event logs with filtering |
353
+ | `deploy_wallet` | Deploy a new AgentAccountV2 smart contract wallet |
262
354
 
263
- ```json
264
- { "action": "approve", "tx_id": "0" }
265
- ```
355
+ ### Token Operations
266
356
 
267
- **Cancel:**
357
+ | Tool | What It Does |
358
+ |------|-------------|
359
+ | `lookup_token` | Token address + decimals by symbol and chain |
360
+ | `add_custom_token` | Register a custom ERC-20 in the token registry |
361
+ | `list_chain_tokens` | All registered tokens for a chain |
362
+ | `send_token` | Send any registry token (resolves address + decimals automatically) |
363
+ | `get_balances` | Token balances across one or more tokens |
268
364
 
269
- ```json
270
- { "action": "cancel", "tx_id": "0" }
271
- ```
365
+ ### DeFi
272
366
 
273
- ---
367
+ | Tool | What It Does |
368
+ |------|-------------|
369
+ | `swap_tokens` | Uniswap V3 swap on Base, Arbitrum, Optimism, or Polygon |
370
+ | `bridge_usdc` | CCTP V2 cross-chain USDC bridge (10 EVM chains, ~12s) |
274
371
 
275
- ### 6. `x402_pay`
372
+ ### Identity & Trust
276
373
 
277
- Fetch a URL and automatically handle HTTP 402 Payment Required responses.
374
+ | Tool | What It Does |
375
+ |------|-------------|
376
+ | `verify_agent_identity` | ERC-8004 on-chain identity verification |
377
+ | `get_reputation` | On-chain reputation score and history |
378
+ | `create_escrow` | Mutual-stake USDC escrow — both parties lock collateral |
278
379
 
279
- **Input:**
380
+ ---
381
+
382
+ ## Key Tool Examples
383
+
384
+ ### `x402_pay` — The Core Tool
280
385
 
281
386
  ```json
387
+ // Request
282
388
  {
283
- "url": "https://api.example.com/premium-data",
284
- "max_payment_eth": "0.001",
285
- "timeout_ms": 15000
389
+ "tool": "x402_pay",
390
+ "arguments": {
391
+ "url": "https://api.example.com/premium-data",
392
+ "max_payment_eth": "0.0002"
393
+ }
286
394
  }
395
+
396
+ // Response
397
+ { "status": 200, "body": "{ ... }" }
287
398
  ```
288
399
 
289
- ---
400
+ If the cost exceeds `max_payment_eth`, the tool returns an error before paying — no surprise charges.
290
401
 
291
- ### 7. `get_transaction_history`
402
+ ### `x402_session_start` — Pay Once for Multiple Calls
292
403
 
293
- Retrieve on-chain transaction history from event logs.
404
+ ```json
405
+ // Request
406
+ {
407
+ "tool": "x402_session_start",
408
+ "arguments": {
409
+ "endpoint": "https://api.example.com/",
410
+ "ttl_seconds": 3600,
411
+ "label": "market-data-session"
412
+ }
413
+ }
294
414
 
295
- **Input:**
415
+ // Response
416
+ { "session_id": "sess_abc123", "token": "eyJ...", "expires_at": 1741000000 }
417
+ ```
296
418
 
297
419
  ```json
420
+ // Subsequent calls — no new payment
298
421
  {
299
- "limit": 10,
300
- "event_type": "execution"
422
+ "tool": "x402_session_fetch",
423
+ "arguments": {
424
+ "url": "https://api.example.com/stocks/AAPL",
425
+ "session_id": "sess_abc123"
426
+ }
301
427
  }
302
428
  ```
303
429
 
304
- ---
430
+ ### `check_budget` — Know Before You Loop
305
431
 
306
- ## Security Model
432
+ ```json
433
+ // Request — check before starting an expensive loop
434
+ { "tool": "check_budget", "arguments": {} }
307
435
 
308
- ### Non-Custodial Architecture
436
+ // Response
437
+ {
438
+ "remaining": "7.50 USDC",
439
+ "spent": "2.50 USDC",
440
+ "limit": "10.00 USDC",
441
+ "periodEnds": "2026-03-24T00:00:00Z"
442
+ }
443
+ ```
444
+
445
+ ---
309
446
 
310
- AgentPay MCP wraps **AgentAccountV2** — a smart contract wallet that you own via an NFT. The security model:
447
+ ## Supported Chains
311
448
 
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.
449
+ | Chain | Chain ID | Recommended For |
450
+ |-------|----------|----------------|
451
+ | Base Mainnet | 8453 | Everything lowest gas, most x402 activity |
452
+ | Arbitrum One | 42161 | High-throughput swaps |
453
+ | Optimism | 10 | Low-cost transfers |
454
+ | Polygon | 137 | High-frequency micro-payments |
455
+ | Ethereum Mainnet | 1 | Identity, large settlements |
456
+ | Avalanche | 43114 | Bridge, transfers |
457
+ | Linea / Unichain / Sonic / Worldchain | various | Bridge, transfers |
458
+ | Base Sepolia | 84532 | Testing |
316
459
 
317
- ### Threat Model
460
+ ---
318
461
 
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 |
462
+ ## Security Model
326
463
 
327
- ### Isolation Architecture Why ContextCrush-Style Attacks Don't Apply
464
+ **Non-custodial:** The agent signs all transactions locally with its private key. No third party holds or validates keys.
328
465
 
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.
466
+ **On-chain enforcement:**
467
+ - Per-transaction caps — over-cap transactions queue for human approval via `queue_approval`
468
+ - Daily period limits — aggregate spending enforced by the AgentAccountV2 smart contract
469
+ - Recipient allowlists — restrict which addresses the agent can send to
330
470
 
331
- AgentPay MCP is architecturally immune to this class of attack. Here's why.
471
+ **Role separation:**
472
+ The agent's signing key (`AGENT_PRIVATE_KEY`) can only transact within limits set by the wallet owner. Even if the agent's key is leaked or the agent is compromised, an attacker can only spend up to the configured cap before the next reset.
332
473
 
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
474
+ **x402 sessions:**
475
+ Session tokens are ECDSA-signed claims. Any x402 V2 server can independently verify them no central session store required.
337
476
 
338
- **Why AgentPay MCP doesn't have this surface:**
477
+ **Minimal dependency footprint:**
478
+ AgentPay MCP has **zero LiteLLM dependency**. The entire server runs on `viem` (Ethereum client), `@modelcontextprotocol/sdk`, and a handful of auditable packages — no heavyweight LLM routing layers in the dependency tree. This matters: on March 24, 2026, LiteLLM versions 1.82.7 and 1.82.8 on PyPI were [confirmed compromised](https://github.com/berriai/litellm/issues) in a supply chain attack targeting AI agent infrastructure. Any MCP server that depends on LiteLLM (directly or transitively) was exposed. AgentPay MCP was not — because payment infrastructure should have the smallest possible attack surface.
339
479
 
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.
480
+ ---
341
481
 
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.
482
+ ## MCP 2026 Compliance
343
483
 
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.
484
+ AgentPay MCP aligns with the emerging MCP security standards for 2026, including CoSAI (Coalition for Secure AI) threat categories and OAuth 2.1 requirements.
345
485
 
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.
486
+ **Security posture documentation:** See [`docs/security-posture.md`](docs/security-posture.md) for the full compliance matrix covering:
347
487
 
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.
488
+ - **CoSAI T9 (Financial Fraud)** — On-chain spend caps, merchant allowlists, and human-approval gates mitigate unauthorized agent spending
489
+ - **CoSAI T10 (Identity Spoofing)** — ERC-8004 agent identity verification + non-custodial key management prevent identity-based attacks
490
+ - **OAuth 2.1 + PKCE** — MCP server authentication supports OAuth 2.1 with PKCE for enterprise SSO integration (Azure AD, Okta)
491
+ - **MCP Audit Logging** — Every tool invocation logged with timestamp, parameters, outcome, and transaction hash (where applicable)
349
492
 
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.
493
+ For enterprise security teams evaluating MCP servers: the security posture document provides the artifact your audit process needs.
351
494
 
352
495
  ---
353
496
 
354
- ## Configuration
497
+ ## Architecture
355
498
 
356
- | Variable | Required | Default | Description |
357
- |----------|----------|---------|-------------|
358
- | `AGENT_PRIVATE_KEY` | ✅ | — | Agent hot wallet private key (0x-prefixed hex) |
359
- | `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 |
499
+ ```
500
+ ┌─────────────────────────────────────────┐
501
+ │ AI Agent (Claude / Cursor / Windsurf)
502
+ └────────────────┬────────────────────────┘
503
+ │ MCP (stdio / SSE)
504
+ ┌────────────────▼────────────────────────┐
505
+ │ AgentPay MCP Server │
506
+ │ ┌────────────┐ ┌────────────────────┐
507
+ │ │ 23 Tools │ │ Session Manager │ │
508
+ │ └─────┬──────┘ └────────────────────┘ │
509
+ │ │ │
510
+ │ ┌─────▼──────────────────────────────┐ │
511
+ │ │ agentwallet-sdk v6.0.0 │ │
512
+ │ │ TokenRegistry SwapModule │ │
513
+ │ │ BridgeModule ERC8004Client │ │
514
+ │ └─────┬──────────────────────────────┘ │
515
+ └────────┼────────────────────────────────┘
516
+ │ viem + RPC
517
+ ┌────────▼────────────────────────────────┐
518
+ │ AgentAccountV2 Smart Contract │
519
+ │ SpendingPolicy · Tx Queue │
520
+ │ (12 chains — Base, ETH, ARB, OP, ...) │
521
+ └─────────────────────────────────────────┘
522
+ ```
364
523
 
365
- > **Minimum to get started:** Just `AGENT_PRIVATE_KEY` + `AGENT_WALLET_ADDRESS`. Everything else has sensible defaults.
524
+ Transport: `stdio` by default (Claude Desktop, Cursor, Windsurf). SSE available for remote deployments.
366
525
 
367
526
  ---
368
527
 
369
- ## Integration Examples
528
+ ## Contributing
370
529
 
371
- ### Cursor / Windsurf
372
-
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
- }
530
+ ```bash
531
+ git clone https://github.com/up2itnow0822/agentpay-mcp
532
+ cd agentpay-mcp
533
+ npm install
534
+ npm run build
535
+ npm test
387
536
  ```
388
537
 
389
538
  ---
390
539
 
391
- ## Ecosystem
540
+ ## Patent Notice
392
541
 
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
542
+ **Patent Pending** — USPTO provisional application filed March 2026: "Non-Custodial Multi-Chain Financial Infrastructure System for Autonomous AI Agents."
543
+
544
+ We support the open x402 standard. Our filing is defensive to prevent hostile monopolization of open payment rails, not to restrict builders using open standards.
398
545
 
399
546
  ---
400
547
 
401
548
  ## License
402
549
 
403
- MIT see [LICENSE](LICENSE)
550
+ MIT © [AI Agent Economy](https://ai-agent-economy.com)
551
+
552
+ Built by **AI Agent Economy** — infrastructure for production agent workflows.