@mcp-b/global 1.1.3-beta.0 → 1.1.3-beta.2

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
@@ -2,6 +2,7 @@ import { IframeChildTransport, TabServerTransport } from "@mcp-b/transports";
2
2
  import { CallToolRequestSchema, GetPromptRequestSchema, ListPromptsRequestSchema, ListResourcesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema, Server } from "@mcp-b/webmcp-ts-sdk";
3
3
  import { jsonSchemaToZod } from "@composio/json-schema-to-zod";
4
4
  import { z } from "zod";
5
+ import { zodToJsonSchema as zodToJsonSchema$1 } from "zod-to-json-schema";
5
6
 
6
7
  //#region src/validation.ts
7
8
  /**
@@ -29,44 +30,17 @@ function jsonSchemaToZod$1(jsonSchema) {
29
30
  }
30
31
  /**
31
32
  * Convert Zod schema object to JSON Schema
32
- * Based on react-webmcp implementation
33
+ * Uses zod-to-json-schema package for comprehensive conversion
34
+ *
35
+ * @param schema - Record of Zod type definitions (e.g., { name: z.string(), age: z.number() })
36
+ * @returns JSON Schema object compatible with MCP InputSchema
33
37
  */
34
38
  function zodToJsonSchema(schema) {
35
- const properties = {};
36
- const required = [];
37
- for (const [key, zodType] of Object.entries(schema)) {
38
- const description = zodType.description || void 0;
39
- let type = "string";
40
- let enumValues;
41
- let items;
42
- if (zodType instanceof z.ZodString) type = "string";
43
- else if (zodType instanceof z.ZodNumber) type = "number";
44
- else if (zodType instanceof z.ZodBoolean) type = "boolean";
45
- else if (zodType instanceof z.ZodArray) {
46
- type = "array";
47
- const elementType = zodType.element;
48
- if (elementType instanceof z.ZodString) items = { type: "string" };
49
- else if (elementType instanceof z.ZodNumber) items = { type: "number" };
50
- else if (elementType instanceof z.ZodBoolean) items = { type: "boolean" };
51
- else items = { type: "string" };
52
- } else if (zodType instanceof z.ZodObject) type = "object";
53
- else if (zodType instanceof z.ZodEnum) {
54
- type = "string";
55
- const enumDef = zodType._def;
56
- if (enumDef?.values) enumValues = enumDef.values;
57
- }
58
- const propertySchema = { type };
59
- if (description) propertySchema.description = description;
60
- if (enumValues) propertySchema.enum = enumValues;
61
- if (items) propertySchema.items = items;
62
- properties[key] = propertySchema;
63
- if (!zodType.isOptional()) required.push(key);
64
- }
65
- return {
66
- type: "object",
67
- properties,
68
- ...required.length > 0 && { required }
69
- };
39
+ const { $schema: _,...rest } = zodToJsonSchema$1(z.object(schema), {
40
+ $refStrategy: "none",
41
+ target: "jsonSchema7"
42
+ });
43
+ return rest;
70
44
  }
71
45
  /**
72
46
  * Normalize a schema to both JSON Schema and Zod formats
@@ -1755,5 +1729,5 @@ if (typeof window !== "undefined" && typeof document !== "undefined") {
1755
1729
  }
1756
1730
 
1757
1731
  //#endregion
1758
- export { cleanupWebModelContext, initializeWebModelContext };
1732
+ export { cleanupWebModelContext, initializeWebModelContext, zodToJsonSchema };
1759
1733
  //# sourceMappingURL=index.js.map