mcp-server-agentpay 1.0.3 → 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 +43 -8
- package/package.json +4 -2
- package/server.json +2 -2
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,15 +10,36 @@ 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
|
|
|
30
|
+
const MAX_RESPONSE_SIZE = 5 * 1024 * 1024; // 5MB
|
|
31
|
+
|
|
17
32
|
function request(method, urlPath, body, timeout = 120_000) {
|
|
18
33
|
return new Promise((resolve, reject) => {
|
|
19
34
|
const fullUrl = `${BASE_URL}${urlPath}`;
|
|
20
|
-
const mod = fullUrl.startsWith("https") ? https : http;
|
|
21
35
|
const parsed = new URL(fullUrl);
|
|
36
|
+
const isHttps = parsed.protocol === "https:";
|
|
37
|
+
|
|
38
|
+
if (!isHttps && GATEWAY_KEY) {
|
|
39
|
+
return reject(new Error("Refusing to send gateway key over insecure HTTP. Use HTTPS."));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const mod = isHttps ? https : http;
|
|
22
43
|
|
|
23
44
|
const headers = {
|
|
24
45
|
"Content-Type": "application/json",
|
|
@@ -28,7 +49,7 @@ function request(method, urlPath, body, timeout = 120_000) {
|
|
|
28
49
|
|
|
29
50
|
const opts = {
|
|
30
51
|
hostname: parsed.hostname,
|
|
31
|
-
port: parsed.port || (
|
|
52
|
+
port: parsed.port || (isHttps ? 443 : 80),
|
|
32
53
|
path: parsed.pathname + parsed.search,
|
|
33
54
|
method,
|
|
34
55
|
headers,
|
|
@@ -37,7 +58,12 @@ function request(method, urlPath, body, timeout = 120_000) {
|
|
|
37
58
|
|
|
38
59
|
const req = mod.request(opts, (res) => {
|
|
39
60
|
let data = "";
|
|
40
|
-
|
|
61
|
+
let size = 0;
|
|
62
|
+
res.on("data", (c) => {
|
|
63
|
+
size += c.length;
|
|
64
|
+
if (size > MAX_RESPONSE_SIZE) { req.destroy(); return reject(new Error("Response too large")); }
|
|
65
|
+
data += c;
|
|
66
|
+
});
|
|
41
67
|
res.on("end", () => {
|
|
42
68
|
try {
|
|
43
69
|
const json = JSON.parse(data);
|
|
@@ -128,7 +154,7 @@ server.tool(
|
|
|
128
154
|
|
|
129
155
|
server.tool(
|
|
130
156
|
"call_tool",
|
|
131
|
-
"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.",
|
|
132
158
|
{
|
|
133
159
|
tool: z.string().describe("Tool ID (e.g. 'agent-audit', 'indexforge')"),
|
|
134
160
|
method: z.string().describe("Method name (e.g. 'security_scan', 'scan_sitemap')"),
|
|
@@ -136,13 +162,22 @@ server.tool(
|
|
|
136
162
|
},
|
|
137
163
|
async ({ tool, method, params_json }) => {
|
|
138
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
|
+
|
|
139
171
|
try {
|
|
140
172
|
let params = {};
|
|
141
173
|
if (params_json) {
|
|
142
174
|
try { params = JSON.parse(params_json); } catch { return { content: [{ type: "text", text: "Error: params_json must be valid JSON" }] }; }
|
|
143
175
|
}
|
|
144
176
|
const result = await request("POST", "/gateway/call", { tool, method, params }, 600_000);
|
|
145
|
-
const
|
|
177
|
+
const cost = Number(result.cost) || 0;
|
|
178
|
+
sessionSpent += cost;
|
|
179
|
+
const balance = Number(result.balance) || 0;
|
|
180
|
+
const meta = `[Cost: $${cost.toFixed(2)} | Balance: $${balance.toFixed(2)} | Session: $${sessionSpent.toFixed(2)}/$${SESSION_BUDGET} | Time: ${result.elapsed || 0}ms]`;
|
|
146
181
|
return {
|
|
147
182
|
content: [{ type: "text", text: `${meta}\n\n${JSON.stringify(result.result, null, 2)}` }],
|
|
148
183
|
};
|
|
@@ -177,7 +212,7 @@ server.tool(
|
|
|
177
212
|
"get_usage",
|
|
178
213
|
"View your recent tool call history — which tools you called, what methods, how much each cost, and when.",
|
|
179
214
|
{
|
|
180
|
-
limit: z.number().default(20).describe("Number of recent calls to show (default: 20, max: 200)"),
|
|
215
|
+
limit: z.number().int().min(1).max(200).default(20).describe("Number of recent calls to show (default: 20, max: 200)"),
|
|
181
216
|
},
|
|
182
217
|
async ({ limit }) => {
|
|
183
218
|
if (!GATEWAY_KEY) return noKeyError();
|
|
@@ -213,7 +248,7 @@ server.tool(
|
|
|
213
248
|
|
|
214
249
|
server.tool(
|
|
215
250
|
"fund_wallet_x402",
|
|
216
|
-
"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.",
|
|
217
252
|
{
|
|
218
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)"),
|
|
219
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,7 +44,8 @@
|
|
|
44
44
|
"url": "https://github.com/joepangallo/agent-pay"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@modelcontextprotocol/sdk": "
|
|
47
|
+
"@modelcontextprotocol/sdk": "1.27.0",
|
|
48
|
+
"zod": "3.24.2"
|
|
48
49
|
},
|
|
49
50
|
"engines": {
|
|
50
51
|
"node": ">=18"
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
"files": [
|
|
53
54
|
"index.js",
|
|
54
55
|
"README.md",
|
|
56
|
+
"SKILL.md",
|
|
55
57
|
"server.json",
|
|
56
58
|
"package.json"
|
|
57
59
|
]
|
package/server.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/joepangallo/agent-pay",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.4",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "mcp-server-agentpay",
|
|
14
|
-
"version": "1.0.
|
|
14
|
+
"version": "1.0.4",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
},
|