fastmcp 4.23.7 → 4.23.9

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.
Files changed (39) hide show
  1. package/dist/FastMCP.cjs +4 -4
  2. package/dist/FastMCP.d.cts +3 -2
  3. package/dist/FastMCP.d.ts +3 -2
  4. package/dist/FastMCP.js +3 -3
  5. package/dist/auth/index.cjs +2 -2
  6. package/dist/auth/index.js +1 -1
  7. package/dist/bin/fastmcp.cjs +7 -1
  8. package/dist/bin/fastmcp.cjs.map +1 -1
  9. package/dist/bin/fastmcp.js +7 -1
  10. package/dist/bin/fastmcp.js.map +1 -1
  11. package/dist/{chunk-C7TBI7A5.cjs → chunk-4OWHPJEL.cjs} +16 -5
  12. package/dist/chunk-4OWHPJEL.cjs.map +1 -0
  13. package/dist/{chunk-MPFPOZ2H.cjs → chunk-6TDYSPLC.cjs} +12 -4
  14. package/dist/chunk-6TDYSPLC.cjs.map +1 -0
  15. package/dist/{chunk-7WNI6AGD.js → chunk-75ZLE5AS.js} +153 -59
  16. package/dist/chunk-75ZLE5AS.js.map +1 -0
  17. package/dist/{chunk-CA2EPNZF.js → chunk-G44SPVP7.js} +16 -5
  18. package/dist/chunk-G44SPVP7.js.map +1 -0
  19. package/dist/{chunk-YZ5QEHBX.js → chunk-OKKFL2M4.js} +11 -3
  20. package/dist/chunk-OKKFL2M4.js.map +1 -0
  21. package/dist/{chunk-TBMRFQ6M.cjs → chunk-PV5VLW7R.cjs} +208 -114
  22. package/dist/chunk-PV5VLW7R.cjs.map +1 -0
  23. package/dist/edge/index.cjs +13 -5
  24. package/dist/edge/index.cjs.map +1 -1
  25. package/dist/edge/index.js +11 -3
  26. package/dist/edge/index.js.map +1 -1
  27. package/dist/examples/custom-routes.cjs +4 -4
  28. package/dist/examples/custom-routes.js +3 -3
  29. package/dist/openapi/index.cjs +17 -12
  30. package/dist/openapi/index.cjs.map +1 -1
  31. package/dist/openapi/index.js +12 -7
  32. package/dist/openapi/index.js.map +1 -1
  33. package/package.json +1 -1
  34. package/dist/chunk-7WNI6AGD.js.map +0 -1
  35. package/dist/chunk-C7TBI7A5.cjs.map +0 -1
  36. package/dist/chunk-CA2EPNZF.js.map +0 -1
  37. package/dist/chunk-MPFPOZ2H.cjs.map +0 -1
  38. package/dist/chunk-TBMRFQ6M.cjs.map +0 -1
  39. package/dist/chunk-YZ5QEHBX.js.map +0 -1
@@ -1,10 +1,11 @@
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 _chunkC7TBI7A5cjs = require('./chunk-C7TBI7A5.cjs');
3
+ var _chunk4OWHPJELcjs = require('./chunk-4OWHPJEL.cjs');
4
4
 
5
5
 
6
6
 
7
- var _chunkMPFPOZ2Hcjs = require('./chunk-MPFPOZ2H.cjs');
7
+
8
+ var _chunk6TDYSPLCcjs = require('./chunk-6TDYSPLC.cjs');
8
9
 
9
10
  // src/FastMCP.ts
10
11
  var _indexjs = require('@modelcontextprotocol/sdk/server/index.js');
@@ -140,7 +141,7 @@ var DiscoveryDocumentCache = class {
140
141
  throw error;
141
142
  }
142
143
  if (!res.ok) {
143
- await _chunkC7TBI7A5cjs.cancelResponseBody.call(void 0, res);
144
+ await _chunk4OWHPJELcjs.cancelResponseBody.call(void 0, res);
144
145
  throw new Error(
145
146
  `Failed to fetch discovery document from ${url}: ${res.status} ${res.statusText}`
146
147
  );
@@ -186,9 +187,18 @@ function jsonSchemaAdapter(schema) {
186
187
  };
187
188
  }
