mcp-server-agentpay 1.0.2 → 1.0.4

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
@@ -14,6 +14,23 @@ claude mcp add agentpay -- npx mcp-server-agentpay
14
14
  export AGENTPAY_GATEWAY_KEY="apg_your_key_here"
15
15
  ```
16
16
 
17
+ Or add to `~/.claude/settings.json`:
18
+
19
+ ```json
20
+ {
21
+ "mcpServers": {
22
+ "agentpay": {
23
+ "command": "npx",
24
+ "args": ["-y", "mcp-server-agentpay"],
25
+ "env": {
26
+ "AGENTPAY_GATEWAY_KEY": "apg_your_key_here",
27
+ "AGENTPAY_URL": "https://agentpay.metaltorque.dev"
28
+ }
29
+ }
30
+ }
31
+ }
32
+ ```
33
+
17
34
  ## Get a Gateway Key
18
35
 
19
36
  ```bash
@@ -24,22 +41,42 @@ curl -X POST https://agentpay.metaltorque.dev/gateway/register \
24
41
 
25
42
  You get $1 in free credits to start.
26
43
 
27
- ## Tools
44
+ ## Tools (9 total)
28
45
 
29
46
  | Tool | Description |
30
47
  |------|-------------|
48
+ | `discover_tools` | Search tools by keyword |
31
49
  | `list_tools` | List all available tools with pricing |
32
- | `discover_tools` | Search tools by keyword/capability |
33
- | `call_tool` | Call any tool method (auto-provisions, metered) |
34
50
  | `check_balance` | Check wallet balance and provisioned tools |
51
+ | `call_tool` | Call any tool method (metered, auto-provisions) |
35
52
  | `provision_tool` | Pre-provision access to a tool |
36
53
  | `get_usage` | View recent call history and costs |
37
- | `fund_wallet` | Get Stripe checkout URL to add credits |
54
+ | `fund_wallet_stripe` | Get Stripe checkout URL for credits |
55
+ | `fund_wallet_x402` | Get x402 crypto funding info |
56
+ | `x402_info` | View x402 payment options and setup |
57
+
58
+ ## Funding Methods
59
+
60
+ ### Stripe (human-in-the-loop)
61
+ Use `fund_wallet_stripe` — returns a checkout URL for a human to complete.
62
+
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.
65
+
66
+ ## Credit Packages
67
+
68
+ | Package | Price | Credits |
69
+ |---------|-------|---------|
70
+ | micro | $10 | 10 |
71
+ | small | $45 | 50 |
72
+ | medium | $80 | 100 |
73
+ | large | $350 | 500 |
74
+ | whale | $600 | 1,000 |
38
75
 
39
76
  ## How It Works
40
77
 
41
78
  1. **Register** — create a wallet, get a gateway key
42
- 2. **Fund** — add credits via Stripe ($10–$600 packages)
79
+ 2. **Fund** — add credits via Stripe or x402 USDC
43
80
  3. **Discover** — agent searches for tools by capability
44
81
  4. **Call** — agent calls any tool, gateway handles auth + billing
45
82
 
@@ -58,3 +95,9 @@ The agent never needs to know about individual tool APIs, accounts, or payment.
58
95
  - **IndexForge SEO** — submit URLs to Google/Bing, scan sitemaps, check index status
59
96
 
60
97
  More tools added regularly. Tool providers can register at the gateway.
