fastmcp 4.26.2 → 4.28.0
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/FastMCP.cjs +4 -4
- package/dist/FastMCP.d.cts +2 -2
- package/dist/FastMCP.d.ts +2 -2
- package/dist/FastMCP.js +3 -3
- package/dist/{OAuthProvider-B7VDZGyx.d.cts → OAuthProvider-BnQsqcsL.d.cts} +13 -3
- package/dist/{OAuthProvider-B7VDZGyx.d.ts → OAuthProvider-BnQsqcsL.d.ts} +13 -3
- package/dist/auth/index.cjs +2 -2
- package/dist/auth/index.d.cts +2 -2
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +1 -1
- package/dist/chunk-2NZFMD6I.cjs +120 -0
- package/dist/chunk-2NZFMD6I.cjs.map +1 -0
- package/dist/{chunk-W6P57SNV.js → chunk-4ZSNKIR3.js} +37 -5
- package/dist/chunk-4ZSNKIR3.js.map +1 -0
- package/dist/{chunk-UULT6NOS.cjs → chunk-AAPHX5IG.cjs} +28 -13
- package/dist/chunk-AAPHX5IG.cjs.map +1 -0
- package/dist/chunk-AM3HVK4Z.js +120 -0
- package/dist/chunk-AM3HVK4Z.js.map +1 -0
- package/dist/{chunk-ASOZUCE2.js → chunk-EI3KPYSZ.js} +22 -7
- package/dist/chunk-EI3KPYSZ.js.map +1 -0
- package/dist/{chunk-HVKGDRTL.cjs → chunk-VVAKRLCY.cjs} +37 -5
- package/dist/chunk-VVAKRLCY.cjs.map +1 -0
- package/dist/edge/index.cjs +61 -43
- package/dist/edge/index.cjs.map +1 -1
- package/dist/edge/index.d.cts +0 -6
- package/dist/edge/index.d.ts +0 -6
- package/dist/edge/index.js +59 -41
- 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 +98 -36
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.d.cts +4 -4
- package/dist/openapi/index.d.ts +4 -4
- package/dist/openapi/index.js +88 -26
- package/dist/openapi/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-6TDYSPLC.cjs +0 -44
- package/dist/chunk-6TDYSPLC.cjs.map +0 -1
- package/dist/chunk-ASOZUCE2.js.map +0 -1
- package/dist/chunk-HVKGDRTL.cjs.map +0 -1
- package/dist/chunk-OKKFL2M4.js +0 -44
- package/dist/chunk-OKKFL2M4.js.map +0 -1
- package/dist/chunk-UULT6NOS.cjs.map +0 -1
- package/dist/chunk-W6P57SNV.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 _chunkAAPHX5IGcjs = require('../chunk-AAPHX5IG.cjs');
|
|
6
|
+
require('../chunk-VVAKRLCY.cjs');
|
|
7
|
+
require('../chunk-2NZFMD6I.cjs');
|
|
8
8
|
|
|
9
9
|
// src/openapi/loadSpec.ts
|
|
10
10
|
var _swaggerparser = require('@apidevtools/swagger-parser'); var _swaggerparser2 = _interopRequireDefault(_swaggerparser);
|
|
@@ -38,7 +38,7 @@ function buildFlatSchema(route, sharedDefs) {
|
|
|
38
38
|
unsupportedBodyContentType,
|
|
39
39
|
wholeBodyKey
|
|
40
40
|
} = extractBodyProperties(
|
|
41
|
-
route.method === "get" ? void 0 : route.requestBody,
|
|
41
|
+
route.method === "get" || route.method === "head" ? void 0 : route.requestBody,
|
|
42
42
|
sharedDefs
|
|
43
43
|
);
|
|
44
44
|
const properties = /* @__PURE__ */ Object.create(null);
|
|
@@ -84,10 +84,13 @@ function buildFlatSchema(route, sharedDefs) {
|
|
|
84
84
|
const requiredBodyKeys = [];
|
|
85
85
|
for (const [name, { required: isRequired, schema }] of bodyProperties) {
|
|
86
86
|
const key = name === "__proto__" ? allocateAlias(`${name}__body`) : name;
|
|
87
|
-
properties[key] =
|
|
87
|
+
properties[key] = omitReadOnlyRequired(
|
|
88
|
+
rewriteComponentRefs(schema),
|
|
89
|
+
"schema"
|
|
90
|
+
);
|
|
88
91
|
parameterMap[key] = { in: "body", name };
|
|
89
92
|
bodyKeys.push(key);
|
|
90
|
-
if (isRequired) {
|
|
93
|
+
if (isRequired && schema.readOnly !== true) {
|
|
91
94
|
requiredBodyKeys.push(key);
|
|
92
95
|
}
|
|
93
96
|
}
|
|
@@ -106,7 +109,7 @@ function buildFlatSchema(route, sharedDefs) {
|
|
|
106
109
|
}
|
|
107
110
|
const usedDefs = sharedDefs && filterReferencedDefs(properties, sharedDefs);
|
|
108
111
|
if (usedDefs) {
|
|
109
|
-
flatSchema.$defs = usedDefs;
|
|
112
|
+
flatSchema.$defs = omitReadOnlyRequired(usedDefs, "schemaMap");
|
|
110
113
|
}
|
|
111
114
|
return {
|
|
112
115
|
bodyEncoding,
|
|
@@ -126,24 +129,34 @@ function buildSharedDefs(document) {
|
|
|
126
129
|
var SUCCESS_STATUS_PATTERN = /^2\d\d$/;
|
|
127
130
|
var MAX_OUTPUT_SCHEMA_DEFS = 50;
|
|
128
131
|
function buildOutputSchema(route, sharedDefs) {
|
|
129
|
-
|
|
132
|
+
if (route.method === "head") {
|
|
133
|
+
return void 0;
|
|
134
|
+
}
|
|
135
|
+
const successEntries = Object.entries(_nullishCoalesce(route.responses, () => ( {}))).filter(
|
|
130
136
|
([code]) => SUCCESS_STATUS_PATTERN.test(code)
|
|
131
137
|
);
|
|
132
|
-
|
|
133
|
-
_optionalChain([successEntry, 'optionalAccess', _8 => _8[1], 'access', _9 => _9.content]),
|
|
134
|
-
"application/json"
|
|
135
|
-
), 'optionalAccess', _10 => _10.schema]);
|
|
136
|
-
if (!declaredSchema) {
|
|
138
|
+
if (successEntries.length === 0) {
|
|
137
139
|
return void 0;
|
|
138
140
|
}
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
const schemas = [];
|
|
142
|
+
for (const [, response] of successEntries) {
|
|
143
|
+
const declaredSchema = _optionalChain([findMediaType, 'call', _7 => _7(
|
|
144
|
+
response.content,
|
|
145
|
+
"application/json"
|
|
146
|
+
), 'optionalAccess', _8 => _8.schema]);
|
|
147
|
+
if (!declaredSchema) {
|
|
148
|
+
return void 0;
|
|
149
|
+
}
|
|
150
|
+
const schema = resolveComponentRef(declaredSchema, sharedDefs);
|
|
151
|
+
const rewritten = rewriteComponentRefs(schema, true);
|
|
152
|
+
const { type } = rewritten;
|
|
153
|
+
const isObjectShaped = type === "object" || Array.isArray(type) && type.includes("object");
|
|
154
|
+
if (!isObjectShaped) {
|
|
155
|
+
return void 0;
|
|
156
|
+
}
|
|
157
|
+
schemas.push({ ...rewritten, type: "object" });
|
|
145
158
|
}
|
|
146
|
-
const normalized = {
|
|
159
|
+
const normalized = schemas.length === 1 ? schemas[0] : { anyOf: schemas, type: "object" };
|
|
147
160
|
const usedDefs = sharedDefs && filterReferencedDefs(normalized, sharedDefs);
|
|
148
161
|
if (usedDefs && Object.keys(usedDefs).length > MAX_OUTPUT_SCHEMA_DEFS) {
|
|
149
162
|
return void 0;
|
|
@@ -161,7 +174,7 @@ function resolveComponentRef(schema, sharedDefs) {
|
|
|
161
174
|
let ref = current.$ref;
|
|
162
175
|
while (typeof ref === "string") {
|
|
163
176
|
const name = componentSchemaName(ref);
|
|
164
|
-
const target = name === void 0 ? void 0 : _optionalChain([sharedDefs, 'optionalAccess',
|
|
177
|
+
const target = name === void 0 ? void 0 : _optionalChain([sharedDefs, 'optionalAccess', _9 => _9[name]]);
|
|
165
178
|
if (name === void 0 || target === void 0 || seen.has(name)) {
|
|
166
179
|
break;
|
|
167
180
|
}
|
|
@@ -190,7 +203,7 @@ function componentSchemaName(ref) {
|
|
|
190
203
|
}
|
|
191
204
|
function extractBodyProperties(requestBody, sharedDefs) {
|
|
192
205
|
const properties = /* @__PURE__ */ new Map();
|
|
193
|
-
const content = _optionalChain([requestBody, 'optionalAccess',
|
|
206
|
+
const content = _optionalChain([requestBody, 'optionalAccess', _10 => _10.content]);
|
|
194
207
|
if (!content) {
|
|
195
208
|
return { properties };
|
|
196
209
|
}
|
|
@@ -201,7 +214,7 @@ function extractBodyProperties(requestBody, sharedDefs) {
|
|
|
201
214
|
return contentTypes.length > 0 ? { properties, unsupportedBodyContentType: contentTypes[0] } : { properties };
|
|
202
215
|
}
|
|
203
216
|
const bodyEncoding = json === void 0 ? "form" : "json";
|
|
204
|
-
const declaredSchema = bodyEncoding === "json" ? _optionalChain([json, 'optionalAccess',
|
|
217
|
+
const declaredSchema = bodyEncoding === "json" ? _optionalChain([json, 'optionalAccess', _11 => _11.schema]) : _optionalChain([form, 'optionalAccess', _12 => _12.schema]);
|
|
205
218
|
if (!declaredSchema) {
|
|
206
219
|
return { bodyEncoding, properties };
|
|
207
220
|
}
|
|
@@ -226,7 +239,7 @@ function extractBodyProperties(requestBody, sharedDefs) {
|
|
|
226
239
|
};
|
|
227
240
|
}
|
|
228
241
|
properties.set("body", {
|
|
229
|
-
required: _nullishCoalesce(_optionalChain([requestBody, 'optionalAccess',
|
|
242
|
+
required: _nullishCoalesce(_optionalChain([requestBody, 'optionalAccess', _13 => _13.required]), () => ( false)),
|
|
230
243
|
schema
|
|
231
244
|
});
|
|
232
245
|
return { bodyEncoding, properties, wholeBodyKey: "body" };
|
|
@@ -309,6 +322,35 @@ function normalizeNullable(schema) {
|
|
|
309
322
|
}
|
|
310
323
|
return rest;
|
|
311
324
|
}
|
|
325
|
+
function omitReadOnlyRequired(value, mode) {
|
|
326
|
+
if (mode === "data" || !value || typeof value !== "object") {
|
|
327
|
+
return value;
|
|
328
|
+
}
|
|
329
|
+
if (Array.isArray(value)) {
|
|
330
|
+
return value.map((item) => omitReadOnlyRequired(item, "schema"));
|
|
331
|
+
}
|
|
332
|
+
const node = Object.fromEntries(
|
|
333
|
+
Object.entries(value).map(([key, child]) => [
|
|
334
|
+
key,
|
|
335
|
+
omitReadOnlyRequired(
|
|
336
|
+
child,
|
|
337
|
+
mode === "schemaMap" ? "schema" : childMode(key)
|
|
338
|
+
)
|
|
339
|
+
])
|
|
340
|
+
);
|
|
341
|
+
const { properties, required } = node;
|
|
342
|
+
if (mode === "schema" && Array.isArray(required) && properties && typeof properties === "object") {
|
|
343
|
+
const writable = required.filter(
|
|
344
|
+
(name) => !(typeof name === "string" && Object.hasOwn(properties, name) && _optionalChain([properties, 'access', _14 => _14[name], 'optionalAccess', _15 => _15.readOnly]) === true)
|
|
345
|
+
);
|
|
346
|
+
if (writable.length > 0) {
|
|
347
|
+
node.required = writable;
|
|
348
|
+
} else {
|
|
349
|
+
delete node.required;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return node;
|
|
353
|
+
}
|
|
312
354
|
function rewriteNode(value, mode, stripExamples = false) {
|
|
313
355
|
if (mode === "data") {
|
|
314
356
|
return value;
|
|
@@ -564,7 +606,7 @@ async function executeRequest(options) {
|
|
|
564
606
|
});
|
|
565
607
|
const text = await response.text();
|
|
566
608
|
if (!response.ok) {
|
|
567
|
-
throw new (0,
|
|
609
|
+
throw new (0, _chunkAAPHX5IGcjs.UserError)(
|
|
568
610
|
`${options.route.method.toUpperCase()} ${path} failed with ${response.status}: ${text.slice(0, 2e3)}`
|
|
569
611
|
);
|
|
570
612
|
}
|
|
@@ -628,12 +670,13 @@ function appendBracketPairs(params, key, value) {
|
|
|
628
670
|
params.append(key, String(value));
|
|
629
671
|
}
|
|
630
672
|
function appendQueryValue(query, name, style, value, explode) {
|
|
673
|
+
value = withoutNullMembers(value);
|
|
631
674
|
if (style === "deepObject") {
|
|
632
675
|
appendBracketPairs(query, name, value);
|
|
633
676
|
return;
|
|
634
677
|
}
|
|
635
678
|
if (style === "spaceDelimited" || style === "pipeDelimited") {
|
|
636
|
-
const items = Array.isArray(value) ? value : [value];
|
|
679
|
+
const items = Array.isArray(value) ? value : value !== null && typeof value === "object" ? Object.entries(value).flat() : [value];
|
|
637
680
|
const separator = style === "spaceDelimited" ? " " : "|";
|
|
638
681
|
query.append(name, items.map(String).join(separator));
|
|
639
682
|
return;
|
|
@@ -666,7 +709,7 @@ function assertNoSubstitutedDotSegments(route, resolvedPath) {
|
|
|
666
709
|
const templateSegments = new Set(route.path.split("/"));
|
|
667
710
|
for (const segment of resolvedPath.split("/")) {
|
|
668
711
|
if ((segment === "." || segment === "..") && !templateSegments.has(segment)) {
|
|
669
|
-
throw new (0,
|
|
712
|
+
throw new (0, _chunkAAPHX5IGcjs.UserError)(
|
|
670
713
|
`${route.method.toUpperCase()} ${route.path}: path parameter values must not produce a "${segment}" path segment.`
|
|
671
714
|
);
|
|
672
715
|
}
|
|
@@ -679,7 +722,7 @@ function encodeCookieValue(mapping, value) {
|
|
|
679
722
|
return encodePathComponent(text);
|
|
680
723
|
}
|
|
681
724
|
if (/[;,]/.test(text)) {
|
|
682
|
-
throw new (0,
|
|
725
|
+
throw new (0, _chunkAAPHX5IGcjs.UserError)(
|
|
683
726
|
`Cookie parameter "${mapping.name}" uses style "cookie" and its value contains ";" or ","`
|
|
684
727
|
);
|
|
685
728
|
}
|
|
@@ -752,6 +795,17 @@ function serializeQuery(query, allowReserved) {
|
|
|
752
795
|
return `${name}=${expanded}`;
|
|
753
796
|
}).join("&");
|
|
754
797
|
}
|
|
798
|
+
function withoutNullMembers(value) {
|
|
799
|
+
if (Array.isArray(value)) {
|
|
800
|
+
return value.filter((item) => item !== null).map((item) => withoutNullMembers(item));
|
|
801
|
+
}
|
|
802
|
+
if (value !== null && typeof value === "object") {
|
|
803
|
+
return Object.fromEntries(
|
|
804
|
+
Object.entries(value).filter(([, item]) => item !== null).map(([key, item]) => [key, withoutNullMembers(item)])
|
|
805
|
+
);
|
|
806
|
+
}
|
|
807
|
+
return value;
|
|
808
|
+
}
|
|
755
809
|
|
|
756
810
|
// src/openapi/resourceMapping.ts
|
|
757
811
|
function buildResourceMapping(route, name, parameterMap, requiredKeys) {
|
|
@@ -788,7 +842,14 @@ function isEligibleForResource(route, sharedDefs) {
|
|
|
788
842
|
}
|
|
789
843
|
|
|
790
844
|
// src/openapi/routes.ts
|
|
791
|
-
var HTTP_METHODS = [
|
|
845
|
+
var HTTP_METHODS = [
|
|
846
|
+
"get",
|
|
847
|
+
"head",
|
|
848
|
+
"put",
|
|
849
|
+
"post",
|
|
850
|
+
"delete",
|
|
851
|
+
"patch"
|
|
852
|
+
];
|
|
792
853
|
function extractRoutes(document) {
|
|
793
854
|
const routes = [];
|
|
794
855
|
for (const [path, rawPathItem] of Object.entries(_nullishCoalesce(document.paths, () => ( {})))) {
|
|
@@ -883,11 +944,12 @@ function resolveResponses(document, rawResponses) {
|
|
|
883
944
|
// src/openapi/selection.ts
|
|
884
945
|
var DEFAULT_MAX_OPERATIONS = 40;
|
|
885
946
|
var METHOD_PRIORITY = {
|
|
886
|
-
delete:
|
|
947
|
+
delete: 5,
|
|
887
948
|
get: 0,
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
949
|
+
head: 1,
|
|
950
|
+
patch: 4,
|
|
951
|
+
post: 2,
|
|
952
|
+
put: 3
|
|
891
953
|
};
|
|
892
954
|
function selectRoutes(routes, options) {
|
|
893
955
|
let selected = routes.filter((route) => !route.deprecated);
|
|
@@ -933,7 +995,7 @@ async function fromOpenAPI(options) {
|
|
|
933
995
|
const selected = selectRoutes(routes, options);
|
|
934
996
|
const names = generateNames(selected, options.mcpNames);
|
|
935
997
|
const sharedDefs = buildSharedDefs(document);
|
|
936
|
-
const server = _nullishCoalesce(options.server, () => ( new (0,
|
|
998
|
+
const server = _nullishCoalesce(options.server, () => ( new (0, _chunkAAPHX5IGcjs.FastMCP)({
|
|
937
999
|
name: _nullishCoalesce(_nullishCoalesce(options.name, () => ( _optionalChain([document, 'access', _35 => _35.info, 'optionalAccess', _36 => _36.title]))), () => ( "OpenAPI Server")),
|
|
938
1000
|
version: _nullishCoalesce(options.version, () => ( "1.0.0"))
|
|
939
1001
|
})));
|
|
@@ -979,7 +1041,7 @@ async function fromOpenAPI(options) {
|
|
|
979
1041
|
continue;
|
|
980
1042
|
}
|
|
981
1043
|
const outputSchemaJson = buildOutputSchema(route, sharedDefs);
|
|
982
|
-
const outputSchema = outputSchemaJson ?
|
|
1044
|
+
const outputSchema = outputSchemaJson ? _chunkAAPHX5IGcjs.jsonSchemaAdapter.call(void 0, outputSchemaJson) : void 0;
|
|
983
1045
|
server.addTool({
|
|
984
1046
|
description: _nullishCoalesce(route.summary, () => ( `${route.method.toUpperCase()} ${route.path}`)),
|
|
985
1047
|
execute: async (args, context) => {
|
|
@@ -994,7 +1056,7 @@ async function fromOpenAPI(options) {
|
|
|
994
1056
|
return resolveToolResult(result, outputSchema);
|
|
995
1057
|
},
|
|
996
1058
|
name,
|
|
997
|
-
parameters:
|
|
1059
|
+
parameters: _chunkAAPHX5IGcjs.jsonSchemaAdapter.call(void 0, flatSchema),
|
|
998
1060
|
...outputSchema ? { outputSchema } : {}
|
|
999
1061
|
});
|
|
1000
1062
|
}
|