188
189
  async function compileSchema(schema) {
190
+ const dialect = _optionalChain([schema, 'access', _2 => _2.$schema, 'optionalAccess', _3 => _3.replace, 'call', _4 => _4(/^http:\/\//, "https://"), 'access', _5 => _5.replace, 'call', _6 => _6(/#$/, "")]);
191
+ const isDraft2020 = dialect === "https://json-schema.org/draft/2020-12/schema";
192
+ const isDraft2019 = dialect === "https://json-schema.org/draft/2019-09/schema";
189
193
  let ajvModule;
190
194
  try {
191
- ajvModule = await Promise.resolve().then(() => _interopRequireWildcard(require("ajv")));
195
+ if (isDraft2020) {
196
+ ajvModule = await Promise.resolve().then(() => _interopRequireWildcard(require("ajv/dist/2020.js")));
197
+ } else if (isDraft2019) {
198
+ ajvModule = await Promise.resolve().then(() => _interopRequireWildcard(require("ajv/dist/2019.js")));
199
+ } else {
200
+ ajvModule = await Promise.resolve().then(() => _interopRequireWildcard(require("ajv")));
201
+ }
192
202
  } catch (e2) {
193
203
  throw new Error(
194
204
  'The "ajv" package is required to validate JSON Schema tool parameters. Install it with: npm install ajv'
@@ -204,14 +214,16 @@ async function compileSchema(schema) {
204
214
  addFormats(ajv);
205
215
  } catch (e3) {
206
216
  }
207
- return ajv.compile(schema);
217
+ return ajv.compile(
218
+ isDraft2020 || isDraft2019 ? { ...schema, $schema: dialect } : schema
219
+ );
208
220
  }
209
221
  function toIssue(error) {
210
222
  const path = error.instancePath.split("/").slice(1).map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~")).map((segment) => {
211
223
  const index = Number(segment);
212
224
  return /^(?:0|[1-9]\d*)$/.test(segment) && Number.isSafeInteger(index) ? index : segment;
213
225
  });
214
- const missingProperty = _optionalChain([error, 'access', _2 => _2.params, 'optionalAccess', _3 => _3.missingProperty]);
226
+ const missingProperty = _optionalChain([error, 'access', _7 => _7.params, 'optionalAccess', _8 => _8.missingProperty]);
215
227
  if (error.keyword === "required" && typeof missingProperty === "string") {
216
228
  path.push(missingProperty);
217
229
  }
@@ -246,7 +258,7 @@ var imageContent = async (input) => {
246
258
  signal: AbortSignal.timeout(timeoutMs)
247
259
  });
248
260
  if (!response.ok) {
249
- await _chunkC7TBI7A5cjs.cancelResponseBody.call(void 0, response);
261
+ await _chunk4OWHPJELcjs.cancelResponseBody.call(void 0, response);
250
262
  throw new Error(
251
263
  `Server responded with status: ${response.status} - ${response.statusText}`
252
264
  );
@@ -279,7 +291,7 @@ var imageContent = async (input) => {
279
291
  }
280
292
  const { fileTypeFromBuffer } = await Promise.resolve().then(() => _interopRequireWildcard(require("file-type")));
281
293
  const fileType = await fileTypeFromBuffer(rawData);
282
- const mimeType = (!fileType || fileType.mime === "application/xml") && isSvg(rawData) ? "image/svg+xml" : _optionalChain([fileType, 'optionalAccess', _4 => _4.mime]);
294
+ const mimeType = (!fileType || fileType.mime === "application/xml") && isSvg(rawData) ? "image/svg+xml" : _optionalChain([fileType, 'optionalAccess', _9 => _9.mime]);
283
295
  if (!mimeType || !mimeType.startsWith("image/")) {
284
296
  console.warn(
285
297
  `Warning: Content may not be a valid image. Detected MIME: ${mimeType || "unknown"}`
@@ -308,11 +320,11 @@ var AUDIO_CONTAINER_TYPES = /* @__PURE__ */ new Map([
308
320
  ["video/webm", "audio/webm"]
309
321
  ]);
310
322
  var resolveAudioMimeType = (detected, declared) => {
311
- if (_optionalChain([detected, 'optionalAccess', _5 => _5.startsWith, 'call', _6 => _6("audio/")])) {
323
+ if (_optionalChain([detected, 'optionalAccess', _10 => _10.startsWith, 'call', _11 => _11("audio/")])) {
312
324
  return detected;
313
325
  }
314
- const declaredMime = _optionalChain([declared, 'optionalAccess', _7 => _7.split, 'call', _8 => _8(";", 1), 'access', _9 => _9[0], 'access', _10 => _10.trim, 'call', _11 => _11(), 'access', _12 => _12.toLowerCase, 'call', _13 => _13()]);
315
- if (_optionalChain([declaredMime, 'optionalAccess', _14 => _14.startsWith, 'call', _15 => _15("audio/")])) {
326
+ const declaredMime = _optionalChain([declared, 'optionalAccess', _12 => _12.split, 'call', _13 => _13(";", 1), 'access', _14 => _14[0], 'access', _15 => _15.trim, 'call', _16 => _16(), 'access', _17 => _17.toLowerCase, 'call', _18 => _18()]);
327
+ if (_optionalChain([declaredMime, 'optionalAccess', _19 => _19.startsWith, 'call', _20 => _20("audio/")])) {
316
328
  return declaredMime;
317
329
  }
318
330
  return _nullishCoalesce((detected && AUDIO_CONTAINER_TYPES.get(detected)), () => ( detected));
@@ -328,7 +340,7 @@ var audioContent = async (input) => {
328
340
  signal: AbortSignal.timeout(timeoutMs)
329
341
  });
330
342
  if (!response.ok) {
331
- await _chunkC7TBI7A5cjs.cancelResponseBody.call(void 0, response);
343
+ await _chunk4OWHPJELcjs.cancelResponseBody.call(void 0, response);
332
344
  throw new Error(
333
345
  `Server responded with status: ${response.status} - ${response.statusText}`
334
346
  );
@@ -362,7 +374,7 @@ var audioContent = async (input) => {
362
374
  }
363
375
  const { fileTypeFromBuffer } = await Promise.resolve().then(() => _interopRequireWildcard(require("file-type")));
364
376
  const detected = await fileTypeFromBuffer(rawData);
365
- const mimeType = resolveAudioMimeType(_optionalChain([detected, 'optionalAccess', _16 => _16.mime]), declaredMimeType);
377
+ const mimeType = resolveAudioMimeType(_optionalChain([detected, 'optionalAccess', _21 => _21.mime]), declaredMimeType);
366
378
  if (!mimeType || !mimeType.startsWith("audio/")) {
367
379
  console.warn(
368
380
  `Warning: Content may not be a valid audio file. Detected MIME: ${mimeType || "unknown"}`
@@ -402,7 +414,7 @@ var UserError = class extends UnexpectedStateError {
402
414
  };
403
415
  function assertStandardSchema(toolName, schemaName, schema) {
404
416
  const standard = schema["~standard"];
405
- if (typeof _optionalChain([standard, 'optionalAccess', _17 => _17.validate]) === "function") {
417
+ if (typeof _optionalChain([standard, 'optionalAccess', _22 => _22.validate]) === "function") {
406
418
  return;
407
419
  }
408
420
  throw new UserError(
@@ -487,6 +499,28 @@ var ServerState = /* @__PURE__ */ ((ServerState2) => {
487
499
  })(ServerState || {});
488
500
  var FastMCPSessionEventEmitter = class extends FastMCPSessionEventEmitterBase {
489
501
  };
502
+ var lazyRequestBody = (req) => {
503
+ let iterator;
504
+ return new ReadableStream(
505
+ {
506
+ async cancel(reason) {
507
+ await _optionalChain([iterator, 'optionalAccess', _23 => _23.return, 'optionalCall', _24 => _24(reason)]);
508
+ },
509
+ async pull(controller) {
510
+ iterator ??= req[Symbol.asyncIterator]();
511
+ const { done, value } = await iterator.next();
512
+ if (done) {
513
+ controller.close();
514
+ return;
515
+ }
516
+ controller.enqueue(
517
+ typeof value === "string" ? Buffer.from(value) : new Uint8Array(value)
518
+ );
519
+ }
520
+ },
521
+ { highWaterMark: 0 }
522
+ );
523
+ };
490
524
  var FastMCPSession = class extends FastMCPSessionEventEmitter {
491
525
  get clientCapabilities() {
492
526
  return _nullishCoalesce(this.#clientCapabilities, () => ( null));
@@ -519,7 +553,7 @@ var FastMCPSession = class extends FastMCPSessionEventEmitter {
519
553
  */
520
554
  get sessionId() {
521
555
  if (this.#sessionId === void 0) {
522
- const transportSessionId = _optionalChain([this, 'access', _18 => _18.#server, 'access', _19 => _19.transport, 'optionalAccess', _20 => _20.sessionId]);
556
+ const transportSessionId = _optionalChain([this, 'access', _25 => _25.#server, 'access', _26 => _26.transport, 'optionalAccess', _27 => _27.sessionId]);
523
557
  if (typeof transportSessionId === "string") {
524
558
  this.#sessionId = transportSessionId;
525
559
  }
@@ -910,7 +944,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
910
944
  },
911
945
  elicit: this.#createElicit(requestId),
912
946
  log: this.#createLog(sendNotification),
913
- requestId: typeof _optionalChain([meta, 'optionalAccess', _21 => _21.requestId]) === "string" ? meta.requestId : void 0,
947
+ requestId: typeof _optionalChain([meta, 'optionalAccess', _28 => _28.requestId]) === "string" ? meta.requestId : void 0,
914
948
  session: this.#auth,
915
949
  sessionId: this.sessionId
916
950
  };
@@ -932,8 +966,12 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
932
966
  };
933
967
  }
934
968
  #formatSchemaIssues(issues) {
935
- return _optionalChain([this, 'access', _22 => _22.#utils, 'optionalAccess', _23 => _23.formatInvalidParamsErrorMessage]) ? this.#utils.formatInvalidParamsErrorMessage(issues) : issues.map((issue) => {
936
- const path = _optionalChain([issue, 'access', _24 => _24.path, 'optionalAccess', _25 => _25.join, 'call', _26 => _26(".")]) || "root";
969
+ return _optionalChain([this, 'access', _29 => _29.#utils, 'optionalAccess', _30 => _30.formatInvalidParamsErrorMessage]) ? this.#utils.formatInvalidParamsErrorMessage(issues) : issues.map((issue) => {
970
+ const path = _optionalChain([issue, 'access', _31 => _31.path, 'optionalAccess', _32 => _32.map, 'call', _33 => _33(
971
+ (segment) => String(
972
+ typeof segment === "object" && segment !== null ? segment.key : segment
973
+ )
974
+ ), 'access', _34 => _34.join, 'call', _35 => _35(".")]) || "root";
937
975
  return `${path}: ${issue.message}`;
938
976
  }).join(", ");
939
977
  }
@@ -955,7 +993,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
955
993
  * is bounded and retried, and the result is announced with `rootsChanged`.
956
994
  */
957
995
  async #loadRoots(streamableHttp) {
958
- if (_optionalChain([this, 'access', _27 => _27.#rootsConfig, 'optionalAccess', _28 => _28.enabled]) === false || !_optionalChain([this, 'access', _29 => _29.#clientCapabilities, 'optionalAccess', _30 => _30.roots, 'optionalAccess', _31 => _31.listChanged]) || typeof this.#server.listRoots !== "function") {
996
+ if (_optionalChain([this, 'access', _36 => _36.#rootsConfig, 'optionalAccess', _37 => _37.enabled]) === false || !_optionalChain([this, 'access', _38 => _38.#clientCapabilities, 'optionalAccess', _39 => _39.roots, 'optionalAccess', _40 => _40.listChanged]) || typeof this.#server.listRoots !== "function") {
959
997
  return;
960
998
  }
961
999
  const maxAttempts = streamableHttp ? 5 : 1;
@@ -965,7 +1003,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
965
1003
  void 0,
966
1004
  streamableHttp ? { timeout: 1e3 } : void 0
967
1005
  );
968
- this.#roots = _optionalChain([roots, 'optionalAccess', _32 => _32.roots]) || [];
1006
+ this.#roots = _optionalChain([roots, 'optionalAccess', _41 => _41.roots]) || [];
969
1007
  if (streamableHttp) {
970
1008
  this.emit("rootsChanged", { roots: this.#roots });
971
1009
  }
@@ -1103,7 +1141,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1103
1141
  */
1104
1142
  #startStreamKeepalive(extra, toolName) {
1105
1143
  const config = this.#streamKeepaliveConfig;
1106
- if (!_optionalChain([config, 'optionalAccess', _33 => _33.enabled])) {
1144
+ if (!_optionalChain([config, 'optionalAccess', _42 => _42.enabled]) || _optionalChain([extra, 'access', _43 => _43.signal, 'optionalAccess', _44 => _44.aborted])) {
1107
1145
  return () => {
1108
1146
  };
1109
1147
  }
@@ -1123,9 +1161,12 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1123
1161
  );
1124
1162
  });
1125
1163
  }, intervalMs);
1126
- _optionalChain([timer, 'access', _34 => _34.unref, 'optionalCall', _35 => _35()]);
1127
- const stop = () => clearInterval(timer);
1128
- _optionalChain([extra, 'access', _36 => _36.signal, 'optionalAccess', _37 => _37.addEventListener, 'call', _38 => _38("abort", stop, { once: true })]);
1164
+ _optionalChain([timer, 'access', _45 => _45.unref, 'optionalCall', _46 => _46()]);
1165
+ const stop = () => {
1166
+ clearInterval(timer);
1167
+ _optionalChain([extra, 'access', _47 => _47.signal, 'optionalAccess', _48 => _48.removeEventListener, 'call', _49 => _49("abort", stop)]);
1168
+ };
1169
+ _optionalChain([extra, 'access', _50 => _50.signal, 'optionalAccess', _51 => _51.addEventListener, 'call', _52 => _52("abort", stop, { once: true })]);
1129
1170
  return stop;
1130
1171
  }
1131
1172
  async #validateStructuredContent(tool, value, toolName) {
@@ -1345,7 +1386,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1345
1386
  _nullishCoalesce(args, () => ( {})),
1346
1387
  this.#auth,
1347
1388
  this.#createLoadContext(
1348
- _optionalChain([request, 'access', _39 => _39.params, 'optionalAccess', _40 => _40._meta]),
1389
+ _optionalChain([request, 'access', _53 => _53.params, 'optionalAccess', _54 => _54._meta]),
1349
1390
  extra.sendNotification,
1350
1391
  extra.requestId
1351
1392
  )
@@ -1415,7 +1456,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1415
1456
  match,
1416
1457
  this.#auth,
1417
1458
  this.#createLoadContext(
1418
- _optionalChain([request, 'access', _41 => _41.params, 'optionalAccess', _42 => _42._meta]),
1459
+ _optionalChain([request, 'access', _55 => _55.params, 'optionalAccess', _56 => _56._meta]),
1419
1460
  extra.sendNotification,
1420
1461
  extra.requestId
1421
1462
  )
@@ -1445,7 +1486,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1445
1486
  maybeArrayResult = await resource.load(
1446
1487
  this.#auth,
1447
1488
  this.#createLoadContext(
1448
- _optionalChain([request, 'access', _43 => _43.params, 'optionalAccess', _44 => _44._meta]),
1489
+ _optionalChain([request, 'access', _57 => _57.params, 'optionalAccess', _58 => _58._meta]),
1449
1490
  extra.sendNotification,
1450
1491
  extra.requestId
1451
1492
  )
@@ -1511,7 +1552,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1511
1552
  );
1512
1553
  }
1513
1554
  setupRootsHandlers() {
1514
- if (_optionalChain([this, 'access', _45 => _45.#rootsConfig, 'optionalAccess', _46 => _46.enabled]) === false) {
1555
+ if (_optionalChain([this, 'access', _59 => _59.#rootsConfig, 'optionalAccess', _60 => _60.enabled]) === false) {
1515
1556
  this.#logger.debug(
1516
1557
  "[FastMCP debug] roots capability explicitly disabled via config"
1517
1558
  );
@@ -1562,8 +1603,8 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1562
1603
  return {
1563
1604
  annotations: tool.annotations,
1564
1605
  description: tool.description,
1565
- inputSchema: tool.parameters ? _chunkMPFPOZ2Hcjs.strictInputSchema.call(void 0,
1566
- tool.parameters["~standard"].vendor === "zod" && "_zod" in tool.parameters ? _chunkMPFPOZ2Hcjs.zodInputSchema.call(void 0, tool.parameters, "draft-7") : await _xsschema.toJsonSchema.call(void 0, tool.parameters)
1606
+ inputSchema: tool.parameters ? _chunk6TDYSPLCcjs.strictInputSchema.call(void 0,
1607
+ tool.parameters["~standard"].vendor === "zod" && "_zod" in tool.parameters ? _chunk6TDYSPLCcjs.zodInputSchema.call(void 0, tool.parameters, "draft-7") : await _xsschema.toJsonSchema.call(void 0, tool.parameters)
1567
1608
  ) : {
1568
1609
  additionalProperties: false,
1569
1610
  properties: {},
@@ -1571,8 +1612,8 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1571
1612
  },
1572
1613
  name: tool.name,
1573
1614
  ...tool.outputSchema && {
1574
- outputSchema: await _xsschema.toJsonSchema.call(void 0,
1575
- tool.outputSchema
1615
+ outputSchema: _chunk6TDYSPLCcjs.objectRootSchema.call(void 0,
1616
+ await _xsschema.toJsonSchema.call(void 0, tool.outputSchema)
1576
1617
  )
1577
1618
  },
1578
1619
  // Pass through _meta for MCP ext-apps UI support (issue #229)
@@ -1608,15 +1649,35 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1608
1649
  }
1609
1650
  args = parsed.value;
1610
1651
  }
1611
- const progressToken = _optionalChain([request, 'access', _47 => _47.params, 'optionalAccess', _48 => _48._meta, 'optionalAccess', _49 => _49.progressToken]);
1652
+ const progressToken = _optionalChain([request, 'access', _61 => _61.params, 'optionalAccess', _62 => _62._meta, 'optionalAccess', _63 => _63.progressToken]);
1612
1653
  let result;
1654
+ const timeoutAbort = new AbortController();
1655
+ const signal = AbortSignal.any([
1656
+ timeoutAbort.signal,
1657
+ this.#abortController.signal,
1658
+ // Only ever aborted for an explicit `notifications/cancelled`; the
1659
+ // session signal above is what covers a client that simply left.
1660
+ ...extra.signal ? [extra.signal] : []
1661
+ ]);
1662
+ const sendNotification = async (notification) => {
1663
+ if (signal.aborted) {
1664
+ return;
1665
+ }
1666
+ try {
1667
+ await extra.sendNotification(notification);
1668
+ } catch (error) {
1669
+ if (!signal.aborted) {
1670
+ throw error;
1671
+ }
1672
+ }
1673
+ };
1613
1674
  try {
1614
1675
  const reportProgress = async (progress) => {
1615
1676
  if (progressToken === void 0) {
1616
1677
  return;
1617
1678
  }
1618
1679
  try {
1619
- await extra.sendNotification({
1680
+ await sendNotification({
1620
1681
  method: "notifications/progress",
1621
1682
  params: {
1622
1683
  ...progress,
@@ -1633,11 +1694,11 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1633
1694
  );
1634
1695
  }
1635
1696
  };
1636
- const log = this.#createLog(extra.sendNotification);
1697
+ const log = this.#createLog(sendNotification);
1637
1698
  const streamContent = async (content) => {
1638
1699
  const contentArray = Array.isArray(content) ? content : [content];
1639
1700
  try {
1640
- await extra.sendNotification({
1701
+ await sendNotification({
1641
1702
  method: "notifications/tool/streamContent",
1642
1703
  params: {
1643
1704
  content: contentArray,
@@ -1660,14 +1721,6 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1660
1721
  toolName: request.params.name
1661
1722
  });
1662
1723
  }
1663
- const timeoutAbort = new AbortController();
1664
- const signal = AbortSignal.any([
1665
- timeoutAbort.signal,
1666
- this.#abortController.signal,
1667
- // Only ever aborted for an explicit `notifications/cancelled`; the
1668
- // session signal above is what covers a client that simply left.
1669
- ...extra.signal ? [extra.signal] : []
1670
- ]);
1671
1724
  const executeToolPromise = Promise.resolve(
1672
1725
  tool.execute(args, {
1673
1726
  client: {
@@ -1676,7 +1729,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1676
1729
  elicit: this.#createElicit(extra.requestId),
1677
1730
  log,
1678
1731
  reportProgress,
1679
- requestId: typeof _optionalChain([request, 'access', _50 => _50.params, 'optionalAccess', _51 => _51._meta, 'optionalAccess', _52 => _52.requestId]) === "string" ? request.params._meta.requestId : void 0,
1732
+ requestId: typeof _optionalChain([request, 'access', _64 => _64.params, 'optionalAccess', _65 => _65._meta, 'optionalAccess', _66 => _66.requestId]) === "string" ? request.params._meta.requestId : void 0,
1680
1733
  session: this.#auth,
1681
1734
  sessionId: this.sessionId,
1682
1735
  signal,
@@ -1684,25 +1737,37 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1684
1737
  })
1685
1738
  );
1686
1739
  const stopStreamKeepalive = this.#startStreamKeepalive(
1687
- extra,
1740
+ { sendNotification, signal },
1688
1741
  request.params.name
1689
1742
  );
1690
- const maybeStringResult = await (tool.timeoutMs ? Promise.race([
1691
- executeToolPromise,
1692
- new Promise((_, reject) => {
1693
- const timeoutId = setTimeout(() => {
1694
- const timedOut = new UserError(
1743
+ let timeoutId;
1744
+ let stopWaitingForAbort = () => {
1745
+ };
1746
+ const aborted = new Promise((_, reject) => {
1747
+ const onAbort = () => reject(signal.reason);
1748
+ stopWaitingForAbort = () => signal.removeEventListener("abort", onAbort);
1749
+ signal.addEventListener("abort", onAbort, { once: true });
1750
+ if (signal.aborted) {
1751
+ onAbort();
1752
+ }
1753
+ });
1754
+ if (tool.timeoutMs && !signal.aborted) {
1755
+ timeoutId = setTimeout(() => {
1756
+ timeoutAbort.abort(
1757
+ new UserError(
1695
1758
  `Tool '${request.params.name}' timed out after ${tool.timeoutMs}ms. Consider increasing timeoutMs or optimizing the tool implementation.`
1696
- );
1697
- timeoutAbort.abort(timedOut);
1698
- reject(timedOut);
1699
- }, tool.timeoutMs);
1700
- executeToolPromise.then(
1701
- () => clearTimeout(timeoutId),
1702
- () => clearTimeout(timeoutId)
1759
+ )
1703
1760
  );
1704
- })
1705
- ]) : executeToolPromise).finally(stopStreamKeepalive);
1761
+ }, tool.timeoutMs);
1762
+ }
1763
+ const maybeStringResult = await Promise.race([
1764
+ executeToolPromise,
1765
+ aborted
1766
+ ]).finally(() => {
1767
+ clearTimeout(timeoutId);
1768
+ stopWaitingForAbort();
1769
+ stopStreamKeepalive();
1770
+ });
1706
1771
  await _promises3.setTimeout.call(void 0, 1);
1707
1772
  if (maybeStringResult === void 0 || maybeStringResult === null) {
1708
1773
  result = ContentResultZodSchema.parse({
@@ -1743,12 +1808,29 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1743
1808
  } else {
1744
1809
  result = ContentResultZodSchema.parse(maybeStringResult);
1745
1810
  }
1811
+ if (tool.outputSchema && result.structuredContent === void 0 && !result.isError) {
1812
+ throw new UserError(
1813
+ `Tool '${request.params.name}' returned no structured content. Please return a value that matches the tool's outputSchema.`
1814
+ );
1815
+ }
1746
1816
  } catch (error) {
1747
1817
  if (error instanceof UserError) {
1818
+ let structuredContent = error.extras;
1819
+ if (structuredContent && tool.outputSchema) {
1820
+ try {
1821
+ structuredContent = await this.#validateStructuredContent(
1822
+ tool,
1823
+ structuredContent,
1824
+ request.params.name
1825
+ );
1826
+ } catch (e5) {
1827
+ structuredContent = void 0;
1828
+ }
1829
+ }
1748
1830
  return {
1749
1831
  content: [{ text: error.message, type: "text" }],
1750
1832
  isError: true,
1751
- ...error.extras ? { structuredContent: error.extras } : {}
1833
+ ...structuredContent ? { structuredContent } : {}
1752
1834
  };
1753
1835
  }
1754
1836
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -1818,14 +1900,14 @@ function normalizePath(path) {
1818
1900
  return path.startsWith("/") ? path : `/${path}`;
1819
1901
  }
1820
1902
  function parseBasicAuthHeader(authHeader) {
1821
- const basicMatch = _optionalChain([authHeader, 'optionalAccess', _53 => _53.match, 'call', _54 => _54(/^Basic\s+(.+)$/)]);
1903
+ const basicMatch = _optionalChain([authHeader, 'optionalAccess', _67 => _67.match, 'call', _68 => _68(/^Basic\s+(.+)$/)]);
1822
1904
  if (!basicMatch) return null;
1823
1905
  try {
1824
1906
  const credentials = Buffer.from(basicMatch[1], "base64").toString("utf-8");
1825
1907
  const credMatch = credentials.match(/^([^:]+):(.*)$/);
1826
1908
  if (!credMatch) return null;
1827
1909
  return { clientId: credMatch[1], clientSecret: credMatch[2] };
1828
- } catch (e5) {
1910
+ } catch (e6) {
1829
1911
  return null;
1830
1912
  }
1831
1913
  }
@@ -1862,7 +1944,7 @@ function protectedResourceMetadataUrl(resource) {
1862
1944
  let url;
1863
1945
  try {
1864
1946
  url = new URL(resource);
1865
- } catch (e6) {
1947
+ } catch (e7) {
1866
1948
  return `${resource}/.well-known/oauth-protected-resource`;
1867
1949
  }
1868
1950
  const path = url.pathname === "/" ? "" : url.pathname;
@@ -1964,7 +2046,9 @@ var FastMCP = class extends FastMCPEventEmitter {
1964
2046
  * Adds a resource to the server.
1965
2047
  */
1966
2048
  addResource(resource) {
1967
- this.#resources = this.#resources.filter((r) => r.name !== resource.name);
2049
+ this.#resources = this.#resources.filter(
2050
+ (r) => r.name !== resource.name && r.uri !== resource.uri
2051
+ );
1968
2052
  this.#resources.push(resource);
1969
2053
  if (this.#serverState === "running" /* Running */) {
1970
2054
  this.#resourcesListChanged(this.#resources);
@@ -1974,13 +2058,12 @@ var FastMCP = class extends FastMCPEventEmitter {
1974
2058
  * Adds resources to the server.
1975
2059
  */
1976
2060
  addResources(resources) {
1977
- const newResourceNames = new Set(
1978
- resources.map((resource) => resource.name)
1979
- );
1980
- this.#resources = this.#resources.filter(
1981
- (r) => !newResourceNames.has(r.name)
1982
- );
1983
- this.#resources.push(...resources);
2061
+ for (const resource of resources) {
2062
+ this.#resources = this.#resources.filter(
2063
+ (r) => r.name !== resource.name && r.uri !== resource.uri
2064
+ );
2065
+ this.#resources.push(resource);
2066
+ }
1984
2067
  if (this.#serverState === "running" /* Running */) {
1985
2068
  this.#resourcesListChanged(this.#resources);
1986
2069
  }
@@ -2001,13 +2084,12 @@ var FastMCP = class extends FastMCPEventEmitter {
2001
2084
  * Adds resource templates to the server.
2002
2085
  */
2003
2086
  addResourceTemplates(resources) {
2004
- const newResourceTemplateNames = new Set(
2005
- resources.map((resource) => resource.name)
2006
- );
2007
- this.#resourcesTemplates = this.#resourcesTemplates.filter(
2008
- (t) => !newResourceTemplateNames.has(t.name)
2009
- );
2010
- this.#resourcesTemplates.push(...resources);
2087
+ for (const resource of resources) {
2088
+ this.#resourcesTemplates = this.#resourcesTemplates.filter(
2089
+ (template) => template.name !== resource.name
2090
+ );
2091
+ this.#resourcesTemplates.push(resource);
2092
+ }
2011
2093
  if (this.#serverState === "running" /* Running */) {
2012
2094
  this.#resourceTemplatesListChanged(this.#resourcesTemplates);
2013
2095
  }
@@ -2028,9 +2110,12 @@ var FastMCP = class extends FastMCPEventEmitter {
2028
2110
  */
2029
2111
  addTools(tools) {
2030
2112
  tools.forEach(assertToolSchemas);
2031
- const newToolNames = new Set(tools.map((tool) => tool.name));
2032
- this.#tools = this.#tools.filter((t) => !newToolNames.has(t.name));
2033
- this.#tools.push(...tools);
2113
+ const toolsByName = new Map(this.#tools.map((tool) => [tool.name, tool]));
2114
+ for (const tool of tools) {
2115
+ toolsByName.delete(tool.name);
2116
+ toolsByName.set(tool.name, tool);
2117
+ }
2118
+ this.#tools = Array.from(toolsByName.values());
2034
2119
  if (this.#serverState === "running" /* Running */) {
2035
2120
  this.#toolsListChanged(this.#tools);
2036
2121
  }
@@ -2261,6 +2346,13 @@ var FastMCP = class extends FastMCPEventEmitter {
2261
2346
  async start(options) {
2262
2347
  const config = this.#parseRuntimeConfig(options);
2263
2348
  if (config.transportType === "stdio") {
2349
+ const logger = _nullishCoalesce(this.#options.logger, () => ( {
2350
+ debug: (...args) => console.error(...args),
2351
+ error: (...args) => console.error(...args),
2352
+ info: (...args) => console.error(...args),
2353
+ log: (...args) => console.error(...args),
2354
+ warn: (...args) => console.warn(...args)
2355
+ }));
2264
2356
  const transport = new (0, _stdiojs.StdioServerTransport)();
2265
2357
  let auth;
2266
2358
  const authRequired = this.#authenticate !== void 0;
@@ -2287,7 +2379,7 @@ var FastMCP = class extends FastMCPEventEmitter {
2287
2379
  hasTools: this.#tools.length > 0,
2288
2380
  icons: this.#options.icons,
2289
2381
  instructions: this.#options.instructions,
2290
- logger: this.#logger,
2382
+ logger,
2291
2383
  name: this.#options.name,
2292
2384
  onToolCall: this.#options.onToolCall,
2293
2385
  ping: this.#options.ping,
@@ -2332,6 +2424,9 @@ var FastMCP = class extends FastMCPEventEmitter {
2332
2424
  this.#serverState = "running" /* Running */;
2333
2425
  }
2334
2426
  } else if (config.transportType === "httpStream") {
2427
+ if (this.#httpStreamServer) {
2428
+ throw new Error("HTTP server is already running");
2429
+ }
2335
2430
  const httpConfig = config.httpStream;
2336
2431
  const protocol = httpConfig.sslCert || httpConfig.sslKey ? "https" : "http";
2337
2432
  const streamEndpoint = joinPaths(
@@ -2461,6 +2556,7 @@ var FastMCP = class extends FastMCPEventEmitter {
2461
2556
  );
2462
2557
  if (this.#httpStreamServer) {
2463
2558
  await this.#httpStreamServer.close();
2559
+ this.#httpStreamServer = null;
2464
2560
  }
2465
2561
  this.#serverState = "stopped" /* Stopped */;
2466
2562
  }
@@ -2474,9 +2570,9 @@ var FastMCP = class extends FastMCPEventEmitter {
2474
2570
  const originalOnClose = transport.onclose;
2475
2571
  transport.onclose = () => {
2476
2572
  closed = true;
2477
- _optionalChain([onClose, 'optionalCall', _55 => _55()]);
2573
+ _optionalChain([onClose, 'optionalCall', _69 => _69()]);
2478
2574
  this.#removeSession(session);
2479
- _optionalChain([originalOnClose, 'optionalCall', _56 => _56()]);
2575
+ _optionalChain([originalOnClose, 'optionalCall', _70 => _70()]);
2480
2576
  };
2481
2577
  await session.connect(transport);
2482
2578
  if (closed) {
@@ -2541,7 +2637,7 @@ var FastMCP = class extends FastMCPEventEmitter {
2541
2637
  */
2542
2638
  #createUnauthorizedResponse(message) {
2543
2639
  const oauth = this.#options.oauth;
2544
- const resource = _optionalChain([oauth, 'optionalAccess', _57 => _57.enabled]) ? _optionalChain([oauth, 'access', _58 => _58.protectedResource, 'optionalAccess', _59 => _59.resource]) : void 0;
2640
+ const resource = _optionalChain([oauth, 'optionalAccess', _71 => _71.enabled]) ? _optionalChain([oauth, 'access', _72 => _72.protectedResource, 'optionalAccess', _73 => _73.resource]) : void 0;
2545
2641
  const wwwAuthenticateParts = [
2546
2642
  'error="invalid_token"',
2547
2643
  `error_description="${message.replace(/"/g, '\\"')}"`
@@ -2680,7 +2776,7 @@ var FastMCP = class extends FastMCPEventEmitter {
2680
2776
  }
2681
2777
  }
2682
2778
  const oauthConfig = this.#options.oauth;
2683
- if (_optionalChain([oauthConfig, 'optionalAccess', _60 => _60.enabled]) && req.method === "GET") {
2779
+ if (_optionalChain([oauthConfig, 'optionalAccess', _74 => _74.enabled]) && req.method === "GET") {
2684
2780
  const url2 = new URL(req.url || "", `http://${host}`);
2685
2781
  const authorizationServerMetadataPath = joinPaths(
2686
2782
  "",
@@ -2714,8 +2810,8 @@ var FastMCP = class extends FastMCPEventEmitter {
2714
2810
  }
2715
2811
  }
2716
2812
  }
2717
- const oauthProxy = _optionalChain([oauthConfig, 'optionalAccess', _61 => _61.proxy]);
2718
- if (oauthProxy && _optionalChain([oauthConfig, 'optionalAccess', _62 => _62.enabled])) {
2813
+ const oauthProxy = _optionalChain([oauthConfig, 'optionalAccess', _75 => _75.proxy]);
2814
+ if (oauthProxy && _optionalChain([oauthConfig, 'optionalAccess', _76 => _76.enabled])) {
2719
2815
  const url2 = new URL(req.url || "", `http://${host}`);
2720
2816
  const oauthPath = basePathRelativePath;
2721
2817
  try {
@@ -2768,7 +2864,7 @@ var FastMCP = class extends FastMCPEventEmitter {
2768
2864
  const statusCode = error.statusCode || 400;
2769
2865
  res.writeHead(statusCode, OAUTH_CREDENTIAL_RESPONSE_HEADERS).end(
2770
2866
  JSON.stringify(
2771
- _optionalChain([error, 'access', _63 => _63.toJSON, 'optionalCall', _64 => _64()]) || {
2867
+ _optionalChain([error, 'access', _77 => _77.toJSON, 'optionalCall', _78 => _78()]) || {
2772
2868
  error: "invalid_request"
2773
2869
  }
2774
2870
  )
@@ -2795,7 +2891,7 @@ var FastMCP = class extends FastMCPEventEmitter {
2795
2891
  } catch (error) {
2796
2892
  res.writeHead(400, { "Content-Type": "application/json" }).end(
2797
2893
  JSON.stringify(
2798
- _optionalChain([error, 'access', _65 => _65.toJSON, 'optionalCall', _66 => _66()]) || {
2894
+ _optionalChain([error, 'access', _79 => _79.toJSON, 'optionalCall', _80 => _80()]) || {
2799
2895
  error: "invalid_request"
2800
2896
  }
2801
2897
  )
@@ -2817,7 +2913,7 @@ var FastMCP = class extends FastMCPEventEmitter {
2817
2913
  } catch (error) {
2818
2914
  res.writeHead(400, { "Content-Type": "application/json" }).end(
2819
2915
  JSON.stringify(
2820
- _optionalChain([error, 'access', _67 => _67.toJSON, 'optionalCall', _68 => _68()]) || {
2916
+ _optionalChain([error, 'access', _81 => _81.toJSON, 'optionalCall', _82 => _82()]) || {
2821
2917
  error: "server_error"
2822
2918
  }
2823
2919
  )
@@ -2886,7 +2982,7 @@ var FastMCP = class extends FastMCPEventEmitter {
2886
2982
  } catch (error) {
2887
2983
  res.writeHead(400, { "Content-Type": "application/json" }).end(
2888
2984
  JSON.stringify(
2889
- _optionalChain([error, 'access', _69 => _69.toJSON, 'optionalCall', _70 => _70()]) || {
2985
+ _optionalChain([error, 'access', _83 => _83.toJSON, 'optionalCall', _84 => _84()]) || {
2890
2986
  error: "server_error"
2891
2987
  }
2892
2988
  )
@@ -2944,8 +3040,8 @@ var FastMCP = class extends FastMCPEventEmitter {
2944
3040
  const basicAuth = parseBasicAuthHeader(
2945
3041
  req.headers.authorization
2946
3042
  );
2947
- const clientId = _optionalChain([basicAuth, 'optionalAccess', _71 => _71.clientId]) || params.get("client_id") || "";
2948
- const clientSecret = _nullishCoalesce(_nullishCoalesce(_optionalChain([basicAuth, 'optionalAccess', _72 => _72.clientSecret]), () => ( params.get("client_secret"))), () => ( void 0));
3043
+ const clientId = _optionalChain([basicAuth, 'optionalAccess', _85 => _85.clientId]) || params.get("client_id") || "";
3044
+ const clientSecret = _nullishCoalesce(_nullishCoalesce(_optionalChain([basicAuth, 'optionalAccess', _86 => _86.clientSecret]), () => ( params.get("client_secret"))), () => ( void 0));
2949
3045
  let response;
2950
3046
  if (grantType === "authorization_code") {
2951
3047
  response = await oauthProxy.exchangeAuthorizationCode({
@@ -2975,7 +3071,7 @@ var FastMCP = class extends FastMCPEventEmitter {
2975
3071
  const statusCode = error.statusCode || 400;
2976
3072
  res.writeHead(statusCode, OAUTH_CREDENTIAL_RESPONSE_HEADERS).end(
2977
3073
  JSON.stringify(
2978
- _optionalChain([error, 'access', _73 => _73.toJSON, 'optionalCall', _74 => _74()]) || {
3074
+ _optionalChain([error, 'access', _87 => _87.toJSON, 'optionalCall', _88 => _88()]) || {
2979
3075
  error: "invalid_request"
2980
3076
  }
2981
3077
  )
@@ -3001,7 +3097,7 @@ var FastMCP = class extends FastMCPEventEmitter {
3001
3097
  * regardless (RFC 7235), so no config is needed just to get the header.
3002
3098
  */
3003
3099
  #httpStreamOAuthConfig() {
3004
- const resource = _optionalChain([this, 'access', _75 => _75.#options, 'access', _76 => _76.oauth, 'optionalAccess', _77 => _77.enabled]) ? _optionalChain([this, 'access', _78 => _78.#options, 'access', _79 => _79.oauth, 'access', _80 => _80.protectedResource, 'optionalAccess', _81 => _81.resource]) : void 0;
3100
+ const resource = _optionalChain([this, 'access', _89 => _89.#options, 'access', _90 => _90.oauth, 'optionalAccess', _91 => _91.enabled]) ? _optionalChain([this, 'access', _92 => _92.#options, 'access', _93 => _93.oauth, 'access', _94 => _94.protectedResource, 'optionalAccess', _95 => _95.resource]) : void 0;
3005
3101
  if (!resource) {
3006
3102
  return {};
3007
3103
  }
@@ -3067,9 +3163,7 @@ var FastMCP = class extends FastMCPEventEmitter {
3067
3163
  const hasBody = method !== "GET" && method !== "HEAD";
3068
3164
  if (hasBody) {
3069
3165
  return new Request(url.toString(), {
3070
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3071
- body: req,
3072
- // Node.js IncomingMessage is readable stream
3166
+ body: lazyRequestBody(req),
3073
3167
  duplex: "half",
3074
3168
  // Required for streaming bodies
3075
3169
  headers,
@@ -3109,24 +3203,24 @@ var FastMCP = class extends FastMCPEventEmitter {
3109
3203
  const envBasePath = process.env.FASTMCP_BASE_PATH;
3110
3204
  const envStateless = process.env.FASTMCP_STATELESS;
3111
3205
  const envHost = process.env.FASTMCP_HOST;
3112
- const transportType = _optionalChain([overrides, 'optionalAccess', _82 => _82.transportType]) || parseTransportSetting(transportArg, "--transport") || parseTransportSetting(envTransport, "FASTMCP_TRANSPORT") || "stdio";
3206
+ const transportType = _optionalChain([overrides, 'optionalAccess', _96 => _96.transportType]) || parseTransportSetting(transportArg, "--transport") || parseTransportSetting(envTransport, "FASTMCP_TRANSPORT") || "stdio";
3113
3207
  if (transportType === "httpStream") {
3114
3208
  const port = parseInt(
3115
- _optionalChain([overrides, 'optionalAccess', _83 => _83.httpStream, 'optionalAccess', _84 => _84.port, 'optionalAccess', _85 => _85.toString, 'call', _86 => _86()]) || portArg || envPort || "8080"
3209
+ _optionalChain([overrides, 'optionalAccess', _97 => _97.httpStream, 'optionalAccess', _98 => _98.port, 'optionalAccess', _99 => _99.toString, 'call', _100 => _100()]) || portArg || envPort || "8080"
3116
3210
  );
3117
- const host = _optionalChain([overrides, 'optionalAccess', _87 => _87.httpStream, 'optionalAccess', _88 => _88.host]) || hostArg || envHost || "localhost";
3118
- const endpoint = _optionalChain([overrides, 'optionalAccess', _89 => _89.httpStream, 'optionalAccess', _90 => _90.endpoint]) || endpointArg || envEndpoint || "/mcp";
3211
+ const host = _optionalChain([overrides, 'optionalAccess', _101 => _101.httpStream, 'optionalAccess', _102 => _102.host]) || hostArg || envHost || "localhost";
3212
+ const endpoint = _optionalChain([overrides, 'optionalAccess', _103 => _103.httpStream, 'optionalAccess', _104 => _104.endpoint]) || endpointArg || envEndpoint || "/mcp";
3119
3213
  const basePath = normalizeBasePath(
3120
- _optionalChain([overrides, 'optionalAccess', _91 => _91.httpStream, 'optionalAccess', _92 => _92.basePath]) || basePathArg || envBasePath
3214
+ _optionalChain([overrides, 'optionalAccess', _105 => _105.httpStream, 'optionalAccess', _106 => _106.basePath]) || basePathArg || envBasePath
3121
3215
  );
3122
- const enableJsonResponse = _optionalChain([overrides, 'optionalAccess', _93 => _93.httpStream, 'optionalAccess', _94 => _94.enableJsonResponse]) || false;
3123
- const stateless = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([overrides, 'optionalAccess', _95 => _95.httpStream, 'optionalAccess', _96 => _96.stateless]), () => ( // A bare `--stateless` means `--stateless true`.
3216
+ const enableJsonResponse = _optionalChain([overrides, 'optionalAccess', _107 => _107.httpStream, 'optionalAccess', _108 => _108.enableJsonResponse]) || false;
3217
+ const stateless = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([overrides, 'optionalAccess', _109 => _109.httpStream, 'optionalAccess', _110 => _110.stateless]), () => ( // A bare `--stateless` means `--stateless true`.
3124
3218
  (statelessArg === "" ? true : parseBooleanSetting(statelessArg, "--stateless")))), () => ( parseBooleanSetting(envStateless, "FASTMCP_STATELESS"))), () => ( false));
3125
- const cors = _optionalChain([overrides, 'optionalAccess', _97 => _97.httpStream, 'optionalAccess', _98 => _98.cors]);
3126
- const eventStore = _optionalChain([overrides, 'optionalAccess', _99 => _99.httpStream, 'optionalAccess', _100 => _100.eventStore]);
3127
- const sslCa = _optionalChain([overrides, 'optionalAccess', _101 => _101.httpStream, 'optionalAccess', _102 => _102.sslCa]);
3128
- const sslCert = _optionalChain([overrides, 'optionalAccess', _103 => _103.httpStream, 'optionalAccess', _104 => _104.sslCert]);
3129
- const sslKey = _optionalChain([overrides, 'optionalAccess', _105 => _105.httpStream, 'optionalAccess', _106 => _106.sslKey]);
3219
+ const cors = _optionalChain([overrides, 'optionalAccess', _111 => _111.httpStream, 'optionalAccess', _112 => _112.cors]);
3220
+ const eventStore = _optionalChain([overrides, 'optionalAccess', _113 => _113.httpStream, 'optionalAccess', _114 => _114.eventStore]);
3221
+ const sslCa = _optionalChain([overrides, 'optionalAccess', _115 => _115.httpStream, 'optionalAccess', _116 => _116.sslCa]);
3222
+ const sslCert = _optionalChain([overrides, 'optionalAccess', _117 => _117.httpStream, 'optionalAccess', _118 => _118.sslCert]);
3223
+ const sslKey = _optionalChain([overrides, 'optionalAccess', _119 => _119.httpStream, 'optionalAccess', _120 => _120.sslKey]);
3130
3224
  return {
3131
3225
  httpStream: {
3132
3226
  basePath,
@@ -3218,7 +3312,7 @@ var FastMCP = class extends FastMCPEventEmitter {
3218
3312
  */
3219
3313
  #useEndpointAsResource(endpoint) {
3220
3314
  const oauth = this.#options.oauth;
3221
- if (this.#providerResourceBase === void 0 || !_optionalChain([oauth, 'optionalAccess', _107 => _107.protectedResource]))
3315
+ if (this.#providerResourceBase === void 0 || !_optionalChain([oauth, 'optionalAccess', _121 => _121.protectedResource]))
3222
3316
  return;
3223
3317
  this.#options = {
3224
3318
  ...this.#options,
@@ -3247,4 +3341,4 @@ var FastMCP = class extends FastMCPEventEmitter {
3247
3341
 
3248
3342
 
3249
3343
  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;
3250
- //# sourceMappingURL=chunk-TBMRFQ6M.cjs.map
3344
+ //# sourceMappingURL=chunk-PV5VLW7R.cjs.map