skedyul 0.1.6 → 0.1.8
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 +79 -31
- package/dist/types.d.ts +9 -4
- package/package.json +2 -2
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
|
|
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,34 +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
|
-
let schemaIdCounter = 0;
|
|
24
53
|
function toJsonSchema(schema) {
|
|
25
54
|
if (!schema)
|
|
26
55
|
return undefined;
|
|
27
56
|
try {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
'$ref' in json &&
|
|
33
|
-
typeof json.$ref === 'string' &&
|
|
34
|
-
json.$ref.startsWith('#/definitions/')) {
|
|
35
|
-
const defName = json.$ref.split('/').pop();
|
|
36
|
-
const definitions = json.definitions;
|
|
37
|
-
if (defName && definitions && definitions[defName]) {
|
|
38
|
-
return definitions[defName];
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return json;
|
|
57
|
+
return (0, zod_json_schema_compat_js_1.toJsonSchemaCompat)(schema, {
|
|
58
|
+
target: 'jsonSchema7',
|
|
59
|
+
pipeStrategy: 'input',
|
|
60
|
+
});
|
|
42
61
|
}
|
|
43
62
|
catch {
|
|
44
63
|
return undefined;
|
|
45
64
|
}
|
|
46
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
|
+
}
|
|
47
92
|
function parseJsonRecord(value) {
|
|
48
93
|
if (!value) {
|
|
49
94
|
return {};
|
|
@@ -213,8 +258,8 @@ function buildToolMetadata(registry) {
|
|
|
213
258
|
return Object.values(registry).map((tool) => ({
|
|
214
259
|
name: tool.name,
|
|
215
260
|
description: tool.description,
|
|
216
|
-
inputSchema:
|
|
217
|
-
outputSchema:
|
|
261
|
+
inputSchema: getJsonSchemaFromToolSchema(tool.inputs),
|
|
262
|
+
outputSchema: getJsonSchemaFromToolSchema(tool.outputSchema),
|
|
218
263
|
}));
|
|
219
264
|
}
|
|
220
265
|
function createRequestState(maxRequests, ttlExtendSeconds, runtimeLabel, toolNames) {
|
|
@@ -378,17 +423,17 @@ function createSkedyulServer(config, registry) {
|
|
|
378
423
|
for (const [toolKey, tool] of Object.entries(registry)) {
|
|
379
424
|
// Use the tool's name or fall back to the registry key
|
|
380
425
|
const toolName = tool.name || toolKey;
|
|
426
|
+
const inputZodSchema = getZodSchema(tool.inputs);
|
|
427
|
+
const outputZodSchema = getZodSchema(tool.outputSchema);
|
|
381
428
|
mcpServer.registerTool(toolName, {
|
|
382
429
|
title: toolName,
|
|
383
430
|
description: tool.description,
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
inputSchema: tool.inputs,
|
|
387
|
-
outputSchema: tool.outputSchema,
|
|
431
|
+
inputSchema: inputZodSchema,
|
|
432
|
+
outputSchema: outputZodSchema,
|
|
388
433
|
}, async (args) => {
|
|
389
|
-
|
|
434
|
+
const validatedArgs = inputZodSchema ? inputZodSchema.parse(args) : args;
|
|
390
435
|
const result = await callTool(toolKey, {
|
|
391
|
-
inputs:
|
|
436
|
+
inputs: validatedArgs,
|
|
392
437
|
});
|
|
393
438
|
return {
|
|
394
439
|
content: result.content,
|
|
@@ -652,8 +697,9 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer, reg
|
|
|
652
697
|
},
|
|
653
698
|
}, headers);
|
|
654
699
|
}
|
|
700
|
+
const inputSchema = getZodSchema(tool.inputs);
|
|
655
701
|
// Validate arguments against Zod schema
|
|
656
|
-
const validatedArgs =
|
|
702
|
+
const validatedArgs = inputSchema ? inputSchema.parse(toolArgs) : toolArgs;
|
|
657
703
|
const estimateResponse = await callTool(toolKey, {
|
|
658
704
|
inputs: validatedArgs,
|
|
659
705
|
estimate: true,
|
|
@@ -728,9 +774,11 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer, reg
|
|
|
728
774
|
},
|
|
729
775
|
}, headers);
|
|
730
776
|
}
|
|
731
|
-
// Validate arguments against Zod schema
|
|
732
777
|
try {
|
|
733
|
-
const
|
|
778
|
+
const inputSchema = getZodSchema(tool.inputs);
|
|
779
|
+
const validatedArgs = inputSchema
|
|
780
|
+
? inputSchema.parse(toolArgs)
|
|
781
|
+
: toolArgs;
|
|
734
782
|
result = await callTool(toolKey, {
|
|
735
783
|
inputs: validatedArgs,
|
|
736
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:
|
|
35
|
+
inputs: ToolSchema;
|
|
31
36
|
handler: unknown;
|
|
32
|
-
outputSchema?:
|
|
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.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "The Skedyul SDK for Node.js",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"author": "Skedyul <support@skedyul.com>",
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
26
|
+
"@modelcontextprotocol/sdk": "^1.23.0",
|
|
27
27
|
"zod": "^4.0.0",
|
|
28
28
|
"zod-to-json-schema": "^3.23.0"
|
|
29
29
|
},
|