fastmcp 4.22.4 → 4.22.6
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 +4 -2
- package/dist/FastMCP.cjs +3 -3
- package/dist/FastMCP.js +2 -2
- package/dist/auth/index.cjs +2 -2
- package/dist/auth/index.js +1 -1
- package/dist/{chunk-XPKMA7DH.js → chunk-ISYL7EKR.js} +5 -2
- package/dist/{chunk-XPKMA7DH.js.map → chunk-ISYL7EKR.js.map} +1 -1
- package/dist/{chunk-TFX7BV4K.js → chunk-OAM6AYJY.js} +28 -10
- package/dist/chunk-OAM6AYJY.js.map +1 -0
- package/dist/{chunk-V37MCHBL.cjs → chunk-QJIFKZYZ.cjs} +31 -13
- package/dist/chunk-QJIFKZYZ.cjs.map +1 -0
- package/dist/{chunk-YOBCXNFP.cjs → chunk-YLLBANV4.cjs} +5 -2
- package/dist/chunk-YLLBANV4.cjs.map +1 -0
- package/dist/examples/custom-routes.cjs +3 -3
- package/dist/examples/custom-routes.js +2 -2
- package/dist/openapi/index.cjs +29 -17
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.js +15 -3
- package/dist/openapi/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-TFX7BV4K.js.map +0 -1
- package/dist/chunk-V37MCHBL.cjs.map +0 -1
- package/dist/chunk-YOBCXNFP.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkYLLBANV4cjs = require('./chunk-YLLBANV4.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkO22SYZMCcjs = require('./chunk-O22SYZMC.cjs');
|
|
@@ -134,7 +134,7 @@ var DiscoveryDocumentCache = class {
|
|
|
134
134
|
throw error;
|
|
135
135
|
}
|
|
136
136
|
if (!res.ok) {
|
|
137
|
-
await
|
|
137
|
+
await _chunkYLLBANV4cjs.cancelResponseBody.call(void 0, res);
|
|
138
138
|
throw new Error(
|
|
139
139
|
`Failed to fetch discovery document from ${url}: ${res.status} ${res.statusText}`
|
|
140
140
|
);
|
|
@@ -230,7 +230,7 @@ var imageContent = async (input) => {
|
|
|
230
230
|
signal: AbortSignal.timeout(timeoutMs)
|
|
231
231
|
});
|
|
232
232
|
if (!response.ok) {
|
|
233
|
-
await
|
|
233
|
+
await _chunkYLLBANV4cjs.cancelResponseBody.call(void 0, response);
|
|
234
234
|
throw new Error(
|
|
235
235
|
`Server responded with status: ${response.status} - ${response.statusText}`
|
|
236
236
|
);
|
|
@@ -292,7 +292,7 @@ var audioContent = async (input) => {
|
|
|
292
292
|
signal: AbortSignal.timeout(timeoutMs)
|
|
293
293
|
});
|
|
294
294
|
if (!response.ok) {
|
|
295
|
-
await
|
|
295
|
+
await _chunkYLLBANV4cjs.cancelResponseBody.call(void 0, response);
|
|
296
296
|
throw new Error(
|
|
297
297
|
`Server responded with status: ${response.status} - ${response.statusText}`
|
|
298
298
|
);
|
|
@@ -1048,9 +1048,11 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1048
1048
|
return parsed.value;
|
|
1049
1049
|
}
|
|
1050
1050
|
addPrompt(inputPrompt) {
|
|
1051
|
-
const completers =
|
|
1052
|
-
|
|
1053
|
-
|
|
1051
|
+
const completers = /* @__PURE__ */ Object.create(
|
|
1052
|
+
null
|
|
1053
|
+
);
|
|
1054
|
+
const enums = /* @__PURE__ */ Object.create(null);
|
|
1055
|
+
const fuseInstances = /* @__PURE__ */ Object.create(null);
|
|
1054
1056
|
for (const argument of _nullishCoalesce(inputPrompt.arguments, () => ( []))) {
|
|
1055
1057
|
if (argument.complete) {
|
|
1056
1058
|
completers[argument.name] = argument.complete;
|
|
@@ -1098,7 +1100,9 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1098
1100
|
this.#resources.set(inputResource.uri, inputResource);
|
|
1099
1101
|
}
|
|
1100
1102
|
addResourceTemplate(inputResourceTemplate) {
|
|
1101
|
-
const completers =
|
|
1103
|
+
const completers = /* @__PURE__ */ Object.create(
|
|
1104
|
+
null
|
|
1105
|
+
);
|
|
1102
1106
|
for (const argument of _nullishCoalesce(inputResourceTemplate.arguments, () => ( []))) {
|
|
1103
1107
|
if (argument.complete) {
|
|
1104
1108
|
completers[argument.name] = argument.complete;
|
|
@@ -1233,7 +1237,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1233
1237
|
}
|
|
1234
1238
|
const args = request.params.arguments;
|
|
1235
1239
|
for (const arg of _nullishCoalesce(prompt.arguments, () => ( []))) {
|
|
1236
|
-
if (arg.required && !(args && arg.name
|
|
1240
|
+
if (arg.required && !(args && Object.hasOwn(args, arg.name))) {
|
|
1237
1241
|
throw new (0, _typesjs.McpError)(
|
|
1238
1242
|
_typesjs.ErrorCode.InvalidParams,
|
|
1239
1243
|
`Prompt '${request.params.name}' requires argument '${arg.name}': ${arg.description || "No description provided"}`
|
|
@@ -1302,7 +1306,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1302
1306
|
const uriTemplate = _uritemplates2.default.call(void 0,
|
|
1303
1307
|
resourceTemplate.uriTemplate
|
|
1304
1308
|
);
|
|
1305
|
-
const match = uriTemplate
|
|
1309
|
+
const match = matchUriTemplate(uriTemplate, request.params.uri);
|
|
1306
1310
|
if (!match) {
|
|
1307
1311
|
continue;
|
|
1308
1312
|
}
|
|
@@ -1666,6 +1670,20 @@ function convertObjectToSnakeCase(obj) {
|
|
|
1666
1670
|
function joinPaths(basePath, path) {
|
|
1667
1671
|
return `${basePath}${normalizePath(path)}`;
|
|
1668
1672
|
}
|
|
1673
|
+
function matchUriTemplate(template, uri) {
|
|
1674
|
+
const match = template.fromUri(uri);
|
|
1675
|
+
if (!match) {
|
|
1676
|
+
return void 0;
|
|
1677
|
+
}
|
|
1678
|
+
const checksQuery = !/\{[?&]/.test(template.template);
|
|
1679
|
+
const checksFragment = !template.template.includes("{#");
|
|
1680
|
+
const shape = (value) => [
|
|
1681
|
+
value.split(/[?#]/, 1)[0].split("/").length,
|
|
1682
|
+
checksQuery && value.includes("?"),
|
|
1683
|
+
checksFragment && value.includes("#")
|
|
1684
|
+
].join();
|
|
1685
|
+
return shape(template.fill(match)) === shape(uri) ? match : void 0;
|
|
1686
|
+
}
|
|
1669
1687
|
function normalizeBasePath(path) {
|
|
1670
1688
|
if (!path || path === "/") {
|
|
1671
1689
|
return "";
|
|
@@ -1946,7 +1964,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1946
1964
|
}
|
|
1947
1965
|
for (const template of this.#resourcesTemplates) {
|
|
1948
1966
|
const parsedTemplate = _uritemplates2.default.call(void 0, template.uriTemplate);
|
|
1949
|
-
const params = parsedTemplate
|
|
1967
|
+
const params = matchUriTemplate(parsedTemplate, uri);
|
|
1950
1968
|
if (!params) {
|
|
1951
1969
|
continue;
|
|
1952
1970
|
}
|
|
@@ -2922,7 +2940,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2922
2940
|
_optionalChain([overrides, 'optionalAccess', _80 => _80.httpStream, 'optionalAccess', _81 => _81.basePath]) || basePathArg || envBasePath
|
|
2923
2941
|
);
|
|
2924
2942
|
const enableJsonResponse = _optionalChain([overrides, 'optionalAccess', _82 => _82.httpStream, 'optionalAccess', _83 => _83.enableJsonResponse]) || false;
|
|
2925
|
-
const stateless = _optionalChain([overrides, 'optionalAccess', _84 => _84.httpStream, 'optionalAccess', _85 => _85.stateless])
|
|
2943
|
+
const stateless = _nullishCoalesce(_optionalChain([overrides, 'optionalAccess', _84 => _84.httpStream, 'optionalAccess', _85 => _85.stateless]), () => ( (statelessArg !== void 0 ? statelessArg === "true" : envStateless === "true")));
|
|
2926
2944
|
const cors = _optionalChain([overrides, 'optionalAccess', _86 => _86.httpStream, 'optionalAccess', _87 => _87.cors]);
|
|
2927
2945
|
const eventStore = _optionalChain([overrides, 'optionalAccess', _88 => _88.httpStream, 'optionalAccess', _89 => _89.eventStore]);
|
|
2928
2946
|
const sslCa = _optionalChain([overrides, 'optionalAccess', _90 => _90.httpStream, 'optionalAccess', _91 => _91.sslCa]);
|
|
@@ -3048,4 +3066,4 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3048
3066
|
|
|
3049
3067
|
|
|
3050
3068
|
exports.DiscoveryDocumentCache = DiscoveryDocumentCache; exports.jsonSchemaAdapter = jsonSchemaAdapter; exports.MEDIA_FETCH_TIMEOUT_MS = MEDIA_FETCH_TIMEOUT_MS; exports.imageContent = imageContent; exports.audioContent = audioContent; exports.FastMCPError = FastMCPError; exports.SessionError = SessionError; exports.UnexpectedStateError = UnexpectedStateError; exports.UserError = UserError; exports.ServerState = ServerState; exports.FastMCPSession = FastMCPSession; exports.FastMCP = FastMCP;
|
|
3051
|
-
//# sourceMappingURL=chunk-
|
|
3069
|
+
//# sourceMappingURL=chunk-QJIFKZYZ.cjs.map
|