netintel-mcp 1.1.54 → 1.1.57

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
@@ -38,7 +38,7 @@ Or add manually to your Claude Desktop config:
38
38
 
39
39
  ## Requirements
40
40
  - **Optional:** `EVM_PRIVATE_KEY` — a dedicated agent wallet holding USDC on Base mainnet (gasless; a few dollars is plenty). With it, every tool pays its listed price automatically.
41
- - **Without a wallet** the server still runs: `netintel_dns_lookup`, `netintel_ssl_cert`, `netintel_whois_lookup`, `netintel_subnet_calc` and `netintel_email_auth` work free (about 30 calls/hour per client, then the normal price), and paid tools reply with what they cost and how to fund. `netintel_wallet_status` shows the wallet, its USDC balance and the free tools.
41
+ - **Without a wallet** the server still runs: every tool replies with what it costs and how to fund, and `netintel_wallet_status` shows the wallet and its USDC balance. **Spending limits (≥1.1.55):** the server refuses to sign a payment above `NETINTEL_MAX_PER_CALL_USD` (default $0.25) or once it has authorized `NETINTEL_MAX_SESSION_USD` (default $5) in total per process; a refusal returns `SPEND_LIMIT: …` and nothing is paid. Listed prices are what a call costs, not a cap — with a wallet configured every 402 is paid automatically, so authorize paid calls with your user first.
42
42
 
43
43
  ## Tools
44
44
 
package/dist/client.js CHANGED
@@ -9,15 +9,49 @@ import axios from "axios";
9
9
  const BASE_URL = "https://netintel.dev";
10
10
  /** USDC on Base mainnet — the asset every NetIntel price is quoted in. */
11
11
  const USDC_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
12
- /** Tools that work with NO wallet: NetIntel's free tier (per-client quota, then the normal price). */
13
- export const FREE_TOOLS = [
14
- "netintel_dns_lookup",
15
- "netintel_ssl_cert",
16
- "netintel_whois_lookup",
17
- "netintel_subnet_calc",
18
- "netintel_email_auth",
19
- ];
12
+ /**
13
+ * Tools that work with NO wallet. NetIntel's free tier is switched by the API's
14
+ * FREE_TIER env and has been OFF since 2026-10-08, so every call is paid and this
15
+ * list is empty. If the API turns it back on, list its tools here again
16
+ * (netintel_dns_lookup, netintel_ssl_cert, netintel_whois_lookup,
17
+ * netintel_subnet_calc, netintel_email_auth) — every "works free" message keys off it.
18
+ */
19
+ export const FREE_TOOLS = [];
20
20
  let walletAddress = null;
21
+ /**
22
+ * Spending limits, enforced INSIDE the x402 client immediately before a payment
23
+ * payload is signed — the only place a limit can be real, because with a wallet
24
+ * configured every 402 is paid automatically. The listed per-call prices are
25
+ * what a route costs, not a cap.
26
+ * NETINTEL_MAX_PER_CALL_USD — refuse any single payment above this (default $0.25)
27
+ * NETINTEL_MAX_SESSION_USD — refuse once this MCP server process has authorized
28
+ * this much in total (default $5.00)
29
+ * A refusal aborts the payment (nothing is signed or sent) and the tool returns
30
+ * "SPEND_LIMIT: …" telling the agent which limit and how to raise it. Session
31
+ * spend counts every authorized payment, whether or not the call then succeeds
32
+ * (conservative: a payment that settles for a failed call is not charged by
33
+ * NetIntel, but the signature was still handed out).
34
+ */
35
+ const SPEND_LIMIT = "SPEND_LIMIT";
36
+ function limit(envName, fallback) {
37
+ const n = Number(process.env[envName]);
38
+ return Number.isFinite(n) && n >= 0 ? n : fallback;
39
+ }
40
+ export const MAX_PER_CALL_USD = limit("NETINTEL_MAX_PER_CALL_USD", 0.25);
41
+ export const MAX_SESSION_USD = limit("NETINTEL_MAX_SESSION_USD", 5);
42
+ let sessionAuthorizedUsd = 0;
43
+ let refusedPayments = 0;
44
+ /** What the limits are and how much this server process has authorized so far. */
45
+ export function spendStatus() {
46
+ return {
47
+ max_per_call_usd: MAX_PER_CALL_USD,
48
+ max_session_usd: MAX_SESSION_USD,
49
+ session_authorized_usd: Number(sessionAuthorizedUsd.toFixed(6)),
50
+ session_remaining_usd: Number(Math.max(0, MAX_SESSION_USD - sessionAuthorizedUsd).toFixed(6)),
51
+ refused_payments: refusedPayments,
52
+ configure: "NETINTEL_MAX_PER_CALL_USD / NETINTEL_MAX_SESSION_USD (env, or the Claude Code plugin config); limits are per MCP server process",
53
+ };
54
+ }
21
55
  /** The configured agent wallet's address, or null when the server runs wallet-less. */