98
+
99
+ ## Links
100
+
101
+ - [GitHub](https://github.com/joepangallo/agent-pay)
102
+ - [API Docs](https://agentpay.metaltorque.dev/docs)
103
+ - [MCP Registry](https://registry.modelcontextprotocol.io) — `io.github.joepangallo/agent-pay`
package/index.js CHANGED
@@ -5,6 +5,7 @@ const { StdioServerTransport } = require("@modelcontextprotocol/sdk/server/stdio
5
5
  const { z } = require("zod");
6
6
  const https = require("https");
7
7
  const http = require("http");
8
+ const { version } = require("./package.json");
8
9
 
9
10
  // ── Config ──────────────────────────────────────────────────────────
10
11
 
@@ -13,21 +14,29 @@ const BASE_URL = (process.env.AGENTPAY_URL || "https://agentpay.metaltorque.dev"
13
14
 
14
15
  // ── HTTP helper ─────────────────────────────────────────────────────
15
16
 
17
+ const MAX_RESPONSE_SIZE = 5 * 1024 * 1024; // 5MB
18
+
16
19
  function request(method, urlPath, body, timeout = 120_000) {
17
20
  return new Promise((resolve, reject) => {
18
21
  const fullUrl = `${BASE_URL}${urlPath}`;
19
- const mod = fullUrl.startsWith("https") ? https : http;
20
22
  const parsed = new URL(fullUrl);
23
+ const isHttps = parsed.protocol === "https:";
24
+
25
+ if (!isHttps && GATEWAY_KEY) {
26
+ return reject(new Error("Refusing to send gateway key over insecure HTTP. Use HTTPS."));
27
+ }
28
+
29
+ const mod = isHttps ? https : http;
21
30
 
22
31
  const headers = {
23
32
  "Content-Type": "application/json",
24
- "User-Agent": "mcp-server-agentpay/1.0.0",
33
+ "User-Agent": `mcp-server-agentpay/${version}`,
25
34
  };
26
35
  if (GATEWAY_KEY) headers["X-Gateway-Key"] = GATEWAY_KEY;
27
36
 
28
37
  const opts = {
29
38
  hostname: parsed.hostname,
30
- port: parsed.port || (parsed.protocol === "https:" ? 443 : 80),
39
+ port: parsed.port || (isHttps ? 443 : 80),
31
40
  path: parsed.pathname + parsed.search,
32
41
  method,
33
42
  headers,
@@ -36,7 +45,12 @@ function request(method, urlPath, body, timeout = 120_000) {
36
45
 
37
46
  const req = mod.request(opts, (res) => {
38
47
  let data = "";
39
- res.on("data", (c) => (data += c));
48
+ let size = 0;
49
+ res.on("data", (c) => {
50
+ size += c.length;
51
+ if (size > MAX_RESPONSE_SIZE) { req.destroy(); return reject(new Error("Response too large")); }
52
+ data += c;
53
+ });
40
54
  res.on("end", () => {
41
55
  try {
42
56
  const json = JSON.parse(data);
@@ -66,7 +80,7 @@ function noKeyError() {
66
80
 
67
81
  const server = new McpServer({
68
82
  name: "agentpay",
69
- version: "1.0.0",
83
+ version,
70
84
  });
71
85
 
72
86
  // ── Tool: discover_tools ────────────────────────────────────────────
@@ -83,7 +97,7 @@ server.tool(
83
97
  if (result.count === 0) {
84
98
  return { content: [{ type: "text", text: `No tools found for "${query}". Try: security, seo, indexing, vulnerability, audit` }] };
85
99
  }
86
- return { content: [{ type: "text", text: JSON.stringify(result.tools, null, 2) }] };
100
+ return { content: [{ type: "text", text: JSON.stringify(result.tools ?? [], null, 2) }] };
87
101
  } catch (e) {
88
102
  return { content: [{ type: "text", text: `Error: ${e.message}` }] };
89
103
  }
@@ -99,7 +113,7 @@ server.tool(
99
113
  async () => {
100
114
  try {
101
115
  const result = await request("GET", "/gateway/tools");
102
- return { content: [{ type: "text", text: JSON.stringify(result.tools, null, 2) }] };
116
+ return { content: [{ type: "text", text: JSON.stringify(result.tools ?? [], null, 2) }] };
103
117
  } catch (e) {
104
118
  return { content: [{ type: "text", text: `Error: ${e.message}` }] };
105
119
  }
@@ -141,7 +155,9 @@ server.tool(
141
155
  try { params = JSON.parse(params_json); } catch { return { content: [{ type: "text", text: "Error: params_json must be valid JSON" }] }; }
142
156
  }
143
157
  const result = await request("POST", "/gateway/call", { tool, method, params }, 600_000);
144
- const meta = `[Cost: $${(result.cost || 0).toFixed(2)} | Balance: $${(result.balance || 0).toFixed(2)} | Time: ${result.elapsed || 0}ms]`;
158
+ const cost = Number(result.cost) || 0;
159
+ const balance = Number(result.balance) || 0;
160
+ const meta = `[Cost: $${cost.toFixed(2)} | Balance: $${balance.toFixed(2)} | Time: ${result.elapsed || 0}ms]`;
145
161
  return {
146
162
  content: [{ type: "text", text: `${meta}\n\n${JSON.stringify(result.result, null, 2)}` }],
147
163
  };
@@ -176,13 +192,13 @@ server.tool(
176
192
  "get_usage",
177
193
  "View your recent tool call history — which tools you called, what methods, how much each cost, and when.",
178
194
  {
179
- limit: z.number().default(20).describe("Number of recent calls to show (default: 20, max: 200)"),
195
+ limit: z.number().int().min(1).max(200).default(20).describe("Number of recent calls to show (default: 20, max: 200)"),
180
196
  },
181
197
  async ({ limit }) => {
182
198
  if (!GATEWAY_KEY) return noKeyError();
183
199
  try {
184
200
  const result = await request("GET", `/gateway/usage?limit=${limit}`);
185
- return { content: [{ type: "text", text: JSON.stringify(result.usage, null, 2) }] };
201
+ return { content: [{ type: "text", text: JSON.stringify(result.usage ?? [], null, 2) }] };
186
202
  } catch (e) {
187
203
  return { content: [{ type: "text", text: `Error: ${e.message}` }] };
188
204
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-server-agentpay",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
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,13 +44,16 @@
44
44
  "url": "https://github.com/joepangallo/agent-pay"
45
45
  },
46
46
  "dependencies": {
47
- "@modelcontextprotocol/sdk": "^1.27.0"
47
+ "@modelcontextprotocol/sdk": "^1.27.0",
48
+ "zod": "^3.23.0"
48
49
  },
49
50
  "engines": {
50
51
  "node": ">=18"
51
52
  },
52
53
  "files": [
53
54
  "index.js",
54
- "README.md"
55
+ "README.md",
56
+ "server.json",
57
+ "package.json"
55
58
  ]
56
59
  }
package/server.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.joepangallo/agent-pay",
4
+ "description": "Payment gateway for AI agents. Tool discovery, provisioning, and pay-per-call metering.",
5
+ "repository": {
6
+ "url": "https://github.com/joepangallo/agent-pay",
7
+ "source": "github"
8
+ },
9
+ "version": "1.0.4",
10
+ "packages": [
11
+ {
12
+ "registryType": "npm",
13
+ "identifier": "mcp-server-agentpay",
14
+ "version": "1.0.4",
15
+ "transport": {
16
+ "type": "stdio"
17
+ },
18
+ "environmentVariables": [
19
+ {
20
+ "description": "Your AgentPay gateway key (starts with apg_)",
21
+ "isRequired": true,
22
+ "format": "string",
23
+ "isSecret": true,
24
+ "name": "AGENTPAY_GATEWAY_KEY"
25
+ },
26
+ {
27
+ "description": "AgentPay API URL",
28
+ "isRequired": false,
29
+ "format": "string",
30
+ "isSecret": false,
31
+ "name": "AGENTPAY_URL"
32
+ }
33
+ ]
34
+ }
35
+ ]
36
+ }