@ivotoby/openapi-mcp-server 1.12.1 → 1.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +234 -1
  2. package/dist/bundle.js +1165 -415
  3. package/dist/cli.js +1163 -415
  4. package/package.json +3 -3
package/dist/cli.js CHANGED
@@ -8883,11 +8883,11 @@ var require_mime_types = __commonJS({
8883
8883
  }
8884
8884
  return exts[0];
8885
8885
  }
8886
- function lookup(path) {
8887
- if (!path || typeof path !== "string") {
8886
+ function lookup(path2) {
8887
+ if (!path2 || typeof path2 !== "string") {
8888
8888
  return false;
8889
8889
  }
8890
- var extension2 = extname2("x." + path).toLowerCase().substr(1);
8890
+ var extension2 = extname2("x." + path2).toLowerCase().substr(1);
8891
8891
  if (!extension2) {
8892
8892
  return false;
8893
8893
  }
@@ -9976,6 +9976,7 @@ var require_es_set_tostringtag = __commonJS({
9976
9976
  // node_modules/form-data/lib/populate.js
9977
9977
  var require_populate = __commonJS({
9978
9978
  "node_modules/form-data/lib/populate.js"(exports, module) {
9979
+ "use strict";
9979
9980
  module.exports = function(dst, src) {
9980
9981
  Object.keys(src).forEach(function(prop) {
9981
9982
  dst[prop] = dst[prop] || src[prop];
@@ -9988,20 +9989,21 @@ var require_populate = __commonJS({
9988
9989
  // node_modules/form-data/lib/form_data.js
9989
9990
  var require_form_data = __commonJS({
9990
9991
  "node_modules/form-data/lib/form_data.js"(exports, module) {
9992
+ "use strict";
9991
9993
  var CombinedStream = require_combined_stream();
9992
9994
  var util3 = __require("util");
9993
- var path = __require("path");
9994
- var http3 = __require("http");
9995
+ var path2 = __require("path");
9996
+ var http4 = __require("http");
9995
9997
  var https2 = __require("https");
9996
9998
  var parseUrl = __require("url").parse;
9997
- var fs = __require("fs");
9999
+ var fs2 = __require("fs");
9998
10000
  var Stream = __require("stream").Stream;
10001
+ var crypto3 = __require("crypto");
9999
10002
  var mime = require_mime_types();
10000
10003
  var asynckit = require_asynckit();
10001
10004
  var setToStringTag = require_es_set_tostringtag();
10005
+ var hasOwn = require_hasown();
10002
10006
  var populate = require_populate();
10003
- module.exports = FormData3;
10004
- util3.inherits(FormData3, CombinedStream);
10005
10007
  function FormData3(options) {
10006
10008
  if (!(this instanceof FormData3)) {
10007
10009
  return new FormData3(options);
@@ -10015,16 +10017,17 @@ var require_form_data = __commonJS({
10015
10017
  this[option] = options[option];
10016
10018
  }
10017
10019
  }
10020
+ util3.inherits(FormData3, CombinedStream);
10018
10021
  FormData3.LINE_BREAK = "\r\n";
10019
10022
  FormData3.DEFAULT_CONTENT_TYPE = "application/octet-stream";
10020
10023
  FormData3.prototype.append = function(field, value, options) {
10021
10024
  options = options || {};
10022
- if (typeof options == "string") {
10025
+ if (typeof options === "string") {
10023
10026
  options = { filename: options };
10024
10027
  }
10025
10028
  var append2 = CombinedStream.prototype.append.bind(this);
10026
- if (typeof value == "number") {
10027
- value = "" + value;
10029
+ if (typeof value === "number" || value == null) {
10030
+ value = String(value);
10028
10031
  }
10029
10032
  if (Array.isArray(value)) {
10030
10033
  this._error(new Error("Arrays are not supported."));
@@ -10040,7 +10043,7 @@ var require_form_data = __commonJS({
10040
10043
  FormData3.prototype._trackLength = function(header, value, options) {
10041
10044
  var valueLength = 0;
10042
10045
  if (options.knownLength != null) {
10043
- valueLength += +options.knownLength;
10046
+ valueLength += Number(options.knownLength);
10044
10047
  } else if (Buffer.isBuffer(value)) {
10045
10048
  valueLength = value.length;
10046
10049
  } else if (typeof value === "string") {
@@ -10048,7 +10051,7 @@ var require_form_data = __commonJS({
10048
10051
  }
10049
10052
  this._valueLength += valueLength;
10050
10053
  this._overheadLength += Buffer.byteLength(header) + FormData3.LINE_BREAK.length;
10051
- if (!value || !value.path && !(value.readable && Object.prototype.hasOwnProperty.call(value, "httpVersion")) && !(value instanceof Stream)) {
10054
+ if (!value || !value.path && !(value.readable && hasOwn(value, "httpVersion")) && !(value instanceof Stream)) {
10052
10055
  return;
10053
10056
  }
10054
10057
  if (!options.knownLength) {
@@ -10056,26 +10059,25 @@ var require_form_data = __commonJS({
10056
10059
  }
10057
10060
  };
10058
10061
  FormData3.prototype._lengthRetriever = function(value, callback) {
10059
- if (Object.prototype.hasOwnProperty.call(value, "fd")) {
10062
+ if (hasOwn(value, "fd")) {
10060
10063
  if (value.end != void 0 && value.end != Infinity && value.start != void 0) {
10061
10064
  callback(null, value.end + 1 - (value.start ? value.start : 0));
10062
10065
  } else {
10063
- fs.stat(value.path, function(err, stat) {
10064
- var fileSize;
10066
+ fs2.stat(value.path, function(err, stat) {
10065
10067
  if (err) {
10066
10068
  callback(err);
10067
10069
  return;
10068
10070
  }
10069
- fileSize = stat.size - (value.start ? value.start : 0);
10071
+ var fileSize = stat.size - (value.start ? value.start : 0);
10070
10072
  callback(null, fileSize);
10071
10073
  });
10072
10074
  }
10073
- } else if (Object.prototype.hasOwnProperty.call(value, "httpVersion")) {
10074
- callback(null, +value.headers["content-length"]);
10075
- } else if (Object.prototype.hasOwnProperty.call(value, "httpModule")) {
10075
+ } else if (hasOwn(value, "httpVersion")) {
10076
+ callback(null, Number(value.headers["content-length"]));
10077
+ } else if (hasOwn(value, "httpModule")) {
10076
10078
  value.on("response", function(response) {
10077
10079
  value.pause();
10078
- callback(null, +response.headers["content-length"]);
10080
+ callback(null, Number(response.headers["content-length"]));
10079
10081
  });
10080
10082
  value.resume();
10081
10083
  } else {
@@ -10083,7 +10085,7 @@ var require_form_data = __commonJS({
10083
10085
  }
10084
10086
  };
10085
10087
  FormData3.prototype._multiPartHeader = function(field, value, options) {
10086
- if (typeof options.header == "string") {
10088
+ if (typeof options.header === "string") {
10087
10089
  return options.header;
10088
10090
  }
10089
10091
  var contentDisposition = this._getContentDisposition(value, options);
@@ -10095,12 +10097,12 @@ var require_form_data = __commonJS({
10095
10097
  // if no content type. allow it to be empty array
10096
10098
  "Content-Type": [].concat(contentType || [])
10097
10099
  };
10098
- if (typeof options.header == "object") {
10100
+ if (typeof options.header === "object") {
10099
10101
  populate(headers, options.header);
10100
10102
  }
10101
10103
  var header;
10102
10104
  for (var prop in headers) {
10103
- if (Object.prototype.hasOwnProperty.call(headers, prop)) {
10105
+ if (hasOwn(headers, prop)) {
10104
10106
  header = headers[prop];
10105
10107
  if (header == null) {
10106
10108
  continue;
@@ -10116,34 +10118,33 @@ var require_form_data = __commonJS({
10116
10118
  return "--" + this.getBoundary() + FormData3.LINE_BREAK + contents + FormData3.LINE_BREAK;
10117
10119
  };
10118
10120
  FormData3.prototype._getContentDisposition = function(value, options) {
10119
- var filename, contentDisposition;
10121
+ var filename;
10120
10122
  if (typeof options.filepath === "string") {
10121
- filename = path.normalize(options.filepath).replace(/\\/g, "/");
10122
- } else if (options.filename || value.name || value.path) {
10123
- filename = path.basename(options.filename || value.name || value.path);
10124
- } else if (value.readable && Object.prototype.hasOwnProperty.call(value, "httpVersion")) {
10125
- filename = path.basename(value.client._httpMessage.path || "");
10123
+ filename = path2.normalize(options.filepath).replace(/\\/g, "/");
10124
+ } else if (options.filename || value && (value.name || value.path)) {
10125
+ filename = path2.basename(options.filename || value && (value.name || value.path));
10126
+ } else if (value && value.readable && hasOwn(value, "httpVersion")) {
10127
+ filename = path2.basename(value.client._httpMessage.path || "");
10126
10128
  }
10127
10129
  if (filename) {
10128
- contentDisposition = 'filename="' + filename + '"';
10130
+ return 'filename="' + filename + '"';
10129
10131
  }
10130
- return contentDisposition;
10131
10132
  };
10132
10133
  FormData3.prototype._getContentType = function(value, options) {
10133
10134
  var contentType = options.contentType;
10134
- if (!contentType && value.name) {
10135
+ if (!contentType && value && value.name) {
10135
10136
  contentType = mime.lookup(value.name);
10136
10137
  }
10137
- if (!contentType && value.path) {
10138
+ if (!contentType && value && value.path) {
10138
10139
  contentType = mime.lookup(value.path);
10139
10140
  }
10140
- if (!contentType && value.readable && Object.prototype.hasOwnProperty.call(value, "httpVersion")) {
10141
+ if (!contentType && value && value.readable && hasOwn(value, "httpVersion")) {
10141
10142
  contentType = value.headers["content-type"];
10142
10143
  }
10143
10144
  if (!contentType && (options.filepath || options.filename)) {
10144
10145
  contentType = mime.lookup(options.filepath || options.filename);
10145
10146
  }
10146
- if (!contentType && typeof value == "object") {
10147
+ if (!contentType && value && typeof value === "object") {
10147
10148
  contentType = FormData3.DEFAULT_CONTENT_TYPE;
10148
10149
  }
10149
10150
  return contentType;
@@ -10167,13 +10168,16 @@ var require_form_data = __commonJS({
10167
10168
  "content-type": "multipart/form-data; boundary=" + this.getBoundary()
10168
10169
  };
10169
10170
  for (header in userHeaders) {
10170
- if (Object.prototype.hasOwnProperty.call(userHeaders, header)) {
10171
+ if (hasOwn(userHeaders, header)) {
10171
10172
  formHeaders[header.toLowerCase()] = userHeaders[header];
10172
10173
  }
10173
10174
  }
10174
10175
  return formHeaders;
10175
10176
  };
10176
10177
  FormData3.prototype.setBoundary = function(boundary) {
10178
+ if (typeof boundary !== "string") {
10179
+ throw new TypeError("FormData boundary must be a string");
10180
+ }
10177
10181
  this._boundary = boundary;
10178
10182
  };
10179
10183
  FormData3.prototype.getBoundary = function() {
@@ -10200,11 +10204,7 @@ var require_form_data = __commonJS({
10200
10204
  return Buffer.concat([dataBuffer, Buffer.from(this._lastBoundary())]);
10201
10205
  };
10202
10206
  FormData3.prototype._generateBoundary = function() {
10203
- var boundary = "--------------------------";
10204
- for (var i = 0; i < 24; i++) {
10205
- boundary += Math.floor(Math.random() * 10).toString(16);
10206
- }
10207
- this._boundary = boundary;
10207
+ this._boundary = "--------------------------" + crypto3.randomBytes(12).toString("hex");
10208
10208
  };
10209
10209
  FormData3.prototype.getLengthSync = function() {
10210
10210
  var knownLength = this._overheadLength + this._valueLength;
@@ -10244,8 +10244,10 @@ var require_form_data = __commonJS({
10244
10244
  });
10245
10245
  };
10246
10246
  FormData3.prototype.submit = function(params, cb) {
10247
- var request, options, defaults2 = { method: "post" };
10248
- if (typeof params == "string") {
10247
+ var request;
10248
+ var options;
10249
+ var defaults2 = { method: "post" };
10250
+ if (typeof params === "string") {
10249
10251
  params = parseUrl(params);
10250
10252
  options = populate({
10251
10253
  port: params.port,
@@ -10256,14 +10258,14 @@ var require_form_data = __commonJS({
10256
10258
  } else {
10257
10259
  options = populate(params, defaults2);
10258
10260
  if (!options.port) {
10259
- options.port = options.protocol == "https:" ? 443 : 80;
10261
+ options.port = options.protocol === "https:" ? 443 : 80;
10260
10262
  }
10261
10263
  }
10262
10264
  options.headers = this.getHeaders(params.headers);
10263
- if (options.protocol == "https:") {
10265
+ if (options.protocol === "https:") {
10264
10266
  request = https2.request(options);
10265
10267
  } else {
10266
- request = http3.request(options);
10268
+ request = http4.request(options);
10267
10269
  }
10268
10270
  this.getLength(function(err, length) {
10269
10271
  if (err && err !== "Unknown stream") {
@@ -10298,7 +10300,8 @@ var require_form_data = __commonJS({
10298
10300
  FormData3.prototype.toString = function() {
10299
10301
  return "[object FormData]";
10300
10302
  };
10301
- setToStringTag(FormData3, "FormData");
10303
+ setToStringTag(FormData3.prototype, "FormData");
10304
+ module.exports = FormData3;
10302
10305
  }
10303
10306
  });
10304
10307
 
@@ -11160,7 +11163,7 @@ var require_follow_redirects = __commonJS({
11160
11163
  "node_modules/follow-redirects/index.js"(exports, module) {
11161
11164
  var url2 = __require("url");
11162
11165
  var URL2 = url2.URL;
11163
- var http3 = __require("http");
11166
+ var http4 = __require("http");
11164
11167
  var https2 = __require("https");
11165
11168
  var Writable = __require("stream").Writable;
11166
11169
  var assert = __require("assert");
@@ -11168,7 +11171,7 @@ var require_follow_redirects = __commonJS({
11168
11171
  (function detectUnsupportedEnvironment() {
11169
11172
  var looksLikeNode = typeof process !== "undefined";
11170
11173
  var looksLikeBrowser = typeof window !== "undefined" && typeof document !== "undefined";
11171
- var looksLikeV8 = isFunction3(Error.captureStackTrace);
11174
+ var looksLikeV8 = isFunction4(Error.captureStackTrace);
11172
11175
  if (!looksLikeNode && (looksLikeBrowser || !looksLikeV8)) {
11173
11176
  console.warn("The follow-redirects package should be excluded from browser builds.");
11174
11177
  }
@@ -11263,7 +11266,7 @@ var require_follow_redirects = __commonJS({
11263
11266
  if (!isString2(data) && !isBuffer2(data)) {
11264
11267
  throw new TypeError("data should be a string, Buffer or Uint8Array");
11265
11268
  }
11266
- if (isFunction3(encoding)) {
11269
+ if (isFunction4(encoding)) {
11267
11270
  callback = encoding;
11268
11271
  encoding = null;
11269
11272
  }
@@ -11283,10 +11286,10 @@ var require_follow_redirects = __commonJS({
11283
11286
  }
11284
11287
  };
11285
11288
  RedirectableRequest.prototype.end = function(data, encoding, callback) {
11286
- if (isFunction3(data)) {
11289
+ if (isFunction4(data)) {
11287
11290
  callback = data;
11288
11291
  data = encoding = null;
11289
- } else if (isFunction3(encoding)) {
11292
+ } else if (isFunction4(encoding)) {
11290
11293
  callback = encoding;
11291
11294
  encoding = null;
11292
11295
  }
@@ -11487,7 +11490,7 @@ var require_follow_redirects = __commonJS({
11487
11490
  if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) {
11488
11491
  removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers);
11489
11492
  }
11490
- if (isFunction3(beforeRedirect)) {
11493
+ if (isFunction4(beforeRedirect)) {
11491
11494
  var responseDetails = {
11492
11495
  headers: response.headers,
11493
11496
  statusCode
@@ -11522,7 +11525,7 @@ var require_follow_redirects = __commonJS({
11522
11525
  options = validateUrl(input);
11523
11526
  input = { protocol };
11524
11527
  }
11525
- if (isFunction3(options)) {
11528
+ if (isFunction4(options)) {
11526
11529
  callback = options;
11527
11530
  options = null;
11528
11531
  }
@@ -11602,7 +11605,7 @@ var require_follow_redirects = __commonJS({
11602
11605
  }
11603
11606
  function createErrorType(code, message, baseClass) {
11604
11607
  function CustomError(properties) {
11605
- if (isFunction3(Error.captureStackTrace)) {
11608
+ if (isFunction4(Error.captureStackTrace)) {
11606
11609
  Error.captureStackTrace(this, this.constructor);
11607
11610
  }
11608
11611
  Object.assign(this, properties || {});
@@ -11637,7 +11640,7 @@ var require_follow_redirects = __commonJS({
11637
11640
  function isString2(value) {
11638
11641
  return typeof value === "string" || value instanceof String;
11639
11642
  }
11640
- function isFunction3(value) {
11643
+ function isFunction4(value) {
11641
11644
  return typeof value === "function";
11642
11645
  }
11643
11646
  function isBuffer2(value) {
@@ -11646,7 +11649,7 @@ var require_follow_redirects = __commonJS({
11646
11649
  function isURL(value) {
11647
11650
  return URL2 && value instanceof URL2;
11648
11651
  }
11649
- module.exports = wrap2({ http: http3, https: https2 });
11652
+ module.exports = wrap2({ http: http4, https: https2 });
11650
11653
  module.exports.wrap = wrap2;
11651
11654
  }
11652
11655
  });
@@ -11656,7 +11659,14 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
11656
11659
 
11657
11660
  // src/server.ts
11658
11661
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
11659
- import { ListToolsRequestSchema, CallToolRequestSchema } from "@modelcontextprotocol/sdk/types.js";
11662
+ import {
11663
+ ListToolsRequestSchema,
11664
+ CallToolRequestSchema,
11665
+ ListPromptsRequestSchema,
11666
+ GetPromptRequestSchema,
11667
+ ListResourcesRequestSchema,
11668
+ ReadResourceRequestSchema
11669
+ } from "@modelcontextprotocol/sdk/types.js";
11660
11670
 
11661
11671
  // src/openapi-loader.ts
11662
11672
  import { readFile } from "fs/promises";
@@ -12525,6 +12535,18 @@ function charFromCodepoint(c) {
12525
12535
  (c - 65536 & 1023) + 56320
12526
12536
  );
12527
12537
  }
12538
+ function setProperty(object, key, value) {
12539
+ if (key === "__proto__") {
12540
+ Object.defineProperty(object, key, {
12541
+ configurable: true,
12542
+ enumerable: true,
12543
+ writable: true,
12544
+ value
12545
+ });
12546
+ } else {
12547
+ object[key] = value;
12548
+ }
12549
+ }
12528
12550
  var simpleEscapeCheck = new Array(256);
12529
12551
  var simpleEscapeMap = new Array(256);
12530
12552
  for (i = 0; i < 256; i++) {
@@ -12644,7 +12666,7 @@ function mergeMappings(state, destination, source, overridableKeys) {
12644
12666
  for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
12645
12667
  key = sourceKeys[index];
12646
12668
  if (!_hasOwnProperty$1.call(destination, key)) {
12647
- destination[key] = source[key];
12669
+ setProperty(destination, key, source[key]);
12648
12670
  overridableKeys[key] = true;
12649
12671
  }
12650
12672
  }
@@ -12684,16 +12706,7 @@ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valu
12684
12706
  state.position = startPos || state.position;
12685
12707
  throwError(state, "duplicated mapping key");
12686
12708
  }
12687
- if (keyNode === "__proto__") {
12688
- Object.defineProperty(_result, keyNode, {
12689
- configurable: true,
12690
- enumerable: true,
12691
- writable: true,
12692
- value: valueNode
12693
- });
12694
- } else {
12695
- _result[keyNode] = valueNode;
12696
- }
12709
+ setProperty(_result, keyNode, valueNode);
12697
12710
  delete overridableKeys[keyNode];
12698
12711
  }
12699
12712
  return _result;
@@ -14281,7 +14294,6 @@ var jsYaml = {
14281
14294
  safeLoadAll,
14282
14295
  safeDump
14283
14296
  };
14284
- var js_yaml_default = jsYaml;
14285
14297
 
14286
14298
  // src/openapi-loader.ts
14287
14299
  import crypto from "crypto";
@@ -14377,8 +14389,8 @@ function parseToolId(toolId) {
14377
14389
  if (!pathPart) {
14378
14390
  return { method, path: "" };
14379
14391
  }
14380
- const path = pathPart.replace(/__/g, "/");
14381
- return { method, path: "/" + path };
14392
+ const path2 = pathPart.replace(/__/g, "/");
14393
+ return { method, path: "/" + path2 };
14382
14394
  }
14383
14395
  function sanitizeForToolId(input) {
14384
14396
  let result = input.replace(/[^A-Za-z0-9_.-]/g, "").replace(/_{3,}/g, "__");
@@ -14388,8 +14400,8 @@ function sanitizeForToolId(input) {
14388
14400
  function collapseExcessiveHyphens(input) {
14389
14401
  return input.replace(/-{4,}/g, "---");
14390
14402
  }
14391
- function generateToolId(method, path) {
14392
- const cleanPath = path.replace(/^\//, "").replace(/\/+/g, "/").replace(/\{([^}]+)\}/g, "---$1").replace(/\//g, "__");
14403
+ function generateToolId(method, path2) {
14404
+ const cleanPath = path2.replace(/^\//, "").replace(/\/+/g, "/").replace(/\{([^}]+)\}/g, "---$1").replace(/\//g, "__");
14393
14405
  const sanitizedPath = sanitizeForToolId(cleanPath);
14394
14406
  return `${method.toUpperCase()}::${sanitizedPath}`;
14395
14407
  }
@@ -14456,7 +14468,7 @@ var OpenAPISpecLoader = class {
14456
14468
  * Load spec content from standard input
14457
14469
  */
14458
14470
  async loadFromStdin() {
14459
- return new Promise((resolve5, reject) => {
14471
+ return new Promise((resolve6, reject) => {
14460
14472
  let data = "";
14461
14473
  process.stdin.setEncoding("utf8");
14462
14474
  process.stdin.on("data", (chunk) => {
@@ -14466,7 +14478,7 @@ var OpenAPISpecLoader = class {
14466
14478
  if (data.trim().length === 0) {
14467
14479
  reject(new Error("No data received from stdin"));
14468
14480
  } else {
14469
- resolve5(data);
14481
+ resolve6(data);
14470
14482
  }
14471
14483
  });
14472
14484
  process.stdin.on("error", (error) => {
@@ -14486,7 +14498,9 @@ var OpenAPISpecLoader = class {
14486
14498
  return JSON.parse(specContent);
14487
14499
  } catch (jsonError) {
14488
14500
  try {
14489
- const yamlResult = js_yaml_default.load(specContent);
14501
+ const yamlResult = jsYaml.load(specContent, {
14502
+ schema: CORE_SCHEMA
14503
+ });
14490
14504
  if (!yamlResult || typeof yamlResult !== "object") {
14491
14505
  throw new Error("YAML parsing resulted in invalid object");
14492
14506
  }
@@ -14646,8 +14660,8 @@ var OpenAPISpecLoader = class {
14646
14660
  * - "/api/v1/users/{id}/posts" -> "posts"
14647
14661
  * - "/health" -> "health"
14648
14662
  */
14649
- extractResourceName(path) {
14650
- const segments = path.replace(/^\//, "").split("/");
14663
+ extractResourceName(path2) {
14664
+ const segments = path2.replace(/^\//, "").split("/");
14651
14665
  for (let i = segments.length - 1; i >= 0; i--) {
14652
14666
  const segment = segments[i];
14653
14667
  if (!segment.includes("{") && !segment.includes("}") && segment.length > 0) {
@@ -14661,7 +14675,7 @@ var OpenAPISpecLoader = class {
14661
14675
  */
14662
14676
  parseOpenAPISpec(spec) {
14663
14677
  const tools = /* @__PURE__ */ new Map();
14664
- for (const [path, pathItem] of Object.entries(spec.paths)) {
14678
+ for (const [path2, pathItem] of Object.entries(spec.paths)) {
14665
14679
  if (!pathItem) continue;
14666
14680
  const pathLevelParameters = [];
14667
14681
  if (pathItem.parameters) {
@@ -14703,16 +14717,16 @@ var OpenAPISpecLoader = class {
14703
14717
  if (!["get", "post", "put", "patch", "delete", "options", "head"].includes(
14704
14718
  method.toLowerCase()
14705
14719
  )) {
14706
- console.warn(`Skipping non-HTTP method "${method}" for path ${path}`);
14720
+ console.warn(`Skipping non-HTTP method "${method}" for path ${path2}`);
14707
14721
  continue;
14708
14722
  }
14709
14723
  const op = operation;
14710
- const toolId = generateToolId(method, path);
14711
- const nameSource = op.operationId || op.summary || `${method.toUpperCase()} ${path}`;
14724
+ const toolId = generateToolId(method, path2);
14725
+ const nameSource = op.operationId || op.summary || `${method.toUpperCase()} ${path2}`;
14712
14726
  const name = this.abbreviateOperationId(nameSource);
14713
14727
  const tool = {
14714
14728
  name,
14715
- description: op.description || `Make a ${method.toUpperCase()} request to ${path}`,
14729
+ description: op.description || `Make a ${method.toUpperCase()} request to ${path2}`,
14716
14730
  inputSchema: {
14717
14731
  type: "object",
14718
14732
  properties: {}
@@ -14720,10 +14734,10 @@ var OpenAPISpecLoader = class {
14720
14734
  // Add metadata for filtering
14721
14735
  tags: op.tags || [],
14722
14736
  httpMethod: method.toUpperCase(),
14723
- resourceName: this.extractResourceName(path),
14724
- originalPath: path
14737
+ resourceName: this.extractResourceName(path2),
14738
+ originalPath: path2
14725
14739
  };
14726
- tool["x-original-path"] = path;
14740
+ tool["x-original-path"] = path2;
14727
14741
  const requiredParams = [];
14728
14742
  const parameterMap = /* @__PURE__ */ new Map();
14729
14743
  for (const pathParam of pathLevelParameters) {
@@ -15240,6 +15254,16 @@ var isPlainObject = (val) => {
15240
15254
  const prototype3 = getPrototypeOf(val);
15241
15255
  return (prototype3 === null || prototype3 === Object.prototype || Object.getPrototypeOf(prototype3) === null) && !(toStringTag in val) && !(iterator in val);
15242
15256
  };
15257
+ var isEmptyObject = (val) => {
15258
+ if (!isObject2(val) || isBuffer(val)) {
15259
+ return false;
15260
+ }
15261
+ try {
15262
+ return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
15263
+ } catch (e) {
15264
+ return false;
15265
+ }
15266
+ };
15243
15267
  var isDate = kindOfTest("Date");
15244
15268
  var isFile = kindOfTest("File");
15245
15269
  var isBlob = kindOfTest("Blob");
@@ -15267,6 +15291,9 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
15267
15291
  fn.call(null, obj[i], i, obj);
15268
15292
  }
15269
15293
  } else {
15294
+ if (isBuffer(obj)) {
15295
+ return;
15296
+ }
15270
15297
  const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
15271
15298
  const len = keys.length;
15272
15299
  let key;
@@ -15277,6 +15304,9 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
15277
15304
  }
15278
15305
  }
15279
15306
  function findKey(obj, key) {
15307
+ if (isBuffer(obj)) {
15308
+ return null;
15309
+ }
15280
15310
  key = key.toLowerCase();
15281
15311
  const keys = Object.keys(obj);
15282
15312
  let i = keys.length;
@@ -15295,7 +15325,7 @@ var _global = (() => {
15295
15325
  })();
15296
15326
  var isContextDefined = (context) => !isUndefined(context) && context !== _global;
15297
15327
  function merge2() {
15298
- const { caseless } = isContextDefined(this) && this || {};
15328
+ const { caseless, skipUndefined } = isContextDefined(this) && this || {};
15299
15329
  const result = {};
15300
15330
  const assignValue = (val, key) => {
15301
15331
  const targetKey = caseless && findKey(result, key) || key;
@@ -15305,7 +15335,7 @@ function merge2() {
15305
15335
  result[targetKey] = merge2({}, val);
15306
15336
  } else if (isArray(val)) {
15307
15337
  result[targetKey] = val.slice();
15308
- } else {
15338
+ } else if (!skipUndefined || !isUndefined(val)) {
15309
15339
  result[targetKey] = val;
15310
15340
  }
15311
15341
  };
@@ -15467,6 +15497,9 @@ var toJSONObject = (obj) => {
15467
15497
  if (stack.indexOf(source) >= 0) {
15468
15498
  return;
15469
15499
  }
15500
+ if (isBuffer(source)) {
15501
+ return source;
15502
+ }
15470
15503
  if (!("toJSON" in source)) {
15471
15504
  stack[i] = source;
15472
15505
  const target = isArray(source) ? [] : {};
@@ -15516,6 +15549,7 @@ var utils_default = {
15516
15549
  isBoolean: isBoolean2,
15517
15550
  isObject: isObject2,
15518
15551
  isPlainObject,
15552
+ isEmptyObject,
15519
15553
  isReadableStream,
15520
15554
  isRequest,
15521
15555
  isResponse,
@@ -15632,9 +15666,13 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
15632
15666
  }, (prop) => {
15633
15667
  return prop !== "isAxiosError";
15634
15668
  });
15635
- AxiosError.call(axiosError, error.message, code, config, request, response);
15636
- axiosError.cause = error;
15637
- axiosError.name = error.name;
15669
+ const msg = error && error.message ? error.message : "Error";
15670
+ const errCode = code == null && error ? error.code : code;
15671
+ AxiosError.call(axiosError, msg, errCode, config, request, response);
15672
+ if (error && axiosError.cause == null) {
15673
+ Object.defineProperty(axiosError, "cause", { value: error, configurable: true });
15674
+ }
15675
+ axiosError.name = error && error.name || "Error";
15638
15676
  customProps && Object.assign(axiosError, customProps);
15639
15677
  return axiosError;
15640
15678
  };
@@ -15651,9 +15689,9 @@ function isVisitable(thing) {
15651
15689
  function removeBrackets(key) {
15652
15690
  return utils_default.endsWith(key, "[]") ? key.slice(0, -2) : key;
15653
15691
  }
15654
- function renderKey(path, key, dots) {
15655
- if (!path) return key;
15656
- return path.concat(key).map(function each(token, i) {
15692
+ function renderKey(path2, key, dots) {
15693
+ if (!path2) return key;
15694
+ return path2.concat(key).map(function each(token, i) {
15657
15695
  token = removeBrackets(token);
15658
15696
  return !dots && i ? "[" + token + "]" : token;
15659
15697
  }).join(dots ? "." : "");
@@ -15701,9 +15739,9 @@ function toFormData(obj, formData, options) {
15701
15739
  }
15702
15740
  return value;
15703
15741
  }
15704
- function defaultVisitor(value, key, path) {
15742
+ function defaultVisitor(value, key, path2) {
15705
15743
  let arr = value;
15706
- if (value && !path && typeof value === "object") {
15744
+ if (value && !path2 && typeof value === "object") {
15707
15745
  if (utils_default.endsWith(key, "{}")) {
15708
15746
  key = metaTokens ? key : key.slice(0, -2);
15709
15747
  value = JSON.stringify(value);
@@ -15722,7 +15760,7 @@ function toFormData(obj, formData, options) {
15722
15760
  if (isVisitable(value)) {
15723
15761
  return true;
15724
15762
  }
15725
- formData.append(renderKey(path, key, dots), convertValue(value));
15763
+ formData.append(renderKey(path2, key, dots), convertValue(value));
15726
15764
  return false;
15727
15765
  }
15728
15766
  const stack = [];
@@ -15731,10 +15769,10 @@ function toFormData(obj, formData, options) {
15731
15769
  convertValue,
15732
15770
  isVisitable
15733
15771
  });
15734
- function build(value, path) {
15772
+ function build(value, path2) {
15735
15773
  if (utils_default.isUndefined(value)) return;
15736
15774
  if (stack.indexOf(value) !== -1) {
15737
- throw Error("Circular reference detected in " + path.join("."));
15775
+ throw Error("Circular reference detected in " + path2.join("."));
15738
15776
  }
15739
15777
  stack.push(value);
15740
15778
  utils_default.forEach(value, function each(el, key) {
@@ -15742,11 +15780,11 @@ function toFormData(obj, formData, options) {
15742
15780
  formData,
15743
15781
  el,
15744
15782
  utils_default.isString(key) ? key.trim() : key,
15745
- path,
15783
+ path2,
15746
15784
  exposedHelpers
15747
15785
  );
15748
15786
  if (result === true) {
15749
- build(el, path ? path.concat(key) : [key]);
15787
+ build(el, path2 ? path2.concat(key) : [key]);
15750
15788
  }
15751
15789
  });
15752
15790
  stack.pop();
@@ -15794,7 +15832,7 @@ var AxiosURLSearchParams_default = AxiosURLSearchParams;
15794
15832
 
15795
15833
  // node_modules/axios/lib/helpers/buildURL.js
15796
15834
  function encode2(val) {
15797
- return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
15835
+ return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+");
15798
15836
  }
15799
15837
  function buildURL(url2, params, options) {
15800
15838
  if (!params) {
@@ -15850,7 +15888,7 @@ var InterceptorManager = class {
15850
15888
  *
15851
15889
  * @param {Number} id The ID that was returned by `use`
15852
15890
  *
15853
- * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
15891
+ * @returns {void}
15854
15892
  */
15855
15893
  eject(id) {
15856
15894
  if (this.handlers[id]) {
@@ -15957,15 +15995,16 @@ var platform_default = {
15957
15995
 
15958
15996
  // node_modules/axios/lib/helpers/toURLEncodedForm.js
15959
15997
  function toURLEncodedForm(data, options) {
15960
- return toFormData_default(data, new platform_default.classes.URLSearchParams(), Object.assign({
15961
- visitor: function(value, key, path, helpers) {
15998
+ return toFormData_default(data, new platform_default.classes.URLSearchParams(), {
15999
+ visitor: function(value, key, path2, helpers) {
15962
16000
  if (platform_default.isNode && utils_default.isBuffer(value)) {
15963
16001
  this.append(key, value.toString("base64"));
15964
16002
  return false;
15965
16003
  }
15966
16004
  return helpers.defaultVisitor.apply(this, arguments);
15967
- }
15968
- }, options));
16005
+ },
16006
+ ...options
16007
+ });
15969
16008
  }
15970
16009
 
15971
16010
  // node_modules/axios/lib/helpers/formDataToJSON.js
@@ -15987,11 +16026,11 @@ function arrayToObject(arr) {
15987
16026
  return obj;
15988
16027
  }
15989
16028
  function formDataToJSON(formData) {
15990
- function buildPath(path, value, target, index) {
15991
- let name = path[index++];
16029
+ function buildPath(path2, value, target, index) {
16030
+ let name = path2[index++];
15992
16031
  if (name === "__proto__") return true;
15993
16032
  const isNumericKey = Number.isFinite(+name);
15994
- const isLast = index >= path.length;
16033
+ const isLast = index >= path2.length;
15995
16034
  name = !name && utils_default.isArray(target) ? target.length : name;
15996
16035
  if (isLast) {
15997
16036
  if (utils_default.hasOwnProp(target, name)) {
@@ -16004,7 +16043,7 @@ function formDataToJSON(formData) {
16004
16043
  if (!target[name] || !utils_default.isObject(target[name])) {
16005
16044
  target[name] = [];
16006
16045
  }
16007
- const result = buildPath(path, value, target[name], index);
16046
+ const result = buildPath(path2, value, target[name], index);
16008
16047
  if (result && utils_default.isArray(target[name])) {
16009
16048
  target[name] = arrayToObject(target[name]);
16010
16049
  }
@@ -16090,7 +16129,7 @@ var defaults = {
16090
16129
  const silentJSONParsing = transitional2 && transitional2.silentJSONParsing;
16091
16130
  const strictJSONParsing = !silentJSONParsing && JSONRequested;
16092
16131
  try {
16093
- return JSON.parse(data);
16132
+ return JSON.parse(data, this.parseReviver);
16094
16133
  } catch (e) {
16095
16134
  if (strictJSONParsing) {
16096
16135
  if (e.name === "SyntaxError") {
@@ -16433,10 +16472,10 @@ utils_default.inherits(CanceledError, AxiosError_default, {
16433
16472
  var CanceledError_default = CanceledError;
16434
16473
 
16435
16474
  // node_modules/axios/lib/core/settle.js
16436
- function settle(resolve5, reject, response) {
16475
+ function settle(resolve6, reject, response) {
16437
16476
  const validateStatus2 = response.config.validateStatus;
16438
16477
  if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
16439
- resolve5(response);
16478
+ resolve6(response);
16440
16479
  } else {
16441
16480
  reject(new AxiosError_default(
16442
16481
  "Request failed with status code " + response.status,
@@ -16472,11 +16511,12 @@ var import_proxy_from_env = __toESM(require_proxy_from_env(), 1);
16472
16511
  var import_follow_redirects = __toESM(require_follow_redirects(), 1);
16473
16512
  import http from "http";
16474
16513
  import https from "https";
16514
+ import http2 from "http2";
16475
16515
  import util2 from "util";
16476
16516
  import zlib from "zlib";
16477
16517
 
16478
16518
  // node_modules/axios/lib/env/data.js
16479
- var VERSION = "1.10.0";
16519
+ var VERSION = "1.13.2";
16480
16520
 
16481
16521
  // node_modules/axios/lib/helpers/parseProtocol.js
16482
16522
  function parseProtocol(url2) {
@@ -16818,7 +16858,7 @@ function throttle(fn, freq) {
16818
16858
  clearTimeout(timer);
16819
16859
  timer = null;
16820
16860
  }
16821
- fn.apply(null, args);
16861
+ fn(...args);
16822
16862
  };
16823
16863
  const throttled = (...args) => {
16824
16864
  const now = Date.now();
@@ -16875,6 +16915,57 @@ var progressEventDecorator = (total, throttled) => {
16875
16915
  };
16876
16916
  var asyncDecorator = (fn) => (...args) => utils_default.asap(() => fn(...args));
16877
16917
 
16918
+ // node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js
16919
+ function estimateDataURLDecodedBytes(url2) {
16920
+ if (!url2 || typeof url2 !== "string") return 0;
16921
+ if (!url2.startsWith("data:")) return 0;
16922
+ const comma = url2.indexOf(",");
16923
+ if (comma < 0) return 0;
16924
+ const meta = url2.slice(5, comma);
16925
+ const body = url2.slice(comma + 1);
16926
+ const isBase64 = /;base64/i.test(meta);
16927
+ if (isBase64) {
16928
+ let effectiveLen = body.length;
16929
+ const len = body.length;
16930
+ for (let i = 0; i < len; i++) {
16931
+ if (body.charCodeAt(i) === 37 && i + 2 < len) {
16932
+ const a = body.charCodeAt(i + 1);
16933
+ const b = body.charCodeAt(i + 2);
16934
+ const isHex = (a >= 48 && a <= 57 || a >= 65 && a <= 70 || a >= 97 && a <= 102) && (b >= 48 && b <= 57 || b >= 65 && b <= 70 || b >= 97 && b <= 102);
16935
+ if (isHex) {
16936
+ effectiveLen -= 2;
16937
+ i += 2;
16938
+ }
16939
+ }
16940
+ }
16941
+ let pad = 0;
16942
+ let idx = len - 1;
16943
+ const tailIsPct3D = (j) => j >= 2 && body.charCodeAt(j - 2) === 37 && // '%'
16944
+ body.charCodeAt(j - 1) === 51 && // '3'
16945
+ (body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100);
16946
+ if (idx >= 0) {
16947
+ if (body.charCodeAt(idx) === 61) {
16948
+ pad++;
16949
+ idx--;
16950
+ } else if (tailIsPct3D(idx)) {
16951
+ pad++;
16952
+ idx -= 3;
16953
+ }
16954
+ }
16955
+ if (pad === 1 && idx >= 0) {
16956
+ if (body.charCodeAt(idx) === 61) {
16957
+ pad++;
16958
+ } else if (tailIsPct3D(idx)) {
16959
+ pad++;
16960
+ }
16961
+ }
16962
+ const groups = Math.floor(effectiveLen / 4);
16963
+ const bytes = groups * 3 - (pad || 0);
16964
+ return bytes > 0 ? bytes : 0;
16965
+ }
16966
+ return Buffer.byteLength(body, "utf8");
16967
+ }
16968
+
16878
16969
  // node_modules/axios/lib/adapters/http.js
16879
16970
  var zlibOptions = {
16880
16971
  flush: zlib.constants.Z_SYNC_FLUSH,
@@ -16894,6 +16985,76 @@ var flushOnFinish = (stream4, [throttled, flush]) => {
16894
16985
  stream4.on("end", flush).on("error", flush);
16895
16986
  return throttled;
16896
16987
  };
16988
+ var Http2Sessions = class {
16989
+ constructor() {
16990
+ this.sessions = /* @__PURE__ */ Object.create(null);
16991
+ }
16992
+ getSession(authority, options) {
16993
+ options = Object.assign({
16994
+ sessionTimeout: 1e3
16995
+ }, options);
16996
+ let authoritySessions = this.sessions[authority];
16997
+ if (authoritySessions) {
16998
+ let len = authoritySessions.length;
16999
+ for (let i = 0; i < len; i++) {
17000
+ const [sessionHandle, sessionOptions] = authoritySessions[i];
17001
+ if (!sessionHandle.destroyed && !sessionHandle.closed && util2.isDeepStrictEqual(sessionOptions, options)) {
17002
+ return sessionHandle;
17003
+ }
17004
+ }
17005
+ }
17006
+ const session = http2.connect(authority, options);
17007
+ let removed;
17008
+ const removeSession = () => {
17009
+ if (removed) {
17010
+ return;
17011
+ }
17012
+ removed = true;
17013
+ let entries = authoritySessions, len = entries.length, i = len;
17014
+ while (i--) {
17015
+ if (entries[i][0] === session) {
17016
+ if (len === 1) {
17017
+ delete this.sessions[authority];
17018
+ } else {
17019
+ entries.splice(i, 1);
17020
+ }
17021
+ return;
17022
+ }
17023
+ }
17024
+ };
17025
+ const originalRequestFn = session.request;
17026
+ const { sessionTimeout } = options;
17027
+ if (sessionTimeout != null) {
17028
+ let timer;
17029
+ let streamsCount = 0;
17030
+ session.request = function() {
17031
+ const stream4 = originalRequestFn.apply(this, arguments);
17032
+ streamsCount++;
17033
+ if (timer) {
17034
+ clearTimeout(timer);
17035
+ timer = null;
17036
+ }
17037
+ stream4.once("close", () => {
17038
+ if (!--streamsCount) {
17039
+ timer = setTimeout(() => {
17040
+ timer = null;
17041
+ removeSession();
17042
+ }, sessionTimeout);
17043
+ }
17044
+ });
17045
+ return stream4;
17046
+ };
17047
+ }
17048
+ session.once("close", removeSession);
17049
+ let entry = [
17050
+ session,
17051
+ options
17052
+ ];
17053
+ authoritySessions ? authoritySessions.push(entry) : authoritySessions = this.sessions[authority] = [entry];
17054
+ return session;
17055
+ }
17056
+ };
17057
+ var http2Sessions = new Http2Sessions();
16897
17058
  function dispatchBeforeRedirect(options, responseDetails) {
16898
17059
  if (options.beforeRedirects.proxy) {
16899
17060
  options.beforeRedirects.proxy(options);
@@ -16937,7 +17098,7 @@ function setProxy(options, configProxy, location) {
16937
17098
  }
16938
17099
  var isHttpAdapterSupported = typeof process !== "undefined" && utils_default.kindOf(process) === "process";
16939
17100
  var wrapAsync = (asyncExecutor) => {
16940
- return new Promise((resolve5, reject) => {
17101
+ return new Promise((resolve6, reject) => {
16941
17102
  let onDone;
16942
17103
  let isDone;
16943
17104
  const done = (value, isRejected) => {
@@ -16947,7 +17108,7 @@ var wrapAsync = (asyncExecutor) => {
16947
17108
  };
16948
17109
  const _resolve = (value) => {
16949
17110
  done(value);
16950
- resolve5(value);
17111
+ resolve6(value);
16951
17112
  };
16952
17113
  const _reject = (reason) => {
16953
17114
  done(reason, true);
@@ -16966,14 +17127,54 @@ var resolveFamily = ({ address, family }) => {
16966
17127
  };
16967
17128
  };
16968
17129
  var buildAddressEntry = (address, family) => resolveFamily(utils_default.isObject(address) ? address : { address, family });
17130
+ var http2Transport = {
17131
+ request(options, cb) {
17132
+ const authority = options.protocol + "//" + options.hostname + ":" + (options.port || 80);
17133
+ const { http2Options, headers } = options;
17134
+ const session = http2Sessions.getSession(authority, http2Options);
17135
+ const {
17136
+ HTTP2_HEADER_SCHEME,
17137
+ HTTP2_HEADER_METHOD,
17138
+ HTTP2_HEADER_PATH,
17139
+ HTTP2_HEADER_STATUS
17140
+ } = http2.constants;
17141
+ const http2Headers = {
17142
+ [HTTP2_HEADER_SCHEME]: options.protocol.replace(":", ""),
17143
+ [HTTP2_HEADER_METHOD]: options.method,
17144
+ [HTTP2_HEADER_PATH]: options.path
17145
+ };
17146
+ utils_default.forEach(headers, (header, name) => {
17147
+ name.charAt(0) !== ":" && (http2Headers[name] = header);
17148
+ });
17149
+ const req = session.request(http2Headers);
17150
+ req.once("response", (responseHeaders) => {
17151
+ const response = req;
17152
+ responseHeaders = Object.assign({}, responseHeaders);
17153
+ const status = responseHeaders[HTTP2_HEADER_STATUS];
17154
+ delete responseHeaders[HTTP2_HEADER_STATUS];
17155
+ response.headers = responseHeaders;
17156
+ response.statusCode = +status;
17157
+ cb(response);
17158
+ });
17159
+ return req;
17160
+ }
17161
+ };
16969
17162
  var http_default = isHttpAdapterSupported && function httpAdapter(config) {
16970
- return wrapAsync(async function dispatchHttpRequest(resolve5, reject, onDone) {
16971
- let { data, lookup, family } = config;
17163
+ return wrapAsync(async function dispatchHttpRequest(resolve6, reject, onDone) {
17164
+ let { data, lookup, family, httpVersion = 1, http2Options } = config;
16972
17165
  const { responseType, responseEncoding } = config;
16973
17166
  const method = config.method.toUpperCase();
16974
17167
  let isDone;
16975
17168
  let rejected = false;
16976
17169
  let req;
17170
+ httpVersion = +httpVersion;
17171
+ if (Number.isNaN(httpVersion)) {
17172
+ throw TypeError(`Invalid protocol version: '${config.httpVersion}' is not a number`);
17173
+ }
17174
+ if (httpVersion !== 1 && httpVersion !== 2) {
17175
+ throw TypeError(`Unsupported protocol version '${httpVersion}'`);
17176
+ }
17177
+ const isHttp2 = httpVersion === 2;
16977
17178
  if (lookup) {
16978
17179
  const _lookup = callbackify_default(lookup, (value) => utils_default.isArray(value) ? value : [value]);
16979
17180
  lookup = (hostname, opt, cb) => {
@@ -16986,7 +17187,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
16986
17187
  });
16987
17188
  };
16988
17189
  }
16989
- const emitter = new EventEmitter();
17190
+ const abortEmitter = new EventEmitter();
17191
+ function abort(reason) {
17192
+ try {
17193
+ abortEmitter.emit("abort", !reason || reason.type ? new CanceledError_default(null, config, req) : reason);
17194
+ } catch (err) {
17195
+ console.warn("emit error", err);
17196
+ }
17197
+ }
17198
+ abortEmitter.once("abort", reject);
16990
17199
  const onFinished = () => {
16991
17200
  if (config.cancelToken) {
16992
17201
  config.cancelToken.unsubscribe(abort);
@@ -16994,32 +17203,49 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
16994
17203
  if (config.signal) {
16995
17204
  config.signal.removeEventListener("abort", abort);
16996
17205
  }
16997
- emitter.removeAllListeners();
17206
+ abortEmitter.removeAllListeners();
16998
17207
  };
16999
- onDone((value, isRejected) => {
17000
- isDone = true;
17001
- if (isRejected) {
17002
- rejected = true;
17003
- onFinished();
17004
- }
17005
- });
17006
- function abort(reason) {
17007
- emitter.emit("abort", !reason || reason.type ? new CanceledError_default(null, config, req) : reason);
17008
- }
17009
- emitter.once("abort", reject);
17010
17208
  if (config.cancelToken || config.signal) {
17011
17209
  config.cancelToken && config.cancelToken.subscribe(abort);
17012
17210
  if (config.signal) {
17013
17211
  config.signal.aborted ? abort() : config.signal.addEventListener("abort", abort);
17014
17212
  }
17015
17213
  }
17214
+ onDone((response, isRejected) => {
17215
+ isDone = true;
17216
+ if (isRejected) {
17217
+ rejected = true;
17218
+ onFinished();
17219
+ return;
17220
+ }
17221
+ const { data: data2 } = response;
17222
+ if (data2 instanceof stream3.Readable || data2 instanceof stream3.Duplex) {
17223
+ const offListeners = stream3.finished(data2, () => {
17224
+ offListeners();
17225
+ onFinished();
17226
+ });
17227
+ } else {
17228
+ onFinished();
17229
+ }
17230
+ });
17016
17231
  const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
17017
17232
  const parsed = new URL(fullPath, platform_default.hasBrowserEnv ? platform_default.origin : void 0);
17018
17233
  const protocol = parsed.protocol || supportedProtocols[0];
17019
17234
  if (protocol === "data:") {
17235
+ if (config.maxContentLength > -1) {
17236
+ const dataUrl = String(config.url || fullPath || "");
17237
+ const estimated = estimateDataURLDecodedBytes(dataUrl);
17238
+ if (estimated > config.maxContentLength) {
17239
+ return reject(new AxiosError_default(
17240
+ "maxContentLength size of " + config.maxContentLength + " exceeded",
17241
+ AxiosError_default.ERR_BAD_RESPONSE,
17242
+ config
17243
+ ));
17244
+ }
17245
+ }
17020
17246
  let convertedData;
17021
17247
  if (method !== "GET") {
17022
- return settle(resolve5, reject, {
17248
+ return settle(resolve6, reject, {
17023
17249
  status: 405,
17024
17250
  statusText: "method not allowed",
17025
17251
  headers: {},
@@ -17041,7 +17267,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
17041
17267
  } else if (responseType === "stream") {
17042
17268
  convertedData = stream3.Readable.from(convertedData);
17043
17269
  }
17044
- return settle(resolve5, reject, {
17270
+ return settle(resolve6, reject, {
17045
17271
  data: convertedData,
17046
17272
  status: 200,
17047
17273
  statusText: "OK",
@@ -17139,9 +17365,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
17139
17365
  auth = urlUsername + ":" + urlPassword;
17140
17366
  }
17141
17367
  auth && headers.delete("authorization");
17142
- let path;
17368
+ let path2;
17143
17369
  try {
17144
- path = buildURL(
17370
+ path2 = buildURL(
17145
17371
  parsed.pathname + parsed.search,
17146
17372
  config.params,
17147
17373
  config.paramsSerializer
@@ -17159,7 +17385,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
17159
17385
  false
17160
17386
  );
17161
17387
  const options = {
17162
- path,
17388
+ path: path2,
17163
17389
  method,
17164
17390
  headers: headers.toJSON(),
17165
17391
  agents: { http: config.httpAgent, https: config.httpsAgent },
@@ -17167,7 +17393,8 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
17167
17393
  protocol,
17168
17394
  family,
17169
17395
  beforeRedirect: dispatchBeforeRedirect,
17170
- beforeRedirects: {}
17396
+ beforeRedirects: {},
17397
+ http2Options
17171
17398
  };
17172
17399
  !utils_default.isUndefined(lookup) && (options.lookup = lookup);
17173
17400
  if (config.socketPath) {
@@ -17180,18 +17407,22 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
17180
17407
  let transport;
17181
17408
  const isHttpsRequest = isHttps.test(options.protocol);
17182
17409
  options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
17183
- if (config.transport) {
17184
- transport = config.transport;
17185
- } else if (config.maxRedirects === 0) {
17186
- transport = isHttpsRequest ? https : http;
17410
+ if (isHttp2) {
17411
+ transport = http2Transport;
17187
17412
  } else {
17188
- if (config.maxRedirects) {
17189
- options.maxRedirects = config.maxRedirects;
17190
- }
17191
- if (config.beforeRedirect) {
17192
- options.beforeRedirects.config = config.beforeRedirect;
17413
+ if (config.transport) {
17414
+ transport = config.transport;
17415
+ } else if (config.maxRedirects === 0) {
17416
+ transport = isHttpsRequest ? https : http;
17417
+ } else {
17418
+ if (config.maxRedirects) {
17419
+ options.maxRedirects = config.maxRedirects;
17420
+ }
17421
+ if (config.beforeRedirect) {
17422
+ options.beforeRedirects.config = config.beforeRedirect;
17423
+ }
17424
+ transport = isHttpsRequest ? httpsFollow : httpFollow;
17193
17425
  }
17194
- transport = isHttpsRequest ? httpsFollow : httpFollow;
17195
17426
  }
17196
17427
  if (config.maxBodyLength > -1) {
17197
17428
  options.maxBodyLength = config.maxBodyLength;
@@ -17204,7 +17435,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
17204
17435
  req = transport.request(options, function handleResponse(res) {
17205
17436
  if (req.destroyed) return;
17206
17437
  const streams = [res];
17207
- const responseLength = +res.headers["content-length"];
17438
+ const responseLength = utils_default.toFiniteNumber(res.headers["content-length"]);
17208
17439
  if (onDownloadProgress || maxDownloadRate) {
17209
17440
  const transformStream = new AxiosTransformStream_default({
17210
17441
  maxRate: utils_default.toFiniteNumber(maxDownloadRate)
@@ -17246,10 +17477,6 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
17246
17477
  }
17247
17478
  }
17248
17479
  responseStream = streams.length > 1 ? stream3.pipeline(streams, utils_default.noop) : streams[0];
17249
- const offListeners = stream3.finished(responseStream, () => {
17250
- offListeners();
17251
- onFinished();
17252
- });
17253
17480
  const response = {
17254
17481
  status: res.statusCode,
17255
17482
  statusText: res.statusMessage,
@@ -17259,7 +17486,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
17259
17486
  };
17260
17487
  if (responseType === "stream") {
17261
17488
  response.data = responseStream;
17262
- settle(resolve5, reject, response);
17489
+ settle(resolve6, reject, response);
17263
17490
  } else {
17264
17491
  const responseBuffer = [];
17265
17492
  let totalResponseBytes = 0;
@@ -17269,7 +17496,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
17269
17496
  if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
17270
17497
  rejected = true;
17271
17498
  responseStream.destroy();
17272
- reject(new AxiosError_default(
17499
+ abort(new AxiosError_default(
17273
17500
  "maxContentLength size of " + config.maxContentLength + " exceeded",
17274
17501
  AxiosError_default.ERR_BAD_RESPONSE,
17275
17502
  config,
@@ -17307,19 +17534,22 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
17307
17534
  } catch (err) {
17308
17535
  return reject(AxiosError_default.from(err, null, config, response.request, response));
17309
17536
  }
17310
- settle(resolve5, reject, response);
17537
+ settle(resolve6, reject, response);
17311
17538
  });
17312
17539
  }
17313
- emitter.once("abort", (err) => {
17540
+ abortEmitter.once("abort", (err) => {
17314
17541
  if (!responseStream.destroyed) {
17315
17542
  responseStream.emit("error", err);
17316
17543
  responseStream.destroy();
17317
17544
  }
17318
17545
  });
17319
17546
  });
17320
- emitter.once("abort", (err) => {
17321
- reject(err);
17322
- req.destroy(err);
17547
+ abortEmitter.once("abort", (err) => {
17548
+ if (req.close) {
17549
+ req.close();
17550
+ } else {
17551
+ req.destroy(err);
17552
+ }
17323
17553
  });
17324
17554
  req.on("error", function handleRequestError(err) {
17325
17555
  reject(AxiosError_default.from(err, null, config, req));
@@ -17330,7 +17560,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
17330
17560
  if (config.timeout) {
17331
17561
  const timeout = parseInt(config.timeout, 10);
17332
17562
  if (Number.isNaN(timeout)) {
17333
- reject(new AxiosError_default(
17563
+ abort(new AxiosError_default(
17334
17564
  "error trying to parse `config.timeout` to int",
17335
17565
  AxiosError_default.ERR_BAD_OPTION_VALUE,
17336
17566
  config,
@@ -17345,14 +17575,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
17345
17575
  if (config.timeoutErrorMessage) {
17346
17576
  timeoutErrorMessage = config.timeoutErrorMessage;
17347
17577
  }
17348
- reject(new AxiosError_default(
17578
+ abort(new AxiosError_default(
17349
17579
  timeoutErrorMessage,
17350
17580
  transitional2.clarifyTimeoutError ? AxiosError_default.ETIMEDOUT : AxiosError_default.ECONNABORTED,
17351
17581
  config,
17352
17582
  req
17353
17583
  ));
17354
- abort();
17355
17584
  });
17585
+ } else {
17586
+ req.setTimeout(0);
17356
17587
  }
17357
17588
  if (utils_default.isStream(data)) {
17358
17589
  let ended = false;
@@ -17371,7 +17602,8 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
17371
17602
  });
17372
17603
  data.pipe(req);
17373
17604
  } else {
17374
- req.end(data);
17605
+ data && req.write(data);
17606
+ req.end();
17375
17607
  }
17376
17608
  });
17377
17609
  };
@@ -17389,20 +17621,33 @@ var isURLSameOrigin_default = platform_default.hasStandardBrowserEnv ? /* @__PUR
17389
17621
  var cookies_default = platform_default.hasStandardBrowserEnv ? (
17390
17622
  // Standard browser envs support document.cookie
17391
17623
  {
17392
- write(name, value, expires, path, domain, secure) {
17393
- const cookie = [name + "=" + encodeURIComponent(value)];
17394
- utils_default.isNumber(expires) && cookie.push("expires=" + new Date(expires).toGMTString());
17395
- utils_default.isString(path) && cookie.push("path=" + path);
17396
- utils_default.isString(domain) && cookie.push("domain=" + domain);
17397
- secure === true && cookie.push("secure");
17624
+ write(name, value, expires, path2, domain, secure, sameSite) {
17625
+ if (typeof document === "undefined") return;
17626
+ const cookie = [`${name}=${encodeURIComponent(value)}`];
17627
+ if (utils_default.isNumber(expires)) {
17628
+ cookie.push(`expires=${new Date(expires).toUTCString()}`);
17629
+ }
17630
+ if (utils_default.isString(path2)) {
17631
+ cookie.push(`path=${path2}`);
17632
+ }
17633
+ if (utils_default.isString(domain)) {
17634
+ cookie.push(`domain=${domain}`);
17635
+ }
17636
+ if (secure === true) {
17637
+ cookie.push("secure");
17638
+ }
17639
+ if (utils_default.isString(sameSite)) {
17640
+ cookie.push(`SameSite=${sameSite}`);
17641
+ }
17398
17642
  document.cookie = cookie.join("; ");
17399
17643
  },
17400
17644
  read(name) {
17401
- const match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
17402
- return match ? decodeURIComponent(match[3]) : null;
17645
+ if (typeof document === "undefined") return null;
17646
+ const match = document.cookie.match(new RegExp("(?:^|; )" + name + "=([^;]*)"));
17647
+ return match ? decodeURIComponent(match[1]) : null;
17403
17648
  },
17404
17649
  remove(name) {
17405
- this.write(name, "", Date.now() - 864e5);
17650
+ this.write(name, "", Date.now() - 864e5, "/");
17406
17651
  }
17407
17652
  }
17408
17653
  ) : (
@@ -17490,7 +17735,7 @@ function mergeConfig(config1, config2) {
17490
17735
  validateStatus: mergeDirectKeys,
17491
17736
  headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
17492
17737
  };
17493
- utils_default.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
17738
+ utils_default.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
17494
17739
  const merge3 = mergeMap[prop] || mergeDeepProperties;
17495
17740
  const configValue = merge3(config1[prop], config2[prop], prop);
17496
17741
  utils_default.isUndefined(configValue) && merge3 !== mergeDirectKeys || (config[prop] = configValue);
@@ -17510,13 +17755,17 @@ var resolveConfig_default = (config) => {
17510
17755
  "Basic " + btoa((auth.username || "") + ":" + (auth.password ? unescape(encodeURIComponent(auth.password)) : ""))
17511
17756
  );
17512
17757
  }
17513
- let contentType;
17514
17758
  if (utils_default.isFormData(data)) {
17515
17759
  if (platform_default.hasStandardBrowserEnv || platform_default.hasStandardBrowserWebWorkerEnv) {
17516
17760
  headers.setContentType(void 0);
17517
- } else if ((contentType = headers.getContentType()) !== false) {
17518
- const [type2, ...tokens] = contentType ? contentType.split(";").map((token) => token.trim()).filter(Boolean) : [];
17519
- headers.setContentType([type2 || "multipart/form-data", ...tokens].join("; "));
17761
+ } else if (utils_default.isFunction(data.getHeaders)) {
17762
+ const formHeaders = data.getHeaders();
17763
+ const allowedHeaders = ["content-type", "content-length"];
17764
+ Object.entries(formHeaders).forEach(([key, val]) => {
17765
+ if (allowedHeaders.includes(key.toLowerCase())) {
17766
+ headers.set(key, val);
17767
+ }
17768
+ });
17520
17769
  }
17521
17770
  }
17522
17771
  if (platform_default.hasStandardBrowserEnv) {
@@ -17534,7 +17783,7 @@ var resolveConfig_default = (config) => {
17534
17783
  // node_modules/axios/lib/adapters/xhr.js
17535
17784
  var isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
17536
17785
  var xhr_default = isXHRAdapterSupported && function(config) {
17537
- return new Promise(function dispatchXhrRequest(resolve5, reject) {
17786
+ return new Promise(function dispatchXhrRequest(resolve6, reject) {
17538
17787
  const _config = resolveConfig_default(config);
17539
17788
  let requestData = _config.data;
17540
17789
  const requestHeaders = AxiosHeaders_default.from(_config.headers).normalize();
@@ -17568,7 +17817,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
17568
17817
  request
17569
17818
  };
17570
17819
  settle(function _resolve(value) {
17571
- resolve5(value);
17820
+ resolve6(value);
17572
17821
  done();
17573
17822
  }, function _reject(err) {
17574
17823
  reject(err);
@@ -17596,8 +17845,11 @@ var xhr_default = isXHRAdapterSupported && function(config) {
17596
17845
  reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED, config, request));
17597
17846
  request = null;
17598
17847
  };
17599
- request.onerror = function handleError() {
17600
- reject(new AxiosError_default("Network Error", AxiosError_default.ERR_NETWORK, config, request));
17848
+ request.onerror = function handleError(event) {
17849
+ const msg = event && event.message ? event.message : "Network Error";
17850
+ const err = new AxiosError_default(msg, AxiosError_default.ERR_NETWORK, config, request);
17851
+ err.event = event || null;
17852
+ reject(err);
17601
17853
  request = null;
17602
17854
  };
17603
17855
  request.ontimeout = function handleTimeout() {
@@ -17772,9 +18024,16 @@ var trackStream = (stream4, chunkSize, onProgress, onFinish) => {
17772
18024
  };
17773
18025
 
17774
18026
  // node_modules/axios/lib/adapters/fetch.js
17775
- var isFetchSupported = typeof fetch === "function" && typeof Request === "function" && typeof Response === "function";
17776
- var isReadableStreamSupported = isFetchSupported && typeof ReadableStream === "function";
17777
- var encodeText = isFetchSupported && (typeof TextEncoder === "function" ? /* @__PURE__ */ ((encoder) => (str2) => encoder.encode(str2))(new TextEncoder()) : async (str2) => new Uint8Array(await new Response(str2).arrayBuffer()));
18027
+ var DEFAULT_CHUNK_SIZE = 64 * 1024;
18028
+ var { isFunction: isFunction2 } = utils_default;
18029
+ var globalFetchAPI = (({ Request, Response }) => ({
18030
+ Request,
18031
+ Response
18032
+ }))(utils_default.global);
18033
+ var {
18034
+ ReadableStream: ReadableStream2,
18035
+ TextEncoder: TextEncoder2
18036
+ } = utils_default.global;
17778
18037
  var test = (fn, ...args) => {
17779
18038
  try {
17780
18039
  return !!fn(...args);
@@ -17782,164 +18041,204 @@ var test = (fn, ...args) => {
17782
18041
  return false;
17783
18042
  }
17784
18043
  };
17785
- var supportsRequestStream = isReadableStreamSupported && test(() => {
17786
- let duplexAccessed = false;
17787
- const hasContentType = new Request(platform_default.origin, {
17788
- body: new ReadableStream(),
17789
- method: "POST",
17790
- get duplex() {
17791
- duplexAccessed = true;
17792
- return "half";
17793
- }
17794
- }).headers.has("Content-Type");
17795
- return duplexAccessed && !hasContentType;
17796
- });
17797
- var DEFAULT_CHUNK_SIZE = 64 * 1024;
17798
- var supportsResponseStream = isReadableStreamSupported && test(() => utils_default.isReadableStream(new Response("").body));
17799
- var resolvers = {
17800
- stream: supportsResponseStream && ((res) => res.body)
17801
- };
17802
- isFetchSupported && ((res) => {
17803
- ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type2) => {
17804
- !resolvers[type2] && (resolvers[type2] = utils_default.isFunction(res[type2]) ? (res2) => res2[type2]() : (_, config) => {
17805
- throw new AxiosError_default(`Response type '${type2}' is not supported`, AxiosError_default.ERR_NOT_SUPPORT, config);
17806
- });
17807
- });
17808
- })(new Response());
17809
- var getBodyLength = async (body) => {
17810
- if (body == null) {
17811
- return 0;
17812
- }
17813
- if (utils_default.isBlob(body)) {
17814
- return body.size;
18044
+ var factory = (env2) => {
18045
+ env2 = utils_default.merge.call({
18046
+ skipUndefined: true
18047
+ }, globalFetchAPI, env2);
18048
+ const { fetch: envFetch, Request, Response } = env2;
18049
+ const isFetchSupported = envFetch ? isFunction2(envFetch) : typeof fetch === "function";
18050
+ const isRequestSupported = isFunction2(Request);
18051
+ const isResponseSupported = isFunction2(Response);
18052
+ if (!isFetchSupported) {
18053
+ return false;
17815
18054
  }
17816
- if (utils_default.isSpecCompliantForm(body)) {
17817
- const _request = new Request(platform_default.origin, {
18055
+ const isReadableStreamSupported = isFetchSupported && isFunction2(ReadableStream2);
18056
+ const encodeText = isFetchSupported && (typeof TextEncoder2 === "function" ? /* @__PURE__ */ ((encoder) => (str2) => encoder.encode(str2))(new TextEncoder2()) : async (str2) => new Uint8Array(await new Request(str2).arrayBuffer()));
18057
+ const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
18058
+ let duplexAccessed = false;
18059
+ const hasContentType = new Request(platform_default.origin, {
18060
+ body: new ReadableStream2(),
17818
18061
  method: "POST",
17819
- body
17820
- });
17821
- return (await _request.arrayBuffer()).byteLength;
17822
- }
17823
- if (utils_default.isArrayBufferView(body) || utils_default.isArrayBuffer(body)) {
17824
- return body.byteLength;
17825
- }
17826
- if (utils_default.isURLSearchParams(body)) {
17827
- body = body + "";
17828
- }
17829
- if (utils_default.isString(body)) {
17830
- return (await encodeText(body)).byteLength;
17831
- }
17832
- };
17833
- var resolveBodyLength = async (headers, body) => {
17834
- const length = utils_default.toFiniteNumber(headers.getContentLength());
17835
- return length == null ? getBodyLength(body) : length;
17836
- };
17837
- var fetch_default = isFetchSupported && (async (config) => {
17838
- let {
17839
- url: url2,
17840
- method,
17841
- data,
17842
- signal,
17843
- cancelToken,
17844
- timeout,
17845
- onDownloadProgress,
17846
- onUploadProgress,
17847
- responseType,
17848
- headers,
17849
- withCredentials = "same-origin",
17850
- fetchOptions
17851
- } = resolveConfig_default(config);
17852
- responseType = responseType ? (responseType + "").toLowerCase() : "text";
17853
- let composedSignal = composeSignals_default([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
17854
- let request;
17855
- const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
17856
- composedSignal.unsubscribe();
18062
+ get duplex() {
18063
+ duplexAccessed = true;
18064
+ return "half";
18065
+ }
18066
+ }).headers.has("Content-Type");
18067
+ return duplexAccessed && !hasContentType;
17857
18068
  });
17858
- let requestContentLength;
17859
- try {
17860
- if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
17861
- let _request = new Request(url2, {
17862
- method: "POST",
17863
- body: data,
17864
- duplex: "half"
18069
+ const supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(() => utils_default.isReadableStream(new Response("").body));
18070
+ const resolvers = {
18071
+ stream: supportsResponseStream && ((res) => res.body)
18072
+ };
18073
+ isFetchSupported && (() => {
18074
+ ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type2) => {
18075
+ !resolvers[type2] && (resolvers[type2] = (res, config) => {
18076
+ let method = res && res[type2];
18077
+ if (method) {
18078
+ return method.call(res);
18079
+ }
18080
+ throw new AxiosError_default(`Response type '${type2}' is not supported`, AxiosError_default.ERR_NOT_SUPPORT, config);
17865
18081
  });
17866
- let contentTypeHeader;
17867
- if (utils_default.isFormData(data) && (contentTypeHeader = _request.headers.get("content-type"))) {
17868
- headers.setContentType(contentTypeHeader);
17869
- }
17870
- if (_request.body) {
17871
- const [onProgress, flush] = progressEventDecorator(
17872
- requestContentLength,
17873
- progressEventReducer(asyncDecorator(onUploadProgress))
17874
- );
17875
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
17876
- }
18082
+ });
18083
+ })();
18084
+ const getBodyLength = async (body) => {
18085
+ if (body == null) {
18086
+ return 0;
17877
18087
  }
17878
- if (!utils_default.isString(withCredentials)) {
17879
- withCredentials = withCredentials ? "include" : "omit";
18088
+ if (utils_default.isBlob(body)) {
18089
+ return body.size;
17880
18090
  }
17881
- const isCredentialsSupported = "credentials" in Request.prototype;
17882
- request = new Request(url2, {
17883
- ...fetchOptions,
17884
- signal: composedSignal,
17885
- method: method.toUpperCase(),
17886
- headers: headers.normalize().toJSON(),
17887
- body: data,
17888
- duplex: "half",
17889
- credentials: isCredentialsSupported ? withCredentials : void 0
17890
- });
17891
- let response = await fetch(request, fetchOptions);
17892
- const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
17893
- if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
17894
- const options = {};
17895
- ["status", "statusText", "headers"].forEach((prop) => {
17896
- options[prop] = response[prop];
18091
+ if (utils_default.isSpecCompliantForm(body)) {
18092
+ const _request = new Request(platform_default.origin, {
18093
+ method: "POST",
18094
+ body
17897
18095
  });
17898
- const responseContentLength = utils_default.toFiniteNumber(response.headers.get("content-length"));
17899
- const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
17900
- responseContentLength,
17901
- progressEventReducer(asyncDecorator(onDownloadProgress), true)
17902
- ) || [];
17903
- response = new Response(
17904
- trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
17905
- flush && flush();
17906
- unsubscribe && unsubscribe();
17907
- }),
17908
- options
17909
- );
18096
+ return (await _request.arrayBuffer()).byteLength;
17910
18097
  }
17911
- responseType = responseType || "text";
17912
- let responseData = await resolvers[utils_default.findKey(resolvers, responseType) || "text"](response, config);
17913
- !isStreamResponse && unsubscribe && unsubscribe();
17914
- return await new Promise((resolve5, reject) => {
17915
- settle(resolve5, reject, {
17916
- data: responseData,
17917
- headers: AxiosHeaders_default.from(response.headers),
17918
- status: response.status,
17919
- statusText: response.statusText,
17920
- config,
17921
- request
17922
- });
18098
+ if (utils_default.isArrayBufferView(body) || utils_default.isArrayBuffer(body)) {
18099
+ return body.byteLength;
18100
+ }
18101
+ if (utils_default.isURLSearchParams(body)) {
18102
+ body = body + "";
18103
+ }
18104
+ if (utils_default.isString(body)) {
18105
+ return (await encodeText(body)).byteLength;
18106
+ }
18107
+ };
18108
+ const resolveBodyLength = async (headers, body) => {
18109
+ const length = utils_default.toFiniteNumber(headers.getContentLength());
18110
+ return length == null ? getBodyLength(body) : length;
18111
+ };
18112
+ return async (config) => {
18113
+ let {
18114
+ url: url2,
18115
+ method,
18116
+ data,
18117
+ signal,
18118
+ cancelToken,
18119
+ timeout,
18120
+ onDownloadProgress,
18121
+ onUploadProgress,
18122
+ responseType,
18123
+ headers,
18124
+ withCredentials = "same-origin",
18125
+ fetchOptions
18126
+ } = resolveConfig_default(config);
18127
+ let _fetch = envFetch || fetch;
18128
+ responseType = responseType ? (responseType + "").toLowerCase() : "text";
18129
+ let composedSignal = composeSignals_default([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
18130
+ let request = null;
18131
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
18132
+ composedSignal.unsubscribe();
17923
18133
  });
17924
- } catch (err) {
17925
- unsubscribe && unsubscribe();
17926
- if (err && err.name === "TypeError" && /Load failed|fetch/i.test(err.message)) {
17927
- throw Object.assign(
17928
- new AxiosError_default("Network Error", AxiosError_default.ERR_NETWORK, config, request),
17929
- {
17930
- cause: err.cause || err
18134
+ let requestContentLength;
18135
+ try {
18136
+ if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
18137
+ let _request = new Request(url2, {
18138
+ method: "POST",
18139
+ body: data,
18140
+ duplex: "half"
18141
+ });
18142
+ let contentTypeHeader;
18143
+ if (utils_default.isFormData(data) && (contentTypeHeader = _request.headers.get("content-type"))) {
18144
+ headers.setContentType(contentTypeHeader);
17931
18145
  }
17932
- );
18146
+ if (_request.body) {
18147
+ const [onProgress, flush] = progressEventDecorator(
18148
+ requestContentLength,
18149
+ progressEventReducer(asyncDecorator(onUploadProgress))
18150
+ );
18151
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
18152
+ }
18153
+ }
18154
+ if (!utils_default.isString(withCredentials)) {
18155
+ withCredentials = withCredentials ? "include" : "omit";
18156
+ }
18157
+ const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
18158
+ const resolvedOptions = {
18159
+ ...fetchOptions,
18160
+ signal: composedSignal,
18161
+ method: method.toUpperCase(),
18162
+ headers: headers.normalize().toJSON(),
18163
+ body: data,
18164
+ duplex: "half",
18165
+ credentials: isCredentialsSupported ? withCredentials : void 0
18166
+ };
18167
+ request = isRequestSupported && new Request(url2, resolvedOptions);
18168
+ let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url2, resolvedOptions));
18169
+ const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
18170
+ if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
18171
+ const options = {};
18172
+ ["status", "statusText", "headers"].forEach((prop) => {
18173
+ options[prop] = response[prop];
18174
+ });
18175
+ const responseContentLength = utils_default.toFiniteNumber(response.headers.get("content-length"));
18176
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
18177
+ responseContentLength,
18178
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
18179
+ ) || [];
18180
+ response = new Response(
18181
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
18182
+ flush && flush();
18183
+ unsubscribe && unsubscribe();
18184
+ }),
18185
+ options
18186
+ );
18187
+ }
18188
+ responseType = responseType || "text";
18189
+ let responseData = await resolvers[utils_default.findKey(resolvers, responseType) || "text"](response, config);
18190
+ !isStreamResponse && unsubscribe && unsubscribe();
18191
+ return await new Promise((resolve6, reject) => {
18192
+ settle(resolve6, reject, {
18193
+ data: responseData,
18194
+ headers: AxiosHeaders_default.from(response.headers),
18195
+ status: response.status,
18196
+ statusText: response.statusText,
18197
+ config,
18198
+ request
18199
+ });
18200
+ });
18201
+ } catch (err) {
18202
+ unsubscribe && unsubscribe();
18203
+ if (err && err.name === "TypeError" && /Load failed|fetch/i.test(err.message)) {
18204
+ throw Object.assign(
18205
+ new AxiosError_default("Network Error", AxiosError_default.ERR_NETWORK, config, request),
18206
+ {
18207
+ cause: err.cause || err
18208
+ }
18209
+ );
18210
+ }
18211
+ throw AxiosError_default.from(err, err && err.code, config, request);
17933
18212
  }
17934
- throw AxiosError_default.from(err, err && err.code, config, request);
18213
+ };
18214
+ };
18215
+ var seedCache = /* @__PURE__ */ new Map();
18216
+ var getFetch = (config) => {
18217
+ let env2 = config && config.env || {};
18218
+ const { fetch: fetch2, Request, Response } = env2;
18219
+ const seeds = [
18220
+ Request,
18221
+ Response,
18222
+ fetch2
18223
+ ];
18224
+ let len = seeds.length, i = len, seed, target, map2 = seedCache;
18225
+ while (i--) {
18226
+ seed = seeds[i];
18227
+ target = map2.get(seed);
18228
+ target === void 0 && map2.set(seed, target = i ? /* @__PURE__ */ new Map() : factory(env2));
18229
+ map2 = target;
17935
18230
  }
17936
- });
18231
+ return target;
18232
+ };
18233
+ var adapter = getFetch();
17937
18234
 
17938
18235
  // node_modules/axios/lib/adapters/adapters.js
17939
18236
  var knownAdapters = {
17940
18237
  http: http_default,
17941
18238
  xhr: xhr_default,
17942
- fetch: fetch_default
18239
+ fetch: {
18240
+ get: getFetch
18241
+ }
17943
18242
  };
17944
18243
  utils_default.forEach(knownAdapters, (fn, value) => {
17945
18244
  if (fn) {
@@ -17951,41 +18250,50 @@ utils_default.forEach(knownAdapters, (fn, value) => {
17951
18250
  }
17952
18251
  });
17953
18252
  var renderReason = (reason) => `- ${reason}`;
17954
- var isResolvedHandle = (adapter) => utils_default.isFunction(adapter) || adapter === null || adapter === false;
17955
- var adapters_default = {
17956
- getAdapter: (adapters) => {
17957
- adapters = utils_default.isArray(adapters) ? adapters : [adapters];
17958
- const { length } = adapters;
17959
- let nameOrAdapter;
17960
- let adapter;
17961
- const rejectedReasons = {};
17962
- for (let i = 0; i < length; i++) {
17963
- nameOrAdapter = adapters[i];
17964
- let id;
17965
- adapter = nameOrAdapter;
17966
- if (!isResolvedHandle(nameOrAdapter)) {
17967
- adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
17968
- if (adapter === void 0) {
17969
- throw new AxiosError_default(`Unknown adapter '${id}'`);
17970
- }
17971
- }
17972
- if (adapter) {
17973
- break;
17974
- }
17975
- rejectedReasons[id || "#" + i] = adapter;
17976
- }
17977
- if (!adapter) {
17978
- const reasons = Object.entries(rejectedReasons).map(
17979
- ([id, state]) => `adapter ${id} ` + (state === false ? "is not supported by the environment" : "is not available in the build")
17980
- );
17981
- let s = length ? reasons.length > 1 ? "since :\n" + reasons.map(renderReason).join("\n") : " " + renderReason(reasons[0]) : "as no adapter specified";
17982
- throw new AxiosError_default(
17983
- `There is no suitable adapter to dispatch the request ` + s,
17984
- "ERR_NOT_SUPPORT"
17985
- );
18253
+ var isResolvedHandle = (adapter2) => utils_default.isFunction(adapter2) || adapter2 === null || adapter2 === false;
18254
+ function getAdapter(adapters, config) {
18255
+ adapters = utils_default.isArray(adapters) ? adapters : [adapters];
18256
+ const { length } = adapters;
18257
+ let nameOrAdapter;
18258
+ let adapter2;
18259
+ const rejectedReasons = {};
18260
+ for (let i = 0; i < length; i++) {
18261
+ nameOrAdapter = adapters[i];
18262
+ let id;
18263
+ adapter2 = nameOrAdapter;
18264
+ if (!isResolvedHandle(nameOrAdapter)) {
18265
+ adapter2 = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
18266
+ if (adapter2 === void 0) {
18267
+ throw new AxiosError_default(`Unknown adapter '${id}'`);
18268
+ }
18269
+ }
18270
+ if (adapter2 && (utils_default.isFunction(adapter2) || (adapter2 = adapter2.get(config)))) {
18271
+ break;
17986
18272
  }
17987
- return adapter;
17988
- },
18273
+ rejectedReasons[id || "#" + i] = adapter2;
18274
+ }
18275
+ if (!adapter2) {
18276
+ const reasons = Object.entries(rejectedReasons).map(
18277
+ ([id, state]) => `adapter ${id} ` + (state === false ? "is not supported by the environment" : "is not available in the build")
18278
+ );
18279
+ let s = length ? reasons.length > 1 ? "since :\n" + reasons.map(renderReason).join("\n") : " " + renderReason(reasons[0]) : "as no adapter specified";
18280
+ throw new AxiosError_default(
18281
+ `There is no suitable adapter to dispatch the request ` + s,
18282
+ "ERR_NOT_SUPPORT"
18283
+ );
18284
+ }
18285
+ return adapter2;
18286
+ }
18287
+ var adapters_default = {
18288
+ /**
18289
+ * Resolve an adapter from a list of adapter names or functions.
18290
+ * @type {Function}
18291
+ */
18292
+ getAdapter,
18293
+ /**
18294
+ * Exposes all known adapters
18295
+ * @type {Object<string, Function|Object>}
18296
+ */
17989
18297
  adapters: knownAdapters
17990
18298
  };
17991
18299
 
@@ -18008,8 +18316,8 @@ function dispatchRequest(config) {
18008
18316
  if (["post", "put", "patch"].indexOf(config.method) !== -1) {
18009
18317
  config.headers.setContentType("application/x-www-form-urlencoded", false);
18010
18318
  }
18011
- const adapter = adapters_default.getAdapter(config.adapter || defaults_default.adapter);
18012
- return adapter(config).then(function onAdapterResolution(response) {
18319
+ const adapter2 = adapters_default.getAdapter(config.adapter || defaults_default.adapter, config);
18320
+ return adapter2(config).then(function onAdapterResolution(response) {
18013
18321
  throwIfCancellationRequested(config);
18014
18322
  response.data = transformData.call(
18015
18323
  config,
@@ -18204,8 +18512,8 @@ var Axios = class {
18204
18512
  let len;
18205
18513
  if (!synchronousRequestInterceptors) {
18206
18514
  const chain = [dispatchRequest.bind(this), void 0];
18207
- chain.unshift.apply(chain, requestInterceptorChain);
18208
- chain.push.apply(chain, responseInterceptorChain);
18515
+ chain.unshift(...requestInterceptorChain);
18516
+ chain.push(...responseInterceptorChain);
18209
18517
  len = chain.length;
18210
18518
  promise = Promise.resolve(config);
18211
18519
  while (i < len) {
@@ -18215,7 +18523,6 @@ var Axios = class {
18215
18523
  }
18216
18524
  len = requestInterceptorChain.length;
18217
18525
  let newConfig = config;
18218
- i = 0;
18219
18526
  while (i < len) {
18220
18527
  const onFulfilled = requestInterceptorChain[i++];
18221
18528
  const onRejected = requestInterceptorChain[i++];
@@ -18278,8 +18585,8 @@ var CancelToken = class _CancelToken {
18278
18585
  throw new TypeError("executor must be a function.");
18279
18586
  }
18280
18587
  let resolvePromise;
18281
- this.promise = new Promise(function promiseExecutor(resolve5) {
18282
- resolvePromise = resolve5;
18588
+ this.promise = new Promise(function promiseExecutor(resolve6) {
18589
+ resolvePromise = resolve6;
18283
18590
  });
18284
18591
  const token = this;
18285
18592
  this.promise.then((cancel) => {
@@ -18292,9 +18599,9 @@ var CancelToken = class _CancelToken {
18292
18599
  });
18293
18600
  this.promise.then = (onfulfilled) => {
18294
18601
  let _resolve;
18295
- const promise = new Promise((resolve5) => {
18296
- token.subscribe(resolve5);
18297
- _resolve = resolve5;
18602
+ const promise = new Promise((resolve6) => {
18603
+ token.subscribe(resolve6);
18604
+ _resolve = resolve6;
18298
18605
  }).then(onfulfilled);
18299
18606
  promise.cancel = function reject() {
18300
18607
  token.unsubscribe(_resolve);
@@ -18445,7 +18752,13 @@ var HttpStatusCode = {
18445
18752
  InsufficientStorage: 507,
18446
18753
  LoopDetected: 508,
18447
18754
  NotExtended: 510,
18448
- NetworkAuthenticationRequired: 511
18755
+ NetworkAuthenticationRequired: 511,
18756
+ WebServerIsDown: 521,
18757
+ ConnectionTimedOut: 522,
18758
+ OriginIsUnreachable: 523,
18759
+ TimeoutOccurred: 524,
18760
+ SslHandshakeFailed: 525,
18761
+ InvalidSslCertificate: 526
18449
18762
  };
18450
18763
  Object.entries(HttpStatusCode).forEach(([key, value]) => {
18451
18764
  HttpStatusCode[value] = key;
@@ -18501,7 +18814,7 @@ var {
18501
18814
  AxiosHeaders: AxiosHeaders2,
18502
18815
  HttpStatusCode: HttpStatusCode2,
18503
18816
  formToJSON,
18504
- getAdapter,
18817
+ getAdapter: getAdapter2,
18505
18818
  mergeConfig: mergeConfig2
18506
18819
  } = axios_default;
18507
18820
 
@@ -18541,6 +18854,26 @@ function isGetLikeMethod(method) {
18541
18854
  }
18542
18855
 
18543
18856
  // src/api-client.ts
18857
+ var SYSTEM_CONTROLLED_HEADERS = /* @__PURE__ */ new Set([
18858
+ "host",
18859
+ // Controlled by HTTP client based on URL
18860
+ "content-length",
18861
+ // Calculated by HTTP client from body
18862
+ "transfer-encoding",
18863
+ // Managed by HTTP client for chunked encoding
18864
+ "connection",
18865
+ // HTTP connection management
18866
+ "upgrade",
18867
+ // Protocol upgrade (WebSocket, HTTP/2)
18868
+ "te",
18869
+ // Transfer encoding preferences
18870
+ "trailer",
18871
+ // Trailer fields in chunked transfer
18872
+ "proxy-connection",
18873
+ // Proxy connection management
18874
+ "keep-alive"
18875
+ // Connection keep-alive settings
18876
+ ]);
18544
18877
  var ApiClient = class {
18545
18878
  axiosInstance;
18546
18879
  toolsMap = /* @__PURE__ */ new Map();
@@ -18556,7 +18889,15 @@ var ApiClient = class {
18556
18889
  */
18557
18890
  constructor(baseUrl, authProviderOrHeaders, specLoader) {
18558
18891
  this.axiosInstance = axios_default.create({
18559
- baseURL: baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`
18892
+ baseURL: baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`,
18893
+ timeout: 3e4,
18894
+ // 30 second timeout to prevent indefinite hangs
18895
+ maxContentLength: 50 * 1024 * 1024,
18896
+ // 50MB response body limit
18897
+ maxBodyLength: 50 * 1024 * 1024,
18898
+ // 50MB request body limit
18899
+ maxRedirects: 5
18900
+ // Limit redirect chains to prevent abuse
18560
18901
  });
18561
18902
  if (!authProviderOrHeaders) {
18562
18903
  this.authProvider = new StaticAuthProvider();
@@ -18621,10 +18962,10 @@ var ApiClient = class {
18621
18962
  if (toolId === "INVOKE-API-ENDPOINT") {
18622
18963
  return this.handleInvokeApiEndpoint(toolId, params);
18623
18964
  }
18624
- const { method, path } = this.parseToolId(toolId);
18965
+ const { method, path: path2 } = this.parseToolId(toolId);
18625
18966
  const toolDef = this.getToolDefinition(toolId);
18626
18967
  const paramsCopy = { ...params };
18627
- let resolvedPath = path;
18968
+ let resolvedPath = path2;
18628
18969
  const escapeRegExp = (str2) => {
18629
18970
  return str2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
18630
18971
  };
@@ -18654,7 +18995,17 @@ var ApiClient = class {
18654
18995
  queryParams[key] = value;
18655
18996
  delete paramsCopy[key];
18656
18997
  } else if (paramLocation === "header") {
18657
- headerParams[key] = String(value);
18998
+ const headerName = key.toLowerCase();
18999
+ if (SYSTEM_CONTROLLED_HEADERS.has(headerName)) {
19000
+ throw new Error(
19001
+ `Cannot set system-controlled header "${key}". This header is managed by the HTTP client and cannot be overridden.`
19002
+ );
19003
+ }
19004
+ const headerValue = String(value);
19005
+ if (headerValue.includes("\r") || headerValue.includes("\n")) {
19006
+ throw new Error(`Header value for "${key}" contains invalid characters (CR/LF)`);
19007
+ }
19008
+ headerParams[key] = headerValue;
18658
19009
  delete paramsCopy[key];
18659
19010
  }
18660
19011
  }
@@ -18679,6 +19030,16 @@ var ApiClient = class {
18679
19030
  }
18680
19031
  }
18681
19032
  const authHeaders = await this.authProvider.getAuthHeaders();
19033
+ if (authHeaders && Object.keys(authHeaders).length > 0) {
19034
+ const authHeadersLower = Object.keys(authHeaders).map((k) => k.toLowerCase());
19035
+ for (const headerKey of Object.keys(headerParams)) {
19036
+ if (authHeadersLower.includes(headerKey.toLowerCase())) {
19037
+ throw new Error(
19038
+ `Cannot override authentication header "${headerKey}". This header is set by the authentication provider.`
19039
+ );
19040
+ }
19041
+ }
19042
+ }
18682
19043
  const config = {
18683
19044
  method: method.toLowerCase(),
18684
19045
  url: resolvedPath,
@@ -18709,7 +19070,10 @@ var ApiClient = class {
18709
19070
  }
18710
19071
  }
18711
19072
  throw new Error(
18712
- `API request failed: ${axiosError.message}${axiosError.response ? ` (${axiosError.response.status}: ${typeof axiosError.response.data === "object" ? JSON.stringify(axiosError.response.data) : axiosError.response.data})` : ""}`
19073
+ `API request failed: ${axiosError.message}${axiosError.response ? ` (${axiosError.response.status}: ${this.sanitizeErrorData(
19074
+ axiosError.response.data,
19075
+ axiosError.response.status
19076
+ )})` : ""}`
18713
19077
  );
18714
19078
  }
18715
19079
  throw error;
@@ -18742,6 +19106,25 @@ var ApiClient = class {
18742
19106
  }
18743
19107
  return result;
18744
19108
  }
19109
+ /**
19110
+ * Sanitize error data to prevent information disclosure
19111
+ * Redacts sensitive data from authentication errors and truncates large responses
19112
+ *
19113
+ * @param data - The error response data
19114
+ * @param statusCode - The HTTP status code
19115
+ * @returns Sanitized error data string
19116
+ */
19117
+ sanitizeErrorData(data, statusCode) {
19118
+ if (statusCode === 401 || statusCode === 403) {
19119
+ return "[Authentication/Authorization error - details redacted for security]";
19120
+ }
19121
+ const dataStr = typeof data === "object" ? JSON.stringify(data) : String(data);
19122
+ const MAX_ERROR_LENGTH = 1e3;
19123
+ if (dataStr.length > MAX_ERROR_LENGTH) {
19124
+ return dataStr.substring(0, MAX_ERROR_LENGTH) + "... [truncated]";
19125
+ }
19126
+ return dataStr;
19127
+ }
18745
19128
  /**
18746
19129
  * Handle the LIST-API-ENDPOINTS meta-tool
18747
19130
  * Returns a list of all available API endpoints from the loaded tools
@@ -18749,7 +19132,7 @@ var ApiClient = class {
18749
19132
  async handleListApiEndpoints() {
18750
19133
  const endpoints = [];
18751
19134
  if (this.openApiSpec) {
18752
- for (const [path, pathItem] of Object.entries(this.openApiSpec.paths)) {
19135
+ for (const [path2, pathItem] of Object.entries(this.openApiSpec.paths)) {
18753
19136
  if (!pathItem) continue;
18754
19137
  for (const [method, operation] of Object.entries(pathItem)) {
18755
19138
  if (method === "parameters" || !operation) continue;
@@ -18759,7 +19142,7 @@ var ApiClient = class {
18759
19142
  const op = operation;
18760
19143
  endpoints.push({
18761
19144
  method: method.toUpperCase(),
18762
- path,
19145
+ path: path2,
18763
19146
  summary: op.summary || "",
18764
19147
  description: op.description || "",
18765
19148
  operationId: op.operationId || "",
@@ -18773,13 +19156,13 @@ var ApiClient = class {
18773
19156
  continue;
18774
19157
  }
18775
19158
  try {
18776
- const { method, path } = this.parseToolId(toolId);
19159
+ const { method, path: path2 } = this.parseToolId(toolId);
18777
19160
  endpoints.push({
18778
19161
  toolId,
18779
19162
  name: tool.name,
18780
19163
  description: tool.description,
18781
19164
  method: method.toUpperCase(),
18782
- path
19165
+ path: path2
18783
19166
  });
18784
19167
  } catch (error) {
18785
19168
  continue;
@@ -18837,8 +19220,8 @@ var ApiClient = class {
18837
19220
  let matchingToolId;
18838
19221
  for (const [toolId2, tool] of this.toolsMap.entries()) {
18839
19222
  try {
18840
- const { path } = this.parseToolId(toolId2);
18841
- if (path === endpoint) {
19223
+ const { path: path2 } = this.parseToolId(toolId2);
19224
+ if (path2 === endpoint) {
18842
19225
  matchingTool = tool;
18843
19226
  matchingToolId = toolId2;
18844
19227
  break;
@@ -18875,8 +19258,8 @@ var ApiClient = class {
18875
19258
  } else if (this.openApiSpec) {
18876
19259
  const pathItem = this.openApiSpec.paths[endpoint];
18877
19260
  if (pathItem && pathItem[method.toLowerCase()]) {
18878
- const { method: httpMethod, path } = { method: method.toUpperCase(), path: endpoint };
18879
- return this.makeDirectHttpRequest(httpMethod, path, endpointParams);
19261
+ const { method: httpMethod, path: path2 } = { method: method.toUpperCase(), path: endpoint };
19262
+ return this.makeDirectHttpRequest(httpMethod, path2, endpointParams);
18880
19263
  } else {
18881
19264
  throw new Error(
18882
19265
  `No endpoint found for path '${endpoint}' with method '${method}' in tool '${toolId2}'`
@@ -18905,11 +19288,11 @@ var ApiClient = class {
18905
19288
  * Make a direct HTTP request without going through the tool system
18906
19289
  * Used by dynamic meta-tools when we have OpenAPI spec but no corresponding tool
18907
19290
  */
18908
- async makeDirectHttpRequest(method, path, params) {
19291
+ async makeDirectHttpRequest(method, path2, params) {
18909
19292
  const authHeaders = await this.authProvider.getAuthHeaders();
18910
19293
  const config = {
18911
19294
  method: method.toLowerCase(),
18912
- url: path,
19295
+ url: path2,
18913
19296
  headers: authHeaders
18914
19297
  };
18915
19298
  if (isGetLikeMethod(method)) {
@@ -18924,7 +19307,10 @@ var ApiClient = class {
18924
19307
  if (axios_default.isAxiosError(error)) {
18925
19308
  const axiosError = error;
18926
19309
  throw new Error(
18927
- `API request failed: ${axiosError.message}${axiosError.response ? ` (${axiosError.response.status}: ${typeof axiosError.response.data === "object" ? JSON.stringify(axiosError.response.data) : axiosError.response.data})` : ""}`
19310
+ `API request failed: ${axiosError.message}${axiosError.response ? ` (${axiosError.response.status}: ${this.sanitizeErrorData(
19311
+ axiosError.response.data,
19312
+ axiosError.response.status
19313
+ )})` : ""}`
18928
19314
  );
18929
19315
  }
18930
19316
  throw error;
@@ -18932,22 +19318,265 @@ var ApiClient = class {
18932
19318
  }
18933
19319
  };
18934
19320
 
19321
+ // src/prompts-manager.ts
19322
+ var PromptsManager = class {
19323
+ prompts = /* @__PURE__ */ new Map();
19324
+ constructor(config) {
19325
+ if (config.prompts) {
19326
+ for (const prompt of config.prompts) {
19327
+ this.addPrompt(prompt);
19328
+ }
19329
+ }
19330
+ }
19331
+ /**
19332
+ * Add a prompt definition
19333
+ */
19334
+ addPrompt(prompt) {
19335
+ if (!prompt.name) {
19336
+ throw new Error("Prompt name is required");
19337
+ }
19338
+ if (!prompt.template) {
19339
+ throw new Error(`Prompt "${prompt.name}" requires a template`);
19340
+ }
19341
+ this.prompts.set(prompt.name, prompt);
19342
+ }
19343
+ /**
19344
+ * Remove a prompt by name
19345
+ */
19346
+ removePrompt(name) {
19347
+ return this.prompts.delete(name);
19348
+ }
19349
+ /**
19350
+ * Get all prompts in MCP format for listing
19351
+ */
19352
+ getAllPrompts() {
19353
+ return Array.from(this.prompts.values()).map((def) => this.toMCPPrompt(def));
19354
+ }
19355
+ /**
19356
+ * Get a specific prompt with arguments applied
19357
+ */
19358
+ getPrompt(name, args) {
19359
+ const def = this.prompts.get(name);
19360
+ if (!def) {
19361
+ throw new Error(`Prompt not found: ${name}`);
19362
+ }
19363
+ if (def.arguments) {
19364
+ for (const arg of def.arguments) {
19365
+ if (arg.required && (!args || args[arg.name] === void 0)) {
19366
+ throw new Error(`Missing required argument: ${arg.name}`);
19367
+ }
19368
+ }
19369
+ }
19370
+ const renderedText = this.renderTemplate(def.template, args || {});
19371
+ const messages = [
19372
+ {
19373
+ role: "user",
19374
+ content: {
19375
+ type: "text",
19376
+ text: renderedText
19377
+ }
19378
+ }
19379
+ ];
19380
+ return {
19381
+ description: def.description,
19382
+ messages
19383
+ };
19384
+ }
19385
+ /**
19386
+ * Check if a prompt exists
19387
+ */
19388
+ hasPrompt(name) {
19389
+ return this.prompts.has(name);
19390
+ }
19391
+ /**
19392
+ * Get the count of prompts
19393
+ */
19394
+ get count() {
19395
+ return this.prompts.size;
19396
+ }
19397
+ /**
19398
+ * Convert internal prompt definition to MCP Prompt format
19399
+ */
19400
+ toMCPPrompt(def) {
19401
+ const prompt = {
19402
+ name: def.name,
19403
+ description: def.description
19404
+ };
19405
+ if (def.arguments && def.arguments.length > 0) {
19406
+ prompt.arguments = def.arguments.map(
19407
+ (arg) => ({
19408
+ name: arg.name,
19409
+ description: arg.description,
19410
+ required: arg.required
19411
+ })
19412
+ );
19413
+ }
19414
+ return prompt;
19415
+ }
19416
+ /**
19417
+ * Render a template string by replacing {{argName}} placeholders
19418
+ */
19419
+ renderTemplate(template, args) {
19420
+ return template.replace(/\{\{(\w+)\}\}/g, (match, argName) => {
19421
+ if (args[argName] !== void 0) {
19422
+ return args[argName];
19423
+ }
19424
+ return "";
19425
+ });
19426
+ }
19427
+ };
19428
+
19429
+ // src/resources-manager.ts
19430
+ var ResourcesManager = class {
19431
+ resources = /* @__PURE__ */ new Map();
19432
+ constructor(config) {
19433
+ if (config.resources) {
19434
+ for (const resource of config.resources) {
19435
+ this.addResource(resource);
19436
+ }
19437
+ }
19438
+ }
19439
+ /**
19440
+ * Add a resource definition
19441
+ */
19442
+ addResource(resource) {
19443
+ if (!resource.uri) {
19444
+ throw new Error("Resource URI is required");
19445
+ }
19446
+ if (!resource.name) {
19447
+ throw new Error(`Resource "${resource.uri}" requires a name`);
19448
+ }
19449
+ if (!resource.text && !resource.blob && !resource.contentProvider) {
19450
+ throw new Error(
19451
+ `Resource "${resource.uri}" requires content (text, blob, or contentProvider)`
19452
+ );
19453
+ }
19454
+ this.resources.set(resource.uri, resource);
19455
+ }
19456
+ /**
19457
+ * Remove a resource by URI
19458
+ */
19459
+ removeResource(uri) {
19460
+ return this.resources.delete(uri);
19461
+ }
19462
+ /**
19463
+ * Get all resources in MCP format for listing
19464
+ */
19465
+ getAllResources() {
19466
+ return Array.from(this.resources.values()).map((def) => this.toMCPResource(def));
19467
+ }
19468
+ /**
19469
+ * Read a specific resource by URI
19470
+ */
19471
+ async readResource(uri) {
19472
+ const def = this.resources.get(uri);
19473
+ if (!def) {
19474
+ throw new Error(`Resource not found: ${uri}`);
19475
+ }
19476
+ let contents;
19477
+ if (def.contentProvider) {
19478
+ let content;
19479
+ try {
19480
+ content = await def.contentProvider();
19481
+ } catch (error) {
19482
+ throw new Error(
19483
+ `Failed to load content for resource "${uri}": ${error instanceof Error ? error.message : String(error)}`
19484
+ );
19485
+ }
19486
+ if (typeof content === "string") {
19487
+ contents = [
19488
+ {
19489
+ uri: def.uri,
19490
+ mimeType: def.mimeType,
19491
+ text: content
19492
+ }
19493
+ ];
19494
+ } else {
19495
+ contents = [
19496
+ {
19497
+ uri: def.uri,
19498
+ mimeType: def.mimeType,
19499
+ blob: content.blob
19500
+ }
19501
+ ];
19502
+ }
19503
+ } else if (def.text !== void 0) {
19504
+ contents = [
19505
+ {
19506
+ uri: def.uri,
19507
+ mimeType: def.mimeType,
19508
+ text: def.text
19509
+ }
19510
+ ];
19511
+ } else if (def.blob !== void 0) {
19512
+ contents = [
19513
+ {
19514
+ uri: def.uri,
19515
+ mimeType: def.mimeType,
19516
+ blob: def.blob
19517
+ }
19518
+ ];
19519
+ } else {
19520
+ throw new Error(`Resource "${uri}" has no content`);
19521
+ }
19522
+ return { contents };
19523
+ }
19524
+ /**
19525
+ * Check if a resource exists
19526
+ */
19527
+ hasResource(uri) {
19528
+ return this.resources.has(uri);
19529
+ }
19530
+ /**
19531
+ * Get the count of resources
19532
+ */
19533
+ get count() {
19534
+ return this.resources.size;
19535
+ }
19536
+ /**
19537
+ * Convert internal resource definition to MCP Resource format
19538
+ */
19539
+ toMCPResource(def) {
19540
+ return {
19541
+ uri: def.uri,
19542
+ name: def.name,
19543
+ description: def.description,
19544
+ mimeType: def.mimeType
19545
+ };
19546
+ }
19547
+ };
19548
+
18935
19549
  // src/server.ts
18936
19550
  var OpenAPIServer = class {
18937
19551
  server;
18938
19552
  toolsManager;
18939
19553
  apiClient;
19554
+ promptsManager;
19555
+ resourcesManager;
19556
+ config;
18940
19557
  constructor(config) {
19558
+ this.config = config;
19559
+ if (config.prompts?.length) {
19560
+ this.promptsManager = new PromptsManager({ prompts: config.prompts });
19561
+ }
19562
+ if (config.resources?.length) {
19563
+ this.resourcesManager = new ResourcesManager({ resources: config.resources });
19564
+ }
19565
+ const capabilities = {
19566
+ tools: {
19567
+ list: true,
19568
+ execute: true
19569
+ }
19570
+ };
19571
+ if (this.promptsManager) {
19572
+ capabilities.prompts = {};
19573
+ }
19574
+ if (this.resourcesManager) {
19575
+ capabilities.resources = {};
19576
+ }
18941
19577
  this.server = new Server(
18942
19578
  { name: config.name, version: config.version },
18943
- {
18944
- capabilities: {
18945
- tools: {
18946
- list: true,
18947
- execute: true
18948
- }
18949
- }
18950
- }
19579
+ { capabilities }
18951
19580
  );
18952
19581
  this.toolsManager = new ToolsManager(config);
18953
19582
  const authProviderOrHeaders = config.authProvider || new StaticAuthProvider(config.headers);
@@ -19009,6 +19638,25 @@ var OpenAPIServer = class {
19009
19638
  throw error;
19010
19639
  }
19011
19640
  });
19641
+ if (this.promptsManager) {
19642
+ this.server.setRequestHandler(ListPromptsRequestSchema, async () => ({
19643
+ prompts: this.promptsManager.getAllPrompts()
19644
+ }));
19645
+ this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {
19646
+ return this.promptsManager.getPrompt(
19647
+ request.params.name,
19648
+ request.params.arguments
19649
+ );
19650
+ });
19651
+ }
19652
+ if (this.resourcesManager) {
19653
+ this.server.setRequestHandler(ListResourcesRequestSchema, async () => ({
19654
+ resources: this.resourcesManager.getAllResources()
19655
+ }));
19656
+ this.server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
19657
+ return this.resourcesManager.readResource(request.params.uri);
19658
+ });
19659
+ }
19012
19660
  }
19013
19661
  /**
19014
19662
  * Start the server with the given transport
@@ -19026,6 +19674,18 @@ var OpenAPIServer = class {
19026
19674
  }
19027
19675
  await this.server.connect(transport);
19028
19676
  }
19677
+ /**
19678
+ * Get the prompts manager (for library users to add prompts dynamically)
19679
+ */
19680
+ getPromptsManager() {
19681
+ return this.promptsManager;
19682
+ }
19683
+ /**
19684
+ * Get the resources manager (for library users to add resources dynamically)
19685
+ */
19686
+ getResourcesManager() {
19687
+ return this.resourcesManager;
19688
+ }
19029
19689
  };
19030
19690
 
19031
19691
  // node_modules/yargs/lib/platform-shims/esm.mjs
@@ -20304,11 +20964,11 @@ var parser = new YargsParser({
20304
20964
  resolve: resolve2,
20305
20965
  // TODO: figure out a way to combine ESM and CJS coverage, such that
20306
20966
  // we can exercise all the lines below:
20307
- require: (path) => {
20967
+ require: (path2) => {
20308
20968
  if (typeof __require !== "undefined") {
20309
- return __require(path);
20310
- } else if (path.match(/\.json$/)) {
20311
- return JSON.parse(readFileSync(path, "utf8"));
20969
+ return __require(path2);
20970
+ } else if (path2.match(/\.json$/)) {
20971
+ return JSON.parse(readFileSync(path2, "utf8"));
20312
20972
  } else {
20313
20973
  throw Error("only .json config files are supported in ESM");
20314
20974
  }
@@ -20799,13 +21459,13 @@ function maybeAsyncResult(getResult, resultHandler, errorHandler = (err) => {
20799
21459
  throw err;
20800
21460
  }) {
20801
21461
  try {
20802
- const result = isFunction2(getResult) ? getResult() : getResult;
21462
+ const result = isFunction3(getResult) ? getResult() : getResult;
20803
21463
  return isPromise(result) ? result.then((result2) => resultHandler(result2)) : resultHandler(result);
20804
21464
  } catch (err) {
20805
21465
  return errorHandler(err);
20806
21466
  }
20807
21467
  }
20808
- function isFunction2(arg) {
21468
+ function isFunction3(arg) {
20809
21469
  return typeof arg === "function";
20810
21470
  }
20811
21471
 
@@ -22833,12 +23493,12 @@ var YargsInstance = class {
22833
23493
  async getCompletion(args, done) {
22834
23494
  argsert("<array> [function]", [args, done], arguments.length);
22835
23495
  if (!done) {
22836
- return new Promise((resolve5, reject) => {
23496
+ return new Promise((resolve6, reject) => {
22837
23497
  __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
22838
23498
  if (err)
22839
23499
  reject(err);
22840
23500
  else
22841
- resolve5(completions);
23501
+ resolve6(completions);
22842
23502
  });
22843
23503
  });
22844
23504
  } else {
@@ -23957,6 +24617,18 @@ function loadConfig() {
23957
24617
  }).option("disable-abbreviation", {
23958
24618
  type: "boolean",
23959
24619
  description: "Disable name optimization"
24620
+ }).option("prompts", {
24621
+ type: "string",
24622
+ description: "Path or URL to prompts JSON/YAML file"
24623
+ }).option("prompts-inline", {
24624
+ type: "string",
24625
+ description: "Provide prompts directly as JSON string"
24626
+ }).option("resources", {
24627
+ type: "string",
24628
+ description: "Path or URL to resources JSON/YAML file"
24629
+ }).option("resources-inline", {
24630
+ type: "string",
24631
+ description: "Provide resources directly as JSON string"
23960
24632
  }).help().parseSync();
23961
24633
  let transportType;
23962
24634
  if (argv.transport === "http" || process.env.TRANSPORT_TYPE === "http") {
@@ -24034,7 +24706,11 @@ function loadConfig() {
24034
24706
  includeResources: argv.resource,
24035
24707
  includeOperations: argv.operation,
24036
24708
  toolsMode,
24037
- disableAbbreviation: disableAbbreviation ? true : void 0
24709
+ disableAbbreviation: disableAbbreviation ? true : void 0,
24710
+ promptsPath: argv.prompts || process.env.PROMPTS_PATH,
24711
+ promptsInline: argv["prompts-inline"] || process.env.PROMPTS_INLINE,
24712
+ resourcesPath: argv.resources || process.env.RESOURCES_PATH,
24713
+ resourcesInline: argv["resources-inline"] || process.env.RESOURCES_INLINE
24038
24714
  };
24039
24715
  }
24040
24716
 
@@ -24044,7 +24720,7 @@ import {
24044
24720
  isJSONRPCRequest,
24045
24721
  isJSONRPCResponse
24046
24722
  } from "@modelcontextprotocol/sdk/types.js";
24047
- import * as http2 from "http";
24723
+ import * as http3 from "http";
24048
24724
  import { randomUUID } from "crypto";
24049
24725
  var StreamableHttpServerTransport = class {
24050
24726
  // Track if using an external server
@@ -24071,7 +24747,7 @@ var StreamableHttpServerTransport = class {
24071
24747
  this.server = server;
24072
24748
  this.server.on("request", this.handleRequest.bind(this));
24073
24749
  } else {
24074
- this.server = http2.createServer(this.handleRequest.bind(this));
24750
+ this.server = http3.createServer(this.handleRequest.bind(this));
24075
24751
  }
24076
24752
  }
24077
24753
  server;
@@ -24103,13 +24779,13 @@ var StreamableHttpServerTransport = class {
24103
24779
  if (this.started) {
24104
24780
  throw new Error("Transport already started");
24105
24781
  }
24106
- return new Promise((resolve5, reject) => {
24782
+ return new Promise((resolve6, reject) => {
24107
24783
  this.server.listen(this.port, this.host, () => {
24108
24784
  this.started = true;
24109
24785
  console.error(
24110
24786
  `Streamable HTTP transport listening on http://${this.host}:${this.port}${this.endpointPath}`
24111
24787
  );
24112
- resolve5();
24788
+ resolve6();
24113
24789
  });
24114
24790
  this.server.on("error", (err) => {
24115
24791
  reject(err);
@@ -24139,7 +24815,7 @@ var StreamableHttpServerTransport = class {
24139
24815
  }
24140
24816
  return;
24141
24817
  }
24142
- return new Promise((resolve5, reject) => {
24818
+ return new Promise((resolve6, reject) => {
24143
24819
  this.server.close((err) => {
24144
24820
  if (err) {
24145
24821
  reject(err instanceof Error ? err : new Error(String(err)));
@@ -24148,7 +24824,7 @@ var StreamableHttpServerTransport = class {
24148
24824
  if (this.onclose) {
24149
24825
  this.onclose();
24150
24826
  }
24151
- resolve5();
24827
+ resolve6();
24152
24828
  }
24153
24829
  });
24154
24830
  });
@@ -24630,10 +25306,82 @@ var StreamableHttpServerTransport = class {
24630
25306
  }
24631
25307
  };
24632
25308
 
25309
+ // src/content-loader.ts
25310
+ import * as fs from "fs";
25311
+ import * as path from "path";
25312
+ async function loadContent(pathOrUrl, inline) {
25313
+ if (inline) {
25314
+ return inline;
25315
+ }
25316
+ if (!pathOrUrl) {
25317
+ return void 0;
25318
+ }
25319
+ if (pathOrUrl.startsWith("http://") || pathOrUrl.startsWith("https://")) {
25320
+ const response = await axios_default.get(pathOrUrl, {
25321
+ responseType: "text",
25322
+ headers: { Accept: "application/json, application/yaml, text/yaml" }
25323
+ });
25324
+ return response.data;
25325
+ }
25326
+ const absolutePath = path.isAbsolute(pathOrUrl) ? pathOrUrl : path.resolve(process.cwd(), pathOrUrl);
25327
+ return fs.readFileSync(absolutePath, "utf-8");
25328
+ }
25329
+ function parseContent(content, source) {
25330
+ try {
25331
+ return JSON.parse(content);
25332
+ } catch {
25333
+ try {
25334
+ return jsYaml.load(content);
25335
+ } catch (yamlError) {
25336
+ throw new Error(
25337
+ `Failed to parse ${source} as JSON or YAML: ${yamlError}`
25338
+ );
25339
+ }
25340
+ }
25341
+ }
25342
+ async function loadPrompts(pathOrUrl, inline) {
25343
+ const content = await loadContent(pathOrUrl, inline);
25344
+ if (!content) {
25345
+ return void 0;
25346
+ }
25347
+ const source = inline ? "inline prompts" : pathOrUrl;
25348
+ const prompts = parseContent(content, source);
25349
+ if (!Array.isArray(prompts)) {
25350
+ throw new Error(`Prompts must be an array, got: ${typeof prompts}`);
25351
+ }
25352
+ return prompts;
25353
+ }
25354
+ async function loadResources(pathOrUrl, inline) {
25355
+ const content = await loadContent(pathOrUrl, inline);
25356
+ if (!content) {
25357
+ return void 0;
25358
+ }
25359
+ const source = inline ? "inline resources" : pathOrUrl;
25360
+ const resources = parseContent(content, source);
25361
+ if (!Array.isArray(resources)) {
25362
+ throw new Error(`Resources must be an array, got: ${typeof resources}`);
25363
+ }
25364
+ return resources;
25365
+ }
25366
+
24633
25367
  // src/index.ts
24634
25368
  async function main() {
24635
25369
  try {
24636
25370
  const config = loadConfig();
25371
+ if (config.promptsPath || config.promptsInline) {
25372
+ const prompts = await loadPrompts(config.promptsPath, config.promptsInline);
25373
+ if (prompts) {
25374
+ config.prompts = prompts;
25375
+ console.error(`Loaded ${prompts.length} prompt(s)`);
25376
+ }
25377
+ }
25378
+ if (config.resourcesPath || config.resourcesInline) {
25379
+ const resources = await loadResources(config.resourcesPath, config.resourcesInline);
25380
+ if (resources) {
25381
+ config.resources = resources;
25382
+ console.error(`Loaded ${resources.length} resource(s)`);
25383
+ }
25384
+ }
24637
25385
  const server = new OpenAPIServer(config);
24638
25386
  let transport;
24639
25387
  if (config.transportType === "http") {
@@ -24678,7 +25426,7 @@ mime-types/index.js:
24678
25426
  *)
24679
25427
 
24680
25428
  js-yaml/dist/js-yaml.mjs:
24681
- (*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT *)
25429
+ (*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT *)
24682
25430
 
24683
25431
  yargs-parser/build/lib/string-utils.js:
24684
25432
  yargs-parser/build/lib/tokenize-arg-string.js: