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 +381 -232
- package/dist/index.js +83 -1
- package/dist/index.js.map +1 -1
- package/dist/tools/bridge.d.ts +52 -0
- package/dist/tools/bridge.d.ts.map +1 -0
- package/dist/tools/bridge.js +97 -0
- package/dist/tools/bridge.js.map +1 -0
- package/dist/tools/budget.d.ts +84 -0
- package/dist/tools/budget.d.ts.map +1 -0
- package/dist/tools/budget.js +163 -0
- package/dist/tools/budget.js.map +1 -0
- package/dist/tools/escrow.d.ts +73 -0
- package/dist/tools/escrow.d.ts.map +1 -0
- package/dist/tools/escrow.js +146 -0
- package/dist/tools/escrow.js.map +1 -0
- package/dist/tools/identity.d.ts +65 -0
- package/dist/tools/identity.d.ts.map +1 -0
- package/dist/tools/identity.js +158 -0
- package/dist/tools/identity.js.map +1 -0
- package/dist/tools/swap.d.ts +65 -0
- package/dist/tools/swap.d.ts.map +1 -0
- package/dist/tools/swap.js +101 -0
- package/dist/tools/swap.js.map +1 -0
- package/dist/tools/tokens.d.ts +129 -0
- package/dist/tools/tokens.d.ts.map +1 -0
- package/dist/tools/tokens.js +138 -0
- package/dist/tools/tokens.js.map +1 -0
- package/dist/tools/transfers.d.ts +86 -0
- package/dist/tools/transfers.d.ts.map +1 -0
- package/dist/tools/transfers.js +136 -0
- package/dist/tools/transfers.js.map +1 -0
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -1,58 +1,104 @@
|
|
|
1
1
|
# AgentPay MCP
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/agentpay-mcp)
|
|
3
|
+
[](https://www.npmjs.com/package/agentpay-mcp)
|
|
6
4
|
[](LICENSE)
|
|
7
|
-
[](tests/)
|
|
6
|
+
[](https://uspto.gov)
|
|
8
7
|
|
|
9
|
-
|
|
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
|
-
|
|
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
|
-
|
|
24
|
+
The trust gap is the deployment gap. Enterprises aren't saying agents don't work — they're saying the oversight infrastructure (approval workflows, spending guardrails, identity verification, audit trails) hasn't kept pace.
|
|
16
25
|
|
|
17
|
-
|
|
26
|
+
AgentPay MCP addresses this directly:
|
|
18
27
|
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
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
|
-
|
|
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
|
-
##
|
|
38
|
+
## Security & Dependencies
|
|
29
39
|
|
|
30
|
-
|
|
40
|
+
AgentPay MCP is built for enterprise MCP deployments where supply chain security matters.
|
|
31
41
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
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
|
-
|
|
49
|
+
---
|
|
43
50
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
68
|
-
|
|
69
|
-
Create a `.env` file (or set env vars for your MCP client):
|
|
113
|
+
### 2. Configure Claude Desktop
|
|
70
114
|
|
|
71
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
133
|
+
### 3. Configure Cursor
|
|
82
134
|
|
|
83
|
-
|
|
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": "
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
---
|
|
105
|
-
|
|
106
|
-
## Tools Reference
|
|
153
|
+
### 4. Set Spend Caps
|
|
107
154
|
|
|
108
|
-
|
|
155
|
+
Once running, tell your agent:
|
|
109
156
|
|
|
110
|
-
|
|
157
|
+
```
|
|
158
|
+
Set my spend policy: $1 per transaction, $10 per day, only send to allowlisted addresses.
|
|
159
|
+
```
|
|
111
160
|
|
|
112
|
-
|
|
161
|
+
Or call `set_spend_policy` directly:
|
|
113
162
|
|
|
114
163
|
```json
|
|
115
164
|
{
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
|
|
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
|
-
|
|
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
|
-
|
|
125
|
-
✅ Agent Wallet deployed successfully!
|
|
176
|
+
---
|
|
126
177
|
|
|
127
|
-
|
|
128
|
-
🔗 Explorer: https://basescan.org/address/0xabc...
|
|
178
|
+
## Human-Approval Mode (the Default)
|
|
129
179
|
|
|
130
|
-
|
|
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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
-
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"tool": "queue_approval",
|
|
192
|
+
"arguments": {
|
|
193
|
+
"action": "approve",
|
|
194
|
+
"tx_id": "0x..."
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
```
|
|
145
198
|
|
|
146
|
-
|
|
199
|
+
To reject it:
|
|
147
200
|
|
|
148
201
|
```json
|
|
149
202
|
{
|
|
150
|
-
"
|
|
203
|
+
"tool": "queue_approval",
|
|
204
|
+
"arguments": {
|
|
205
|
+
"action": "cancel",
|
|
206
|
+
"tx_id": "0x..."
|
|
207
|
+
}
|
|
151
208
|
}
|
|
152
209
|
```
|
|
153
210
|
|
|
154
|
-
|
|
211
|
+
The agent sees the outcome and decides what to do next (use cached data, ask user, abort).
|
|
155
212
|
|
|
156
|
-
|
|
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
|
-
|
|
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
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
-
###
|
|
249
|
+
### 2. Research Agent
|
|
178
250
|
|
|
179
|
-
|
|
251
|
+
**What it does:** Gathers from free sources first, fills gaps with paid data, compiles a structured output.
|
|
180
252
|
|
|
181
|
-
**
|
|
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
|
-
```
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
-
|
|
266
|
+
**Tools used:** `x402_pay`, `x402_session_start`, `x402_session_fetch`, `check_budget`
|
|
192
267
|
|
|
193
|
-
|
|
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
|
-
|
|
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
|
-
|
|
205
|
-
|
|
278
|
+
To fill these I'd spend ~$2.75 USDC:
|
|
279
|
+
- Apollo contact enrichment: $1.50
|
|
280
|
+
- Crunchbase firmographics: $1.25
|
|
206
281
|
|
|
207
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
292
|
+
### 3. Automation Agent
|
|
220
293
|
|
|
221
|
-
|
|
294
|
+
**What it does:** Completes real tasks end-to-end, paying for whatever services are needed along the way.
|
|
222
295
|
|
|
223
|
-
**
|
|
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
|
-
```
|
|
226
|
-
|
|
227
|
-
|
|
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
|
-
**
|
|
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
|
-
|
|
240
|
-
Within per-tx: ✅ Yes
|
|
311
|
+
---
|
|
241
312
|
|
|
242
|
-
|
|
243
|
-
Within period: ✅ Yes
|
|
244
|
-
Resets in: 18h 22m
|
|
313
|
+
## Environment Variables
|
|
245
314
|
|
|
246
|
-
|
|
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
|
-
|
|
330
|
+
## All 23 Tools
|
|
252
331
|
|
|
253
|
-
|
|
332
|
+
### Payments & 402 Flow
|
|
254
333
|
|
|
255
|
-
|
|
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
|
-
|
|
258
|
-
{ "action": "list" }
|
|
259
|
-
```
|
|
342
|
+
### Wallet & Spend Control
|
|
260
343
|
|
|
261
|
-
|
|
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
|
-
|
|
264
|
-
{ "action": "approve", "tx_id": "0" }
|
|
265
|
-
```
|
|
355
|
+
### Token Operations
|
|
266
356
|
|
|
267
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
372
|
+
### Identity & Trust
|
|
276
373
|
|
|
277
|
-
|
|
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
|
-
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
## Key Tool Examples
|
|
383
|
+
|
|
384
|
+
### `x402_pay` — The Core Tool
|
|
280
385
|
|
|
281
386
|
```json
|
|
387
|
+
// Request
|
|
282
388
|
{
|
|
283
|
-
"
|
|
284
|
-
"
|
|
285
|
-
|
|
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
|
-
###
|
|
402
|
+
### `x402_session_start` — Pay Once for Multiple Calls
|
|
292
403
|
|
|
293
|
-
|
|
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
|
-
|
|
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
|
-
"
|
|
300
|
-
"
|
|
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
|
-
|
|
432
|
+
```json
|
|
433
|
+
// Request — check before starting an expensive loop
|
|
434
|
+
{ "tool": "check_budget", "arguments": {} }
|
|
307
435
|
|
|
308
|
-
|
|
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
|
-
|
|
447
|
+
## Supported Chains
|
|
311
448
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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
|
-
|
|
460
|
+
---
|
|
318
461
|
|
|
319
|
-
|
|
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
|
-
|
|
464
|
+
**Non-custodial:** The agent signs all transactions locally with its private key. No third party holds or validates keys.
|
|
328
465
|
|
|
329
|
-
|
|
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
|
-
|
|
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
|
-
**
|
|
334
|
-
|
|
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
|
-
**
|
|
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
|
-
|
|
480
|
+
---
|
|
341
481
|
|
|
342
|
-
|
|
482
|
+
## MCP 2026 Compliance
|
|
343
483
|
|
|
344
|
-
|
|
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
|
-
|
|
486
|
+
**Security posture documentation:** See [`docs/security-posture.md`](docs/security-posture.md) for the full compliance matrix covering:
|
|
347
487
|
|
|
348
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
497
|
+
## Architecture
|
|
355
498
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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
|
-
|
|
524
|
+
Transport: `stdio` by default (Claude Desktop, Cursor, Windsurf). SSE available for remote deployments.
|
|
366
525
|
|
|
367
526
|
---
|
|
368
527
|
|
|
369
|
-
##
|
|
528
|
+
## Contributing
|
|
370
529
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
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
|
-
##
|
|
540
|
+
## Patent Notice
|
|
392
541
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
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
|
|
550
|
+
MIT © [AI Agent Economy](https://ai-agent-economy.com)
|
|
551
|
+
|
|
552
|
+
Built by **AI Agent Economy** — infrastructure for production agent workflows.
|