22
56
  export function configuredWallet() {
23
57
  return walletAddress;
@@ -25,22 +59,42 @@ export function configuredWallet() {
25
59
  /**
26
60
  * The HTTP client every tool uses. With EVM_PRIVATE_KEY set, responses that
27
61
  * demand payment are paid automatically (x402) and retried; without it, the
28
- * server still starts — the free-tier tools work as-is and paid tools return
29
- * an explanation of what a call costs and how to fund a wallet, instead of
30
- * failing to boot for everyone who installed the plugin before funding one.
62
+ * server still starts — tools return an explanation of what a call costs and
63
+ * how to fund a wallet (and any FREE_TOOLS work as-is), instead of failing to
64
+ * boot for everyone who installed the plugin before funding one.
31
65
  */
32
66
  export async function createClient() {
33
67
  const key = process.env.EVM_PRIVATE_KEY?.trim();
34
68
  const plain = axios.create({ baseURL: BASE_URL });
35
69
  if (!key) {
36
- console.error("[netintel-mcp] No EVM_PRIVATE_KEY set — running wallet-less. Free-tier tools work " +
37
- `(${FREE_TOOLS.join(", ")}); paid tools will explain how to fund an agent wallet.`);
70
+ console.error("[netintel-mcp] No EVM_PRIVATE_KEY set — running wallet-less. " +
71
+ (FREE_TOOLS.length ? `Free-tier tools work (${FREE_TOOLS.join(", ")}); ` : "") +
72
+ "paid tools will explain how to fund an agent wallet.");
38
73
  return plain;
39
74
  }
40
75
  const signer = privateKeyToAccount(key);
41
76
  walletAddress = signer.address;
42
77
  const client = new x402Client();
43
78
  registerExactEvmScheme(client, { signer });
79
+ client.onBeforePaymentCreation(async (context) => {
80
+ const req = context?.selectedRequirements;
81
+ const atomic = Number(req?.amount);
82
+ const usd = atomic / 1_000_000;
83
+ if (!Number.isFinite(usd) || usd < 0) {
84
+ refusedPayments += 1;
85
+ return { abort: true, reason: `${SPEND_LIMIT}: the payment requirements carry no usable amount (got ${JSON.stringify(req?.amount)}); refusing to sign` };
86
+ }
87
+ if (usd > MAX_PER_CALL_USD) {
88
+ refusedPayments += 1;
89
+ return { abort: true, reason: `${SPEND_LIMIT}: this call costs ${usd} — above the per-call limit of ${MAX_PER_CALL_USD}. Ask the user; to allow it, raise NETINTEL_MAX_PER_CALL_USD (env or plugin config) and restart the server` };
90
+ }
91
+ if (sessionAuthorizedUsd + usd > MAX_SESSION_USD) {
92
+ refusedPayments += 1;
93
+ return { abort: true, reason: `${SPEND_LIMIT}: this call costs ${usd} and this session has already authorized ${sessionAuthorizedUsd.toFixed(3)} of its ${MAX_SESSION_USD} limit. Ask the user; to continue, raise NETINTEL_MAX_SESSION_USD (env or plugin config) and restart the server` };
94
+ }
95
+ sessionAuthorizedUsd += usd;
96
+ return undefined;
97
+ });
44
98
  return wrapAxiosWithPayment(plain, client);
45
99
  }
46
100
  /** USDC balance of the configured wallet on Base (keyless public RPC). */
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
4
  import { z } from "zod";
5
- import { createClient, configuredWallet, walletUsdcBalance, FREE_TOOLS } from "./client.js";
5
+ import { createClient, configuredWallet, walletUsdcBalance, spendStatus, FREE_TOOLS } from "./client.js";
6
6
  function ok(data) {
7
7
  return { content: [{ type: "text", text: JSON.stringify(data) }] };
8
8
  }
@@ -10,6 +10,12 @@ function err(e) {
10
10
  const ax = e;
11
11
  const status = ax.response?.status ?? "unknown";
12
12
  const msg = ax.message ?? String(e);
13
+ // A spending-limit refusal: the SDK aborted BEFORE signing, so no payment was
14
+ // made. Hand the agent the exact reason (which limit, how to raise it).
15
+ const limitAt = msg.indexOf("SPEND_LIMIT:");
16
+ if (limitAt >= 0) {
17
+ return { content: [{ type: "text", text: `Payment refused by your spending limit — nothing was paid. ${msg.slice(limitAt)}` }], isError: true };
18
+ }
13
19
  if (status === 402) {
14
20
  // The one error a user can act on: the call needs a payment that did not
15
21
  // happen. Say what it costs and exactly what to do, instead of "402".
@@ -17,7 +23,7 @@ function err(e) {
17
23
  const cost = price ? `This tool costs ${price} per call (USDC on Base). ` : "This tool is paid per call (USDC on Base). ";
18
24
  const fix = configuredWallet()
19
25
  ? `The agent wallet ${configuredWallet()} is configured but the payment did not settle — usually an empty wallet. Run netintel_wallet_status to check its USDC balance, then fund it on Base.`
20
- : `No agent wallet is configured, so it cannot be paid. Set EVM_PRIVATE_KEY to a wallet holding USDC on Base (or enter it in the Claude Code plugin config), then retry. Without a wallet these tools still work free, up to a quota: ${FREE_TOOLS.join(", ")}.`;
26
+ : `No agent wallet is configured, so it cannot be paid. Set EVM_PRIVATE_KEY to a wallet holding USDC on Base (or enter it in the Claude Code plugin config), then retry.${FREE_TOOLS.length ? ` Without a wallet these tools still work free, up to a quota: ${FREE_TOOLS.join(", ")}.` : ""}`;
21
27
  return { content: [{ type: "text", text: `Payment required. ${cost}${fix}` }], isError: true };
22
28
  }
23
29
  return {
@@ -1278,18 +1284,20 @@ function registerTools(server, api) {
1278
1284
  // server.tool() in there with the api.get/post path that follows it, and this
1279
1285
  // tool makes no API call.
1280
1286
  function registerWalletTool(server) {
1281
- server.tool("netintel_wallet_status", "Check the agent wallet this MCP server pays NetIntel with: whether a key is configured, its address, and its USDC balance on Base. Free and local (no NetIntel call). Use when a paid tool reports 'Payment required', before funding, or to confirm a top-up arrived. Also lists the tools that work with no wallet at all.", {}, async () => {
1287
+ server.tool("netintel_wallet_status", `Check the agent wallet this MCP server pays NetIntel with: whether a key is configured, its address, its USDC balance on Base, and the spending limits (per call and per session) with how much this session has authorized. Free and local (no NetIntel call). Use when a paid tool reports 'Payment required' or 'SPEND_LIMIT', before funding, or to confirm a top-up arrived.${FREE_TOOLS.length ? " Also lists the tools that work with no wallet at all." : ""}`, {}, async () => {
1282
1288
  const address = configuredWallet();
1283
- const free = { free_without_wallet: [...FREE_TOOLS], note: "Free tools are rate-limited per client (about 30/hour); over the quota they cost their normal price." };
1289
+ const free = FREE_TOOLS.length
1290
+ ? { free_without_wallet: [...FREE_TOOLS], note: "Free tools are rate-limited per client (about 30/hour); over the quota they cost their normal price." }
1291
+ : {};
1284
1292
  if (!address) {
1285
1293
  return ok({ wallet_configured: false, how_to_fund: "Set EVM_PRIVATE_KEY (or the plugin's wallet config) to a dedicated agent wallet, then send it a few dollars of USDC on Base mainnet — no ETH needed, settlement is gasless.", ...free });
1286
1294
  }
1287
1295
  try {
1288
1296
  const usdc = await walletUsdcBalance();
1289
- return ok({ wallet_configured: true, address, usdc_balance_base: usdc, funded: Number(usdc) > 0, top_up: Number(usdc) > 0 ? undefined : `Send USDC on Base to ${address}`, ...free });
1297
+ return ok({ wallet_configured: true, address, usdc_balance_base: usdc, funded: Number(usdc) > 0, top_up: Number(usdc) > 0 ? undefined : `Send USDC on Base to ${address}`, spending_limits: spendStatus(), ...free });
1290
1298
  }
1291
1299
  catch (e) {
1292
- return ok({ wallet_configured: true, address, usdc_balance_base: null, balance_error: String(e.message).slice(0, 160), ...free });
1300
+ return ok({ wallet_configured: true, address, usdc_balance_base: null, balance_error: String(e.message).slice(0, 160), spending_limits: spendStatus(), ...free });
1293
1301
  }
1294
1302
  });
1295
1303
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "netintel-mcp",
3
- "version": "1.1.54",
3
+ "version": "1.1.57",
4
4
  "mcpName": "io.github.kjgueye/netintel-mcp",
5
5
  "repository": {
6
6
  "type": "git",