fastmcp 4.28.4 → 4.29.1
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/README.md +21 -0
- package/dist/FastMCP.cjs +4 -4
- package/dist/FastMCP.d.cts +4 -2
- package/dist/FastMCP.d.ts +4 -2
- package/dist/FastMCP.js +3 -3
- package/dist/auth/index.cjs +2 -2
- package/dist/auth/index.js +1 -1
- package/dist/{chunk-DPJW5QEO.cjs → chunk-5EEESM57.cjs} +64 -92
- package/dist/chunk-5EEESM57.cjs.map +1 -0
- package/dist/{chunk-OCCYKYIM.cjs → chunk-FBDPX4H2.cjs} +30 -3
- package/dist/chunk-FBDPX4H2.cjs.map +1 -0
- package/dist/{chunk-B2QUCZGV.js → chunk-JCKJRUCE.js} +30 -3
- package/dist/chunk-JCKJRUCE.js.map +1 -0
- package/dist/{chunk-UFPH23EN.js → chunk-RWPENEKV.js} +5 -1
- package/dist/{chunk-UFPH23EN.js.map → chunk-RWPENEKV.js.map} +1 -1
- package/dist/{chunk-7IQ5QHVZ.cjs → chunk-UHJQUSUX.cjs} +5 -1
- package/dist/chunk-UHJQUSUX.cjs.map +1 -0
- package/dist/{chunk-Q57EM4LH.js → chunk-VN5SZ6IE.js} +31 -59
- package/dist/chunk-VN5SZ6IE.js.map +1 -0
- package/dist/edge/index.cjs +15 -4
- package/dist/edge/index.cjs.map +1 -1
- package/dist/edge/index.d.cts +4 -0
- package/dist/edge/index.d.ts +4 -0
- package/dist/edge/index.js +13 -2
- package/dist/edge/index.js.map +1 -1
- package/dist/examples/custom-routes.cjs +4 -4
- package/dist/examples/custom-routes.js +3 -3
- package/dist/openapi/index.cjs +160 -135
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.d.cts +10 -0
- package/dist/openapi/index.d.ts +10 -0
- package/dist/openapi/index.js +151 -126
- package/dist/openapi/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-7IQ5QHVZ.cjs.map +0 -1
- package/dist/chunk-B2QUCZGV.js.map +0 -1
- package/dist/chunk-DPJW5QEO.cjs.map +0 -1
- package/dist/chunk-OCCYKYIM.cjs.map +0 -1
- package/dist/chunk-Q57EM4LH.js.map +0 -1
package/dist/openapi/index.cjs
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
require('../chunk-
|
|
7
|
-
require('../chunk-
|
|
5
|
+
var _chunk5EEESM57cjs = require('../chunk-5EEESM57.cjs');
|
|
6
|
+
require('../chunk-UHJQUSUX.cjs');
|
|
7
|
+
require('../chunk-FBDPX4H2.cjs');
|
|
8
8
|
|
|
9
9
|
// src/openapi/loadSpec.ts
|
|
10
10
|
var _swaggerparser = require('@apidevtools/swagger-parser'); var _swaggerparser2 = _interopRequireDefault(_swaggerparser);
|
|
@@ -65,11 +65,11 @@ function buildFlatSchema(route, sharedDefs) {
|
|
|
65
65
|
for (const param of occurrences) {
|
|
66
66
|
const base = collides ? `${name}__${param.in}` : name;
|
|
67
67
|
const key = collides ? allocateAlias(base) : name;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
);
|
|
68
|
+
const input = parameterInput(param);
|
|
69
|
+
properties[key] = rewriteComponentRefs(input.schema);
|
|
71
70
|
parameterMap[key] = {
|
|
72
71
|
allowReserved: param.allowReserved,
|
|
72
|
+
...input.encoding ? { encoding: input.encoding } : {},
|
|
73
73
|
explode: param.explode,
|
|
74
74
|
in: param.in,
|
|
75
75
|
name,
|
|
@@ -220,7 +220,8 @@ function extractBodyProperties(requestBody, sharedDefs) {
|
|
|
220
220
|
}
|
|
221
221
|
const schema = bodyEncoding === "form" ? resolveComponentRef(declaredSchema, sharedDefs) : declaredSchema;
|
|
222
222
|
const schemaProperties = schema.properties;
|
|
223
|
-
|
|
223
|
+
const composedJsonBody = bodyEncoding === "json" && ["allOf", "anyOf", "oneOf"].some((key) => Array.isArray(schema[key]));
|
|
224
|
+
if (!composedJsonBody && schema.type === "object" && schemaProperties && (bodyEncoding === "form" || schema.additionalProperties === false || Object.keys(schemaProperties).length > 0)) {
|
|
224
225
|
const requiredNames = new Set(
|
|
225
226
|
_nullishCoalesce(schema.required, () => ( []))
|
|
226
227
|
);
|
|
@@ -351,6 +352,13 @@ function omitReadOnlyRequired(value, mode) {
|
|
|
351
352
|
}
|
|
352
353
|
return node;
|
|
353
354
|
}
|
|
355
|
+
function parameterInput(param) {
|
|
356
|
+
const json = param.schema === void 0 ? findMediaType(param.content, "application/json") : void 0;
|
|
357
|
+
if (!json) {
|
|
358
|
+
return { schema: _nullishCoalesce(param.schema, () => ( { type: "string" })) };
|
|
359
|
+
}
|
|
360
|
+
return { encoding: "json", schema: _nullishCoalesce(json.schema, () => ( {})) };
|
|
361
|
+
}
|
|
354
362
|
function rewriteNode(value, mode, stripExamples = false) {
|
|
355
363
|
if (mode === "data") {
|
|
356
364
|
return value;
|
|
@@ -517,115 +525,30 @@ function slugify(value) {
|
|
|
517
525
|
|
|
518
526
|
// src/openapi/requestBuilder.ts
|
|
519
527
|
async function executeRequest(options) {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
);
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
const bodyProps = /* @__PURE__ */ Object.create(null);
|
|
531
|
-
for (const [key, value] of Object.entries(options.args)) {
|
|
532
|
-
const mapping = options.parameterMap[key];
|
|
533
|
-
if (!mapping || value === void 0) {
|
|
534
|
-
continue;
|
|
535
|
-
}
|
|
536
|
-
if (value === null && (mapping.in === "query" || mapping.in === "header" || mapping.in === "cookie")) {
|
|
537
|
-
continue;
|
|
538
|
-
}
|
|
539
|
-
switch (mapping.in) {
|
|
540
|
-
case "body":
|
|
541
|
-
bodyProps[mapping.name] = value;
|
|
542
|
-
break;
|
|
543
|
-
case "cookie": {
|
|
544
|
-
const pair = `${mapping.name}=${encodeCookieValue(mapping, value)}`;
|
|
545
|
-
const existing = headers.get("cookie");
|
|
546
|
-
headers.set("cookie", existing ? `${existing}; ${pair}` : pair);
|
|
547
|
-
break;
|
|
548
|
-
}
|
|
549
|
-
case "header":
|
|
550
|
-
headers.set(
|
|
551
|
-
mapping.name,
|
|
552
|
-
serializeHeaderValue(value, mapping.style, mapping.explode)
|
|
553
|
-
);
|
|
554
|
-
break;
|
|
555
|
-
case "path":
|
|
556
|
-
pathParams[mapping.name] = encodePathValue(
|
|
557
|
-
value,
|
|
558
|
-
mapping.style,
|
|
559
|
-
mapping.explode
|
|
560
|
-
);
|
|
561
|
-
break;
|
|
562
|
-
case "query": {
|
|
563
|
-
const query = new URLSearchParams();
|
|
564
|
-
appendQueryValue(
|
|
565
|
-
query,
|
|
566
|
-
mapping.name,
|
|
567
|
-
mapping.style,
|
|
568
|
-
value,
|
|
569
|
-
mapping.explode
|
|
570
|
-
);
|
|
571
|
-
if (query.size > 0) {
|
|
572
|
-
queryParts.push(serializeQuery(query, mapping.allowReserved));
|
|
573
|
-
}
|
|
574
|
-
break;
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
let path = options.route.path;
|
|
579
|
-
for (const [name, value] of Object.entries(pathParams)) {
|
|
580
|
-
path = path.replaceAll(`{${name}}`, value);
|
|
581
|
-
}
|
|
582
|
-
assertNoSubstitutedDotSegments(options.route, path);
|
|
583
|
-
const url = new URL(baseUrl.replace(/\/$/, "") + path);
|
|
584
|
-
url.search = queryParts.join("&");
|
|
585
|
-
let body;
|
|
586
|
-
const requiredJsonBody = options.bodyEncoding === "json" && _optionalChain([options, 'access', _19 => _19.route, 'access', _20 => _20.requestBody, 'optionalAccess', _21 => _21.required]) === true && !options.wholeBodyKey;
|
|
587
|
-
if (Object.keys(bodyProps).length > 0 || requiredJsonBody) {
|
|
588
|
-
const payload = options.wholeBodyKey ? bodyProps[options.wholeBodyKey] : bodyProps;
|
|
589
|
-
if (options.bodyEncoding === "form") {
|
|
590
|
-
if (!headers.has("content-type")) {
|
|
591
|
-
headers.set("content-type", "application/x-www-form-urlencoded");
|
|
592
|
-
}
|
|
593
|
-
body = encodeFormBody(payload);
|
|
594
|
-
} else {
|
|
595
|
-
if (!headers.has("content-type")) {
|
|
596
|
-
headers.set("content-type", "application/json");
|
|
597
|
-
}
|
|
598
|
-
body = JSON.stringify(payload);
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
const response = await options.fetchImpl(url.toString(), {
|
|
602
|
-
body,
|
|
603
|
-
headers,
|
|
604
|
-
method: options.route.method.toUpperCase(),
|
|
605
|
-
signal: options.signal
|
|
606
|
-
});
|
|
607
|
-
const text = await response.text();
|
|
608
|
-
if (!response.ok) {
|
|
609
|
-
throw new (0, _chunkDPJW5QEOcjs.UserError)(
|
|
610
|
-
`${options.route.method.toUpperCase()} ${path} failed with ${response.status}: ${text.slice(0, 2e3)}`
|
|
611
|
-
);
|
|
528
|
+
return readTextResponse(await fetchResponse(options));
|
|
529
|
+
}
|
|
530
|
+
async function executeResourceRequest(options) {
|
|
531
|
+
const response = await fetchResponse(options);
|
|
532
|
+
const mimeType = _optionalChain([response, 'access', _19 => _19.headers, 'access', _20 => _20.get, 'call', _21 => _21("content-type"), 'optionalAccess', _22 => _22.split, 'call', _23 => _23(";"), 'access', _24 => _24[0], 'access', _25 => _25.trim, 'call', _26 => _26(), 'access', _27 => _27.toLowerCase, 'call', _28 => _28()]);
|
|
533
|
+
if (mimeType && !mimeType.startsWith("text/") && !mimeType.includes("json") && !/(?:\/|\+)(?:x-)?(?:xml|yaml|javascript|ecmascript)$/.test(mimeType) && mimeType !== "application/x-www-form-urlencoded") {
|
|
534
|
+
return {
|
|
535
|
+
blob: Buffer.from(await response.arrayBuffer()).toString("base64"),
|
|
536
|
+
mimeType
|
|
537
|
+
};
|
|
612
538
|
}
|
|
613
|
-
const
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
return { text };
|
|
620
|
-
}
|
|
539
|
+
const { text } = await readTextResponse(response);
|
|
540
|
+
try {
|
|
541
|
+
JSON.parse(text);
|
|
542
|
+
return { mimeType: "application/json", text };
|
|
543
|
+
} catch (e2) {
|
|
544
|
+
return { mimeType: "text/plain", text };
|
|
621
545
|
}
|
|
622
|
-
return { text };
|
|
623
546
|
}
|
|
624
547
|
function resolveBaseUrl(servers, origin, overrideUrl) {
|
|
625
548
|
if (overrideUrl) {
|
|
626
549
|
return overrideUrl.replace(/\/$/, "");
|
|
627
550
|
}
|
|
628
|
-
const server = _optionalChain([servers, 'optionalAccess',
|
|
551
|
+
const server = _optionalChain([servers, 'optionalAccess', _29 => _29[0]]);
|
|
629
552
|
if (!server) {
|
|
630
553
|
throw new Error(
|
|
631
554
|
"The OpenAPI document has no `servers` entry. Pass `baseUrl` to fromOpenAPI() explicitly."
|
|
@@ -709,7 +632,7 @@ function assertNoSubstitutedDotSegments(route, resolvedPath) {
|
|
|
709
632
|
const templateSegments = new Set(route.path.split("/"));
|
|
710
633
|
for (const segment of resolvedPath.split("/")) {
|
|
711
634
|
if ((segment === "." || segment === "..") && !templateSegments.has(segment)) {
|
|
712
|
-
throw new (0,
|
|
635
|
+
throw new (0, _chunk5EEESM57cjs.UserError)(
|
|
713
636
|
`${route.method.toUpperCase()} ${route.path}: path parameter values must not produce a "${segment}" path segment.`
|
|
714
637
|
);
|
|
715
638
|
}
|
|
@@ -722,7 +645,7 @@ function encodeCookieValue(mapping, value) {
|
|
|
722
645
|
return encodePathComponent(text);
|
|
723
646
|
}
|
|
724
647
|
if (/[;,]/.test(text)) {
|
|
725
|
-
throw new (0,
|
|
648
|
+
throw new (0, _chunk5EEESM57cjs.UserError)(
|
|
726
649
|
`Cookie parameter "${mapping.name}" uses style "cookie" and its value contains ";" or ","`
|
|
727
650
|
);
|
|
728
651
|
}
|
|
@@ -765,6 +688,117 @@ function encodePathValue(value, style, explode) {
|
|
|
765
688
|
}
|
|
766
689
|
return encodeURIComponent(String(value));
|
|
767
690
|
}
|
|
691
|
+
async function fetchResponse(options) {
|
|
692
|
+
const baseUrl = resolveBaseUrl(
|
|
693
|
+
options.servers,
|
|
694
|
+
options.origin,
|
|
695
|
+
options.baseUrlOverride
|
|
696
|
+
);
|
|
697
|
+
const pathParams = /* @__PURE__ */ Object.create(null);
|
|
698
|
+
const queryParts = [];
|
|
699
|
+
const headers = new Headers(
|
|
700
|
+
await resolveHeaders(options.headers, options.context)
|
|
701
|
+
);
|
|
702
|
+
const bodyProps = /* @__PURE__ */ Object.create(null);
|
|
703
|
+
for (const [key, value] of Object.entries(options.args)) {
|
|
704
|
+
const mapping = options.parameterMap[key];
|
|
705
|
+
if (!mapping || value === void 0) {
|
|
706
|
+
continue;
|
|
707
|
+
}
|
|
708
|
+
if (value === null && mapping.encoding !== "json" && (mapping.in === "query" || mapping.in === "header" || mapping.in === "cookie")) {
|
|
709
|
+
continue;
|
|
710
|
+
}
|
|
711
|
+
switch (mapping.in) {
|
|
712
|
+
case "body":
|
|
713
|
+
bodyProps[mapping.name] = value;
|
|
714
|
+
break;
|
|
715
|
+
case "cookie": {
|
|
716
|
+
const encoded = mapping.encoding === "json" ? encodePathComponent(JSON.stringify(value)) : encodeCookieValue(mapping, value);
|
|
717
|
+
const pair = `${mapping.name}=${encoded}`;
|
|
718
|
+
const existing = headers.get("cookie");
|
|
719
|
+
headers.set("cookie", existing ? `${existing}; ${pair}` : pair);
|
|
720
|
+
break;
|
|
721
|
+
}
|
|
722
|
+
case "header":
|
|
723
|
+
headers.set(
|
|
724
|
+
mapping.name,
|
|
725
|
+
mapping.encoding === "json" ? JSON.stringify(value) : serializeHeaderValue(value, mapping.style, mapping.explode)
|
|
726
|
+
);
|
|
727
|
+
break;
|
|
728
|
+
case "path":
|
|
729
|
+
pathParams[mapping.name] = mapping.encoding === "json" ? encodePathComponent(JSON.stringify(value)) : encodePathValue(value, mapping.style, mapping.explode);
|
|
730
|
+
break;
|
|
731
|
+
case "query": {
|
|
732
|
+
const query = new URLSearchParams();
|
|
733
|
+
if (mapping.encoding === "json") {
|
|
734
|
+
query.append(mapping.name, JSON.stringify(value));
|
|
735
|
+
queryParts.push(serializeQuery(query, false));
|
|
736
|
+
break;
|
|
737
|
+
}
|
|
738
|
+
appendQueryValue(
|
|
739
|
+
query,
|
|
740
|
+
mapping.name,
|
|
741
|
+
mapping.style,
|
|
742
|
+
value,
|
|
743
|
+
mapping.explode
|
|
744
|
+
);
|
|
745
|
+
if (query.size > 0) {
|
|
746
|
+
queryParts.push(serializeQuery(query, mapping.allowReserved));
|
|
747
|
+
}
|
|
748
|
+
break;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
let path = options.route.path;
|
|
753
|
+
for (const [name, value] of Object.entries(pathParams)) {
|
|
754
|
+
path = path.replaceAll(`{${name}}`, value);
|
|
755
|
+
}
|
|
756
|
+
assertNoSubstitutedDotSegments(options.route, path);
|
|
757
|
+
const url = new URL(baseUrl.replace(/\/$/, "") + path);
|
|
758
|
+
url.search = queryParts.join("&");
|
|
759
|
+
let body;
|
|
760
|
+
const requiredJsonBody = options.bodyEncoding === "json" && _optionalChain([options, 'access', _30 => _30.route, 'access', _31 => _31.requestBody, 'optionalAccess', _32 => _32.required]) === true && !options.wholeBodyKey;
|
|
761
|
+
if (Object.keys(bodyProps).length > 0 || requiredJsonBody) {
|
|
762
|
+
const payload = options.wholeBodyKey ? bodyProps[options.wholeBodyKey] : bodyProps;
|
|
763
|
+
if (options.bodyEncoding === "form") {
|
|
764
|
+
if (!headers.has("content-type")) {
|
|
765
|
+
headers.set("content-type", "application/x-www-form-urlencoded");
|
|
766
|
+
}
|
|
767
|
+
body = encodeFormBody(payload);
|
|
768
|
+
} else {
|
|
769
|
+
if (!headers.has("content-type")) {
|
|
770
|
+
headers.set("content-type", "application/json");
|
|
771
|
+
}
|
|
772
|
+
body = JSON.stringify(payload);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
const response = await options.fetchImpl(url.toString(), {
|
|
776
|
+
body,
|
|
777
|
+
headers,
|
|
778
|
+
method: options.route.method.toUpperCase(),
|
|
779
|
+
signal: options.signal
|
|
780
|
+
});
|
|
781
|
+
if (!response.ok) {
|
|
782
|
+
const text = await response.text();
|
|
783
|
+
throw new (0, _chunk5EEESM57cjs.UserError)(
|
|
784
|
+
`${options.route.method.toUpperCase()} ${path} failed with ${response.status}: ${text.slice(0, 2e3)}`
|
|
785
|
+
);
|
|
786
|
+
}
|
|
787
|
+
return response;
|
|
788
|
+
}
|
|
789
|
+
async function readTextResponse(response) {
|
|
790
|
+
const text = await response.text();
|
|
791
|
+
const mediaType = _optionalChain([response, 'access', _33 => _33.headers, 'access', _34 => _34.get, 'call', _35 => _35("content-type"), 'optionalAccess', _36 => _36.split, 'call', _37 => _37(";"), 'access', _38 => _38[0]]);
|
|
792
|
+
if (_optionalChain([mediaType, 'optionalAccess', _39 => _39.toLowerCase, 'call', _40 => _40(), 'access', _41 => _41.includes, 'call', _42 => _42("json")])) {
|
|
793
|
+
try {
|
|
794
|
+
const json = JSON.parse(text);
|
|
795
|
+
return { json, text: JSON.stringify(json, null, 2) };
|
|
796
|
+
} catch (e4) {
|
|
797
|
+
return { text };
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
return { text };
|
|
801
|
+
}
|
|
768
802
|
async function resolveHeaders(headers, context) {
|
|
769
803
|
if (!headers) {
|
|
770
804
|
return {};
|
|
@@ -835,6 +869,9 @@ function isEligibleForResource(route, sharedDefs) {
|
|
|
835
869
|
if (param.in === "header" || param.in === "cookie") {
|
|
836
870
|
return false;
|
|
837
871
|
}
|
|
872
|
+
if (param.content && param.schema === void 0) {
|
|
873
|
+
return false;
|
|
874
|
+
}
|
|
838
875
|
return !hasStructuredType(_nullishCoalesce(param.schema, () => ( {})), sharedDefs);
|
|
839
876
|
});
|
|
840
877
|
}
|
|
@@ -885,7 +922,7 @@ function extractRoutes(document) {
|
|
|
885
922
|
requestBody: operation.requestBody ? resolveRef(document, operation.requestBody) : void 0,
|
|
886
923
|
responses: resolveResponses(document, operation.responses),
|
|
887
924
|
servers: [operation.servers, pathItem.servers, document.servers].find(
|
|
888
|
-
(servers) => _optionalChain([servers, 'optionalAccess',
|
|
925
|
+
(servers) => _optionalChain([servers, 'optionalAccess', _43 => _43.length])
|
|
889
926
|
),
|
|
890
927
|
summary: operation.summary,
|
|
891
928
|
tags: _nullishCoalesce(operation.tags, () => ( []))
|
|
@@ -936,7 +973,7 @@ function resolveRef(document, value) {
|
|
|
936
973
|
);
|
|
937
974
|
let node = document;
|
|
938
975
|
for (const segment of segments) {
|
|
939
|
-
node = _optionalChain([node, 'optionalAccess',
|
|
976
|
+
node = _optionalChain([node, 'optionalAccess', _44 => _44[segment]]);
|
|
940
977
|
}
|
|
941
978
|
return node;
|
|
942
979
|
}
|
|
@@ -1006,8 +1043,8 @@ async function fromOpenAPI(options) {
|
|
|
1006
1043
|
const selected = selectRoutes(routes, options);
|
|
1007
1044
|
const names = generateNames(selected, options.mcpNames);
|
|
1008
1045
|
const sharedDefs = buildSharedDefs(document);
|
|
1009
|
-
const server = _nullishCoalesce(options.server, () => ( new (0,
|
|
1010
|
-
name: _nullishCoalesce(_nullishCoalesce(options.name, () => ( _optionalChain([document, 'access',
|
|
1046
|
+
const server = _nullishCoalesce(options.server, () => ( new (0, _chunk5EEESM57cjs.FastMCP)({
|
|
1047
|
+
name: _nullishCoalesce(_nullishCoalesce(options.name, () => ( _optionalChain([document, 'access', _45 => _45.info, 'optionalAccess', _46 => _46.title]))), () => ( "OpenAPI Server")),
|
|
1011
1048
|
version: _nullishCoalesce(options.version, () => ( "1.0.0"))
|
|
1012
1049
|
})));
|
|
1013
1050
|
const skippedOperations = [];
|
|
@@ -1052,7 +1089,7 @@ async function fromOpenAPI(options) {
|
|
|
1052
1089
|
continue;
|
|
1053
1090
|
}
|
|
1054
1091
|
const outputSchemaJson = buildOutputSchema(route, sharedDefs);
|
|
1055
|
-
const outputSchema = outputSchemaJson ?
|
|
1092
|
+
const outputSchema = outputSchemaJson ? _chunk5EEESM57cjs.jsonSchemaAdapter.call(void 0, outputSchemaJson) : void 0;
|
|
1056
1093
|
server.addTool({
|
|
1057
1094
|
description: _nullishCoalesce(route.summary, () => ( `${route.method.toUpperCase()} ${route.path}`)),
|
|
1058
1095
|
execute: async (args, context) => {
|
|
@@ -1067,7 +1104,7 @@ async function fromOpenAPI(options) {
|
|
|
1067
1104
|
return resolveToolResult(result, outputSchema);
|
|
1068
1105
|
},
|
|
1069
1106
|
name,
|
|
1070
|
-
parameters:
|
|
1107
|
+
parameters: _chunk5EEESM57cjs.jsonSchemaAdapter.call(void 0, flatSchema),
|
|
1071
1108
|
...outputSchema ? { outputSchema } : {}
|
|
1072
1109
|
});
|
|
1073
1110
|
}
|
|
@@ -1086,9 +1123,7 @@ function registerResource(server, route, name, parameterMap, requiredKeys, execO
|
|
|
1086
1123
|
if (mapping.kind === "resource") {
|
|
1087
1124
|
server.addResource({
|
|
1088
1125
|
description,
|
|
1089
|
-
load: async (_auth, context) =>
|
|
1090
|
-
await executeRequest({ ...execOptions, args: {}, context })
|
|
1091
|
-
),
|
|
1126
|
+
load: async (_auth, context) => executeResourceRequest({ ...execOptions, args: {}, context }),
|
|
1092
1127
|
name,
|
|
1093
1128
|
uri: mapping.uri
|
|
1094
1129
|
});
|
|
@@ -1097,13 +1132,11 @@ function registerResource(server, route, name, parameterMap, requiredKeys, execO
|
|
|
1097
1132
|
server.addResourceTemplate({
|
|
1098
1133
|
arguments: mapping.args,
|
|
1099
1134
|
description,
|
|
1100
|
-
load: async (args, _auth, context) =>
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
})
|
|
1106
|
-
),
|
|
1135
|
+
load: async (args, _auth, context) => executeResourceRequest({
|
|
1136
|
+
...execOptions,
|
|
1137
|
+
args,
|
|
1138
|
+
context
|
|
1139
|
+
}),
|
|
1107
1140
|
name,
|
|
1108
1141
|
uriTemplate: mapping.uriTemplate
|
|
1109
1142
|
});
|
|
@@ -1121,14 +1154,6 @@ async function resolveToolResult(result, outputSchema) {
|
|
|
1121
1154
|
}
|
|
1122
1155
|
return { content: [{ text, type: "text" }], isError: true };
|
|
1123
1156
|
}
|
|
1124
|
-
function wrapAsResourceResult({ text }) {
|
|
1125
|
-
try {
|
|
1126
|
-
JSON.parse(text);
|
|
1127
|
-
return { mimeType: "application/json", text };
|
|
1128
|
-
} catch (e4) {
|
|
1129
|
-
return { mimeType: "text/plain", text };
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
1157
|
|
|
1133
1158
|
|
|
1134
1159
|
exports.fromOpenAPI = fromOpenAPI;
|