skedyul 0.1.5 → 0.1.7

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/server.js CHANGED
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
@@ -8,7 +41,8 @@ exports.createSkedyulServer = createSkedyulServer;
8
41
  const http_1 = __importDefault(require("http"));
9
42
  const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
10
43
  const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
11
- const zod_to_json_schema_1 = require("zod-to-json-schema");
44
+ const z = __importStar(require("zod"));
45
+ const zod_json_schema_compat_js_1 = require("@modelcontextprotocol/sdk/server/zod-json-schema-compat.js");
12
46
  const service_1 = require("./core/service");
13
47
  function normalizeBilling(billing) {
14
48
  if (!billing || typeof billing.credits !== 'number') {
@@ -16,23 +50,45 @@ function normalizeBilling(billing) {
16
50
  }
17
51
  return billing;
18
52
  }
19
- // Loosely-typed wrapper around zod-to-json-schema to avoid version/type
20
- // mismatches between the zod dependency used here and the one used by the
21
- // library. At runtime the schemas are compatible.
22
- const zodToJsonSchemaLoose = zod_to_json_schema_1.zodToJsonSchema;
23
53
  function toJsonSchema(schema) {
24
54
  if (!schema)
25
55
  return undefined;
26
56
  try {
27
- return zodToJsonSchemaLoose(schema, {
57
+ return (0, zod_json_schema_compat_js_1.toJsonSchemaCompat)(schema, {
28
58
  target: 'jsonSchema7',
29
- $refStrategy: 'none',
59
+ pipeStrategy: 'input',
30
60
  });
31
61
  }
32
62
  catch {
33
63
  return undefined;
34
64
  }
35
65
  }
66
+ function isToolSchemaWithJson(schema) {
67
+ return Boolean(schema &&
68
+ typeof schema === 'object' &&
69
+ 'zod' in schema &&
70
+ schema.zod instanceof z.ZodType);
71
+ }
72
+ function getZodSchema(schema) {
73
+ if (!schema)
74
+ return undefined;
75
+ if (schema instanceof z.ZodType) {
76
+ return schema;
77
+ }
78
+ if (isToolSchemaWithJson(schema)) {
79
+ return schema.zod;
80
+ }
81
+ return undefined;
82
+ }
83
+ function getJsonSchemaFromToolSchema(schema) {
84
+ if (!schema)
85
+ return undefined;
86
+ if (isToolSchemaWithJson(schema) && schema.jsonSchema) {
87
+ return schema.jsonSchema;
88
+ }
89
+ const zodSchema = getZodSchema(schema);
90
+ return toJsonSchema(zodSchema);
91
+ }
36
92
  function parseJsonRecord(value) {
37
93
  if (!value) {
38
94
  return {};
@@ -202,8 +258,8 @@ function buildToolMetadata(registry) {
202
258
  return Object.values(registry).map((tool) => ({
203
259
  name: tool.name,
204
260
  description: tool.description,
205
- inputSchema: toJsonSchema(tool.inputs),
206
- outputSchema: toJsonSchema(tool.outputSchema),
261
+ inputSchema: getJsonSchemaFromToolSchema(tool.inputs),
262
+ outputSchema: getJsonSchemaFromToolSchema(tool.outputSchema),
207
263
  }));
208
264
  }
209
265
  function createRequestState(maxRequests, ttlExtendSeconds, runtimeLabel, toolNames) {
@@ -367,17 +423,17 @@ function createSkedyulServer(config, registry) {
367
423
  for (const [toolKey, tool] of Object.entries(registry)) {
368
424
  // Use the tool's name or fall back to the registry key
369
425
  const toolName = tool.name || toolKey;
426
+ const inputZodSchema = getZodSchema(tool.inputs);
427
+ const outputZodSchema = getZodSchema(tool.outputSchema);
370
428
  mcpServer.registerTool(toolName, {
371
429
  title: toolName,
372
430
  description: tool.description,
373
- // The MCP SDK expects Zod schemas here; it will handle JSON Schema
374
- // conversion for tools/list responses.
375
- inputSchema: tool.inputs,
376
- outputSchema: tool.outputSchema,
431
+ inputSchema: inputZodSchema,
432
+ outputSchema: outputZodSchema,
377
433
  }, async (args) => {
378
- // Args will be the parsed Zod schema values directly
434
+ const validatedArgs = inputZodSchema ? inputZodSchema.parse(args) : args;
379
435
  const result = await callTool(toolKey, {
380
- inputs: args,
436
+ inputs: validatedArgs,
381
437
  });
382
438
  return {
383
439
  content: result.content,
@@ -641,8 +697,9 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer, reg
641
697
  },
642
698
  }, headers);
643
699
  }
700
+ const inputSchema = getZodSchema(tool.inputs);
644
701
  // Validate arguments against Zod schema
645
- const validatedArgs = tool.inputs.parse(toolArgs);
702
+ const validatedArgs = inputSchema ? inputSchema.parse(toolArgs) : toolArgs;
646
703
  const estimateResponse = await callTool(toolKey, {
647
704
  inputs: validatedArgs,
648
705
  estimate: true,
@@ -717,9 +774,11 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer, reg
717
774
  },
718
775
  }, headers);
719
776
  }
720
- // Validate arguments against Zod schema
721
777
  try {
722
- const validatedArgs = tool.inputs.parse(toolArgs);
778
+ const inputSchema = getZodSchema(tool.inputs);
779
+ const validatedArgs = inputSchema
780
+ ? inputSchema.parse(toolArgs)
781
+ : toolArgs;
723
782
  result = await callTool(toolKey, {
724
783
  inputs: validatedArgs,
725
784
  });
package/dist/types.d.ts CHANGED
@@ -15,21 +15,26 @@ export interface ToolExecutionResult<Output = unknown> {
15
15
  output: Output;
16
16
  billing: BillingInfo;
17
17
  }
18
+ export interface ToolSchemaWithJson<Schema extends z.ZodTypeAny = z.ZodTypeAny> {
19
+ zod: Schema;
20
+ jsonSchema?: Record<string, unknown>;
21
+ }
22
+ export type ToolSchema<Schema extends z.ZodTypeAny = z.ZodTypeAny> = Schema | ToolSchemaWithJson<Schema>;
18
23
  export type ToolHandler<Input, Output> = (params: ToolParams<Input, Output>) => Promise<ToolExecutionResult<Output>> | ToolExecutionResult<Output>;
19
24
  export interface ToolDefinition<Input = unknown, Output = unknown, InputSchema extends z.ZodTypeAny = z.ZodType<Input>, OutputSchema extends z.ZodTypeAny = z.ZodType<Output>> {
20
25
  name: string;
21
26
  description: string;
22
- inputs: InputSchema;
27
+ inputs: ToolSchema<InputSchema>;
23
28
  handler: ToolHandler<Input, Output>;
24
- outputSchema?: OutputSchema;
29
+ outputSchema?: ToolSchema<OutputSchema>;
25
30
  [key: string]: unknown;
26
31
  }
27
32
  export interface ToolRegistryEntry {
28
33
  name: string;
29
34
  description: string;
30
- inputs: z.ZodTypeAny;
35
+ inputs: ToolSchema;
31
36
  handler: unknown;
32
- outputSchema?: z.ZodTypeAny;
37
+ outputSchema?: ToolSchema;
33
38
  [key: string]: unknown;
34
39
  }
35
40
  export type ToolRegistry = Record<string, ToolRegistryEntry>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skedyul",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "The Skedyul SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",