mcp-server-agentpay 1.0.4 → 1.0.5
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 +1 -1
- package/SKILL.md +112 -0
- package/index.js +24 -4
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ You get $1 in free credits to start.
|
|
|
61
61
|
Use `fund_wallet_stripe` — returns a checkout URL for a human to complete.
|
|
62
62
|
|
|
63
63
|
### x402 USDC (fully autonomous)
|
|
64
|
-
Use `fund_wallet_x402` — returns endpoint, network, and instructions for autonomous USDC payments via the x402 protocol. No human needed.
|
|
64
|
+
Use `fund_wallet_x402` — returns endpoint, network, and instructions for autonomous USDC payments via the x402 protocol on Base mainnet. No human needed.
|
|
65
65
|
|
|
66
66
|
## Credit Packages
|
|
67
67
|
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentpay
|
|
3
|
+
description: "Payment gateway for autonomous AI agents — discover, provision, and pay for MCP tool APIs with a single gateway key. Use when building agents that need to pay for API calls, integrating metered billing into MCP workflows, setting up agent wallets, or working with the AgentPay gateway (Stripe + x402 USDC funding). Triggers on: agent payments, tool marketplace, metered billing, agent wallet, gateway key, AgentPay, pay-per-call, autonomous funding, x402, agent economy."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AgentPay — Payment Gateway for AI Agents
|
|
7
|
+
|
|
8
|
+
One key, every tool. Agents discover, provision, and pay for tool APIs through a single gateway — no per-service accounts or auth.
|
|
9
|
+
|
|
10
|
+
## Quick Setup
|
|
11
|
+
|
|
12
|
+
### Add MCP Server
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
claude mcp add agentpay -- npx -y mcp-server-agentpay
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Or in `~/.claude/settings.json`:
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"mcpServers": {
|
|
23
|
+
"agentpay": {
|
|
24
|
+
"command": "npx",
|
|
25
|
+
"args": ["-y", "mcp-server-agentpay"],
|
|
26
|
+
"env": {
|
|
27
|
+
"AGENTPAY_GATEWAY_KEY": "apg_your_key_here"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Register
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
curl -X POST https://agentpay.metaltorque.dev/gateway/register \
|
|
38
|
+
-H "Content-Type: application/json" \
|
|
39
|
+
-d '{"email": "you@example.com"}'
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Returns `apg_` key + $1 free credits.
|
|
43
|
+
|
|
44
|
+
## MCP Tools
|
|
45
|
+
|
|
46
|
+
| Tool | Purpose |
|
|
47
|
+
|------|---------|
|
|
48
|
+
| `discover_tools` | Search tools by keyword |
|
|
49
|
+
| `list_tools` | List all tools with pricing |
|
|
50
|
+
| `check_balance` | Wallet balance and provisioned tools |
|
|
51
|
+
| `call_tool` | Call any tool method (auto-provisions, metered) |
|
|
52
|
+
| `provision_tool` | Pre-provision access (optional) |
|
|
53
|
+
| `get_usage` | Call history with costs |
|
|
54
|
+
| `fund_wallet_stripe` | Stripe checkout URL (human pays) |
|
|
55
|
+
| `fund_wallet_x402` | x402 USDC funding (fully autonomous) |
|
|
56
|
+
| `x402_info` | x402 payment details |
|
|
57
|
+
|
|
58
|
+
## Workflow
|
|
59
|
+
|
|
60
|
+
1. **Register** → get `apg_` key + $1 free
|
|
61
|
+
2. **Fund** → Stripe (human) or x402 USDC (autonomous)
|
|
62
|
+
3. **Discover** → search tools by capability
|
|
63
|
+
4. **Call** → gateway handles auth + billing
|
|
64
|
+
|
|
65
|
+
## Calling Tools
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
call_tool(tool: "agent-audit", method: "security_scan", params_json: '{"url": "example.com"}')
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Response: `[Cost: $0.50 | Balance: $9.50 | Time: 1200ms]` + tool result.
|
|
72
|
+
|
|
73
|
+
## Credit Packages
|
|
74
|
+
|
|
75
|
+
| Package | Price | Credits |
|
|
76
|
+
|---------|-------|---------|
|
|
77
|
+
| micro | $10 | 10 |
|
|
78
|
+
| small | $45 | 50 |
|
|
79
|
+
| medium | $80 | 100 |
|
|
80
|
+
| large | $350 | 500 |
|
|
81
|
+
| whale | $600 | 1,000 |
|
|
82
|
+
|
|
83
|
+
## Autonomous Funding (x402 USDC)
|
|
84
|
+
|
|
85
|
+
For fully autonomous operation without human intervention:
|
|
86
|
+
|
|
87
|
+
```javascript
|
|
88
|
+
import { wrapFetchWithPayment } from "@x402/fetch";
|
|
89
|
+
const res = await fetchWithPayment(endpoint, {
|
|
90
|
+
method: "POST",
|
|
91
|
+
headers: { "X-Gateway-Key": key }
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Requires: `npm install @x402/fetch @x402/evm` + `EVM_PRIVATE_KEY` env var.
|
|
96
|
+
|
|
97
|
+
## Environment Variables
|
|
98
|
+
|
|
99
|
+
| Variable | Required | Default |
|
|
100
|
+
|----------|----------|---------|
|
|
101
|
+
| `AGENTPAY_GATEWAY_KEY` | Yes | — |
|
|
102
|
+
| `AGENTPAY_URL` | No | `https://agentpay.metaltorque.dev` |
|
|
103
|
+
|
|
104
|
+
## For Tool Providers
|
|
105
|
+
|
|
106
|
+
Register tools on the marketplace — see `references/api_reference.md` for developer endpoints, SDK usage, and enterprise features.
|
|
107
|
+
|
|
108
|
+
## Links
|
|
109
|
+
|
|
110
|
+
- npm: `mcp-server-agentpay`
|
|
111
|
+
- GitHub: `github.com/joepangallo/agent-pay`
|
|
112
|
+
- MCP Registry: `io.github.joepangallo/agent-pay`
|
package/index.js
CHANGED
|
@@ -10,7 +10,20 @@ const { version } = require("./package.json");
|
|
|
10
10
|
// ── Config ──────────────────────────────────────────────────────────
|
|
11
11
|
|
|
12
12
|
const GATEWAY_KEY = process.env.AGENTPAY_GATEWAY_KEY || "";
|
|
13
|
-
const
|
|
13
|
+
const ALLOWED_HOSTS = ["agentpay.metaltorque.dev", "localhost", "127.0.0.1"];
|
|
14
|
+
const rawUrl = (process.env.AGENTPAY_URL || "https://agentpay.metaltorque.dev").replace(/\/$/, "");
|
|
15
|
+
const parsedHost = new URL(rawUrl).hostname;
|
|
16
|
+
if (!ALLOWED_HOSTS.includes(parsedHost)) {
|
|
17
|
+
console.error(`[agentpay] SECURITY: AGENTPAY_URL host "${parsedHost}" not in allowlist. Refusing to start.`);
|
|
18
|
+
console.error(`[agentpay] Allowed: ${ALLOWED_HOSTS.join(", ")}. Override with caution.`);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
const BASE_URL = rawUrl;
|
|
22
|
+
|
|
23
|
+
// ── Session spending cap ────────────────────────────────────────────
|
|
24
|
+
|
|
25
|
+
const SESSION_BUDGET = Number(process.env.AGENTPAY_SESSION_BUDGET) || 25; // $25 default
|
|
26
|
+
let sessionSpent = 0;
|
|
14
27
|
|
|
15
28
|
// ── HTTP helper ─────────────────────────────────────────────────────
|
|
16
29
|
|
|
@@ -141,7 +154,7 @@ server.tool(
|
|
|
141
154
|
|
|
142
155
|
server.tool(
|
|
143
156
|
"call_tool",
|
|
144
|
-
"Call any tool method through the AgentPay gateway. Automatically provisions access on first use. Credits are deducted per call. Use discover_tools or list_tools first to see available tools and methods.",
|
|
157
|
+
"Call any tool method through the AgentPay gateway. Automatically provisions access on first use. Credits are deducted per call (real money). Use discover_tools or list_tools first to see available tools and methods. IMPORTANT: Each call costs real credits. Only call when explicitly instructed by the user.",
|
|
145
158
|
{
|
|
146
159
|
tool: z.string().describe("Tool ID (e.g. 'agent-audit', 'indexforge')"),
|
|
147
160
|
method: z.string().describe("Method name (e.g. 'security_scan', 'scan_sitemap')"),
|
|
@@ -149,6 +162,12 @@ server.tool(
|
|
|
149
162
|
},
|
|
150
163
|
async ({ tool, method, params_json }) => {
|
|
151
164
|
if (!GATEWAY_KEY) return noKeyError();
|
|
165
|
+
|
|
166
|
+
// Session spending cap
|
|
167
|
+
if (sessionSpent >= SESSION_BUDGET) {
|
|
168
|
+
return { content: [{ type: "text", text: `Session budget exhausted ($${sessionSpent.toFixed(2)}/$${SESSION_BUDGET}). Restart the MCP server or increase AGENTPAY_SESSION_BUDGET to continue.` }] };
|
|
169
|
+
}
|
|
170
|
+
|
|
152
171
|
try {
|
|
153
172
|
let params = {};
|
|
154
173
|
if (params_json) {
|
|
@@ -156,8 +175,9 @@ server.tool(
|
|
|
156
175
|
}
|
|
157
176
|
const result = await request("POST", "/gateway/call", { tool, method, params }, 600_000);
|
|
158
177
|
const cost = Number(result.cost) || 0;
|
|
178
|
+
sessionSpent += cost;
|
|
159
179
|
const balance = Number(result.balance) || 0;
|
|
160
|
-
const meta = `[Cost: $${cost.toFixed(2)} | Balance: $${balance.toFixed(2)} | Time: ${result.elapsed || 0}ms]`;
|
|
180
|
+
const meta = `[Cost: $${cost.toFixed(2)} | Balance: $${balance.toFixed(2)} | Session: $${sessionSpent.toFixed(2)}/$${SESSION_BUDGET} | Time: ${result.elapsed || 0}ms]`;
|
|
161
181
|
return {
|
|
162
182
|
content: [{ type: "text", text: `${meta}\n\n${JSON.stringify(result.result, null, 2)}` }],
|
|
163
183
|
};
|
|
@@ -228,7 +248,7 @@ server.tool(
|
|
|
228
248
|
|
|
229
249
|
server.tool(
|
|
230
250
|
"fund_wallet_x402",
|
|
231
|
-
"Get x402 crypto funding info for your wallet. Returns the endpoint URL, network, and setup instructions. To actually pay, your HTTP client needs @x402/fetch which automatically handles the 402 payment flow
|
|
251
|
+
"Get x402 crypto funding info for your wallet. Returns the endpoint URL, network, and setup instructions. IMPORTANT: This spends real USDC on Base mainnet. Only call when explicitly instructed by the user. To actually pay, your HTTP client needs @x402/fetch which automatically handles the 402 payment flow.",
|
|
232
252
|
{
|
|
233
253
|
package: z.enum(["micro", "small", "medium", "large", "whale"]).describe("Credit package: micro ($10/10cr), small ($45/50cr), medium ($80/100cr), large ($350/500cr), whale ($600/1000cr)"),
|
|
234
254
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-server-agentpay",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"mcpName": "io.github.joepangallo/agent-pay",
|
|
5
5
|
"description": "MCP server for AgentPay — the payment gateway for autonomous AI agents. Lets agents discover, provision, and pay for MCP tool APIs with a single gateway key.",
|
|
6
6
|
"bin": {
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"url": "https://github.com/joepangallo/agent-pay"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@modelcontextprotocol/sdk": "
|
|
48
|
-
"zod": "
|
|
47
|
+
"@modelcontextprotocol/sdk": "1.27.0",
|
|
48
|
+
"zod": "3.24.2"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": ">=18"
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"files": [
|
|
54
54
|
"index.js",
|
|
55
55
|
"README.md",
|
|
56
|
+
"SKILL.md",
|
|
56
57
|
"server.json",
|
|
57
58
|
"package.json"
|
|
58
59
|
]
|