@avidian/mcp-openapi 0.1.1 → 0.1.3
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 +23 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -277,7 +277,8 @@ function assignToolNames(drafts, reservedNames) {
|
|
|
277
277
|
let name = base;
|
|
278
278
|
let counter = 2;
|
|
279
279
|
while (used.has(name)) {
|
|
280
|
-
|
|
280
|
+
const suffix = `_${counter}`;
|
|
281
|
+
name = `${base.slice(0, 128 - suffix.length)}${suffix}`;
|
|
281
282
|
counter += 1;
|
|
282
283
|
}
|
|
283
284
|
used.add(name);
|
|
@@ -635,19 +636,26 @@ function base64ToBlob(base64) {
|
|
|
635
636
|
import { z } from "zod/v4";
|
|
636
637
|
import { convertJsonSchemaToZod } from "zod-from-json-schema";
|
|
637
638
|
function normalizeJsonSchema(schema) {
|
|
638
|
-
|
|
639
|
+
const seen = new WeakSet;
|
|
640
|
+
return normalizeNode(schema, seen);
|
|
639
641
|
}
|
|
640
|
-
function normalizeNode(node) {
|
|
642
|
+
function normalizeNode(node, seen) {
|
|
641
643
|
if (Array.isArray(node)) {
|
|
642
|
-
|
|
644
|
+
if (seen.has(node))
|
|
645
|
+
return node;
|
|
646
|
+
seen.add(node);
|
|
647
|
+
return node.map((item) => normalizeNode(item, seen));
|
|
643
648
|
}
|
|
644
649
|
if (node === null || typeof node !== "object") {
|
|
645
650
|
return node;
|
|
646
651
|
}
|
|
652
|
+
if (seen.has(node))
|
|
653
|
+
return node;
|
|
654
|
+
seen.add(node);
|
|
647
655
|
const source = node;
|
|
648
656
|
const normalized = {};
|
|
649
657
|
for (const [key, value] of Object.entries(source)) {
|
|
650
|
-
normalized[key] = normalizeNode(value);
|
|
658
|
+
normalized[key] = normalizeNode(value, seen);
|
|
651
659
|
}
|
|
652
660
|
const nullable = normalized.nullable === true || normalized["x-nullable"] === true;
|
|
653
661
|
delete normalized.nullable;
|
|
@@ -666,7 +674,16 @@ function normalizeNode(node) {
|
|
|
666
674
|
return normalized;
|
|
667
675
|
}
|
|
668
676
|
function toZodType(schema, options) {
|
|
669
|
-
|
|
677
|
+
let base;
|
|
678
|
+
if (!schema) {
|
|
679
|
+
base = z.unknown();
|
|
680
|
+
} else {
|
|
681
|
+
try {
|
|
682
|
+
base = convertJsonSchemaToZod(normalizeJsonSchema(schema));
|
|
683
|
+
} catch {
|
|
684
|
+
base = z.unknown();
|
|
685
|
+
}
|
|
686
|
+
}
|
|
670
687
|
const described = options.description !== undefined ? base.describe(options.description) : base;
|
|
671
688
|
return options.required ? described : described.optional();
|
|
672
689
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avidian/mcp-openapi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "MCP server for OpenAPI/Swagger — gives AI agents the ability to discover, search, and call any REST API described by an OpenAPI document.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|