rwagenthub-mcp 1.0.5 → 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 +12 -10
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -41,22 +41,23 @@ async function callGateway(api, inputs) {
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(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rwagenthub-mcp",
3
- "version": "1.0.5",
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": {