rwagenthub-mcp 1.0.4 → 1.0.6

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 +14 -19
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -35,28 +35,29 @@ async function callGateway(api, inputs) {
35
35
  });
36
36
  if (res.status === 402) {
37
37
  const body = await res.json().catch(() => ({}));
38
- const reason = body?.error?.invalidReason ?? body?.error ?? "payment_failed";
38
+ const reason = body?.details ?? body?.error?.invalidReason ?? body?.error ?? "payment_failed";
39
39
  throw new Error(`payment_failed:${reason}`);
40
40
  }
41
41
  return res.json();
42
42
  }
43
43
 
44
- // ── Type mapper: gateway field types → Zod ────────────────────────────────────
45
- function toZod(field) {
44
+ // ── Type mapper: JSON Schema property → Zod ───────────────────────────────────
45
+ function toZod(propName, prop, requiredList) {
46
46
  let schema;
47
- if (field.type === "number") {
47
+ if (prop.type === "number") {
48
48
  schema = z.number();
49
- } else if (field.type === "boolean") {
49
+ } else if (prop.type === "boolean") {
50
50
  schema = z.boolean();
51
- } else if (field.type === "string|string[]") {
51
+ } else if (prop.oneOf) {
52
52
  schema = z.union([z.string(), z.array(z.string())]);
53
53
  } else {
54
54
  schema = z.string();
55
55
  }
56
56
 
57
- if (field.description) schema = schema.describe(field.description);
58
- if (!field.required) schema = schema.optional();
59
- if (field.default !== undefined) schema = schema.default(field.default);
57
+ if (prop.description) schema = schema.describe(prop.description);
58
+ const isRequired = requiredList?.includes(propName);
59
+ if (!isRequired) schema = schema.optional();
60
+ if (prop.default !== undefined) schema = schema.default(prop.default);
60
61
  return schema;
61
62
  }
62
63
 
@@ -73,9 +74,10 @@ async function main() {
73
74
  const server = new McpServer({ name: "agenthub", version: "1.0.0" });
74
75
 
75
76
  for (const api of apis) {
77
+ const { properties = {}, required: requiredList = [] } = api.inputSchema ?? {};
76
78
  const zodShape = {};
77
- for (const [fieldName, field] of Object.entries(api.inputs)) {
78
- zodShape[fieldName] = toZod(field);
79
+ for (const [fieldName, prop] of Object.entries(properties)) {
80
+ zodShape[fieldName] = toZod(fieldName, prop, requiredList);
79
81
  }
80
82
 
81
83
  server.tool(
@@ -104,15 +106,8 @@ async function main() {
104
106
  msg.toLowerCase().includes("insufficient_funds") ||
105
107
  msg.toLowerCase().includes("failed to create payment payload");
106
108
  if (isPaymentError) {
107
- const isNoFunds =
108
- msg.includes("insufficient_funds") ||
109
- msg.toLowerCase().includes("insufficient funds") ||
110
- msg.toLowerCase().includes("failed to create payment payload");
111
- const detail = isNoFunds
112
- ? `Insufficient USDC balance on Base.\nWallet: ${account.address}\n\nTop up your wallet with USDC on Base and try again.`
113
- : `Payment rejected by gateway (${msg.replace("payment_failed:", "")}).\nWallet: ${account.address}`;
114
109
  return {
115
- content: [{ type: "text", text: `Payment failed: ${detail}` }],
110
+ 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.` }],
116
111
  isError: true,
117
112
  };
118
113
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rwagenthub-mcp",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
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": {