@mcp-b/global 0.0.0-beta-20260116035619 → 0.0.0

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/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import { IframeChildTransport, TabServerTransport } from "@mcp-b/transports";
2
2
  import { CallToolRequestSchema, GetPromptRequestSchema, ListPromptsRequestSchema, ListResourcesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema, Server } from "@mcp-b/webmcp-ts-sdk";
3
- import { z } from "zod/v4";
3
+ import { jsonSchemaToZod } from "@composio/json-schema-to-zod";
4
+ import { z } from "zod";
5
+ import { zodToJsonSchema as zodToJsonSchema$1 } from "zod-to-json-schema";
4
6
 
5
7
  //#region src/logger.ts
6
8
  /**
@@ -88,24 +90,22 @@ function createLogger(namespace) {
88
90
  const logger$2 = createLogger("WebModelContext");
89
91
  /**
90
92
  * Detect if a schema is a Zod schema object (Record<string, ZodType>)
91
- * or a JSON Schema object.
92
- *
93
- * Uses duck-typing to detect Zod 4 schemas by checking for the `_zod` property.
93
+ * or a JSON Schema object
94
94
  */
95
95
  function isZodSchema(schema) {
96
96
  if (typeof schema !== "object" || schema === null) return false;
97
97
  if ("type" in schema && typeof schema.type === "string") return false;
98
98
  const values = Object.values(schema);
99
99
  if (values.length === 0) return false;
100
- return values.some((val) => val != null && typeof val === "object" && "_zod" in val);
100
+ return values.some((val) => val instanceof z.ZodType);
101
101
  }
102
102
  /**
103
103
  * Convert JSON Schema to Zod validator
104
- * Uses Zod 4's native z.fromJSONSchema() for conversion
104
+ * Uses @composio/json-schema-to-zod for conversion
105
105
  */
106
- function jsonSchemaToZod(jsonSchema) {
106
+ function jsonSchemaToZod$1(jsonSchema) {
107
107
  try {
108
- return z.fromJSONSchema(jsonSchema);
108
+ return jsonSchemaToZod(jsonSchema);
109
109
  } catch (error) {
110
110
  logger$2.warn("Failed to convert JSON Schema to Zod:", error);
111
111
  return z.object({}).passthrough();
@@ -113,14 +113,16 @@ function jsonSchemaToZod(jsonSchema) {
113
113
  }
114
114
  /**
115
115
  * Convert Zod schema object to JSON Schema
116
- * Uses Zod 4's native z.toJSONSchema() for conversion
116
+ * Uses zod-to-json-schema package for comprehensive conversion
117
117
  *
118
118
  * @param schema - Record of Zod type definitions (e.g., { name: z.string(), age: z.number() })
119
119
  * @returns JSON Schema object compatible with MCP InputSchema
120
120
  */
121
121
  function zodToJsonSchema(schema) {
122
- const zodObject = z.object(schema);
123
- const { $schema: _,...rest } = z.toJSONSchema(zodObject);
122
+ const { $schema: _,...rest } = zodToJsonSchema$1(z.object(schema), {
123
+ $refStrategy: "none",
124
+ target: "jsonSchema7"
125
+ });
124
126
  return rest;
125
127
  }
126
128
  /**
@@ -135,7 +137,7 @@ function normalizeSchema(schema) {
135
137
  const jsonSchema = schema;
136
138
  return {
137
139
  jsonSchema,
138
- zodValidator: jsonSchemaToZod(jsonSchema)
140
+ zodValidator: jsonSchemaToZod$1(jsonSchema)
139
141
  };
140
142
  }
141
143
  /**
@@ -145,7 +147,7 @@ function validateWithZod(data, validator) {
145
147
  const result = validator.safeParse(data);
146
148
  if (!result.success) return {
147
149
  success: false,
148
- error: `Validation failed:\n${result.error.issues.map((err) => ` - ${err.path.join(".") || "root"}: ${err.message}`).join("\n")}`
150
+ error: `Validation failed:\n${result.error.errors.map((err) => ` - ${err.path.join(".") || "root"}: ${err.message}`).join("\n")}`
149
151
  };
150
152
  return {
151
153
  success: true,
@@ -254,7 +256,7 @@ var NativeModelContextAdapter = class {
254
256
  const result = await this.nativeTesting.executeTool(toolInfo.name, JSON.stringify(args));
255
257
  return this.convertToToolResponse(result);
256
258
  },
257
- inputValidator: jsonSchemaToZod(inputSchema)
259
+ inputValidator: jsonSchemaToZod$1(inputSchema)
258
260
  };
259
261
  this.bridge.tools.set(toolInfo.name, validatedTool);
260
262
  } catch (error) {