rwagenthub-mcp 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.
Files changed (2) hide show
  1. package/index.js +9 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -33,6 +33,11 @@ async function callGateway(api, inputs) {
33
33
  headers: { "Content-Type": "application/json" },
34
34
  body: JSON.stringify({ api, inputs }),
35
35
  });
36
+ if (res.status === 402) {
37
+ const body = await res.json().catch(() => ({}));
38
+ const reason = body?.details ?? body?.error?.invalidReason ?? body?.error ?? "payment_failed";
39
+ throw new Error(`payment_failed:${reason}`);
40
+ }
36
41
  return res.json();
37
42
  }
38
43
 
@@ -93,13 +98,14 @@ async function main() {
93
98
  };
94
99
  } catch (err) {
95
100
  const msg = err.message ?? "";
96
- const isInsufficientFunds =
101
+ const isPaymentError =
102
+ msg.startsWith("payment_failed") ||
97
103
  msg.toLowerCase().includes("insufficient funds") ||
98
104
  msg.toLowerCase().includes("insufficient_funds") ||
99
105
  msg.toLowerCase().includes("failed to create payment payload");
100
- if (isInsufficientFunds) {
106
+ if (isPaymentError) {
101
107
  return {
102
- content: [{ type: "text", text: `Payment failed: insufficient USDC balance on Base.\nWallet: ${account.address}\n\nTop up your wallet with USDC on Base network and try again.` }],
108
+ content: [{ type: "text", text: `Payment failed: insufficient USDC balance on Base.\nWallet: ${account.address}\n\nTop up your wallet with USDC on Base and try again.` }],
103
109
  isError: true,
104
110
  };
105
111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rwagenthub-mcp",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "MCP server for AgentHub — 19 AI APIs (flights, weather, crypto, search, DeFi, code execution...) paid via x402 USDC on Base",
5
5
  "type": "module",
6
6
  "bin": {