@ivotoby/openapi-mcp-server 1.12.1 → 1.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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
  }
@@ -9990,11 +9990,11 @@ var require_form_data = __commonJS({
9990
9990
  "node_modules/form-data/lib/form_data.js"(exports, module) {
9991
9991
  var CombinedStream = require_combined_stream();
9992
9992
  var util3 = __require("util");
9993
- var path = __require("path");
9993
+ var path2 = __require("path");
9994
9994
  var http3 = __require("http");
9995
9995
  var https2 = __require("https");
9996
9996
  var parseUrl = __require("url").parse;
9997
- var fs = __require("fs");
9997
+ var fs2 = __require("fs");
9998
9998
  var Stream = __require("stream").Stream;
9999
9999
  var mime = require_mime_types();
10000
10000
  var asynckit = require_asynckit();
@@ -10060,7 +10060,7 @@ var require_form_data = __commonJS({
10060
10060
  if (value.end != void 0 && value.end != Infinity && value.start != void 0) {
10061
10061
  callback(null, value.end + 1 - (value.start ? value.start : 0));
10062
10062
  } else {
10063
- fs.stat(value.path, function(err, stat) {
10063
+ fs2.stat(value.path, function(err, stat) {
10064
10064
  var fileSize;
10065
10065
  if (err) {
10066
10066
  callback(err);
@@ -10118,11 +10118,11 @@ var require_form_data = __commonJS({
10118
10118
  FormData3.prototype._getContentDisposition = function(value, options) {
10119
10119
  var filename, contentDisposition;
10120
10120
  if (typeof options.filepath === "string") {
10121
- filename = path.normalize(options.filepath).replace(/\\/g, "/");
10121
+ filename = path2.normalize(options.filepath).replace(/\\/g, "/");
10122
10122
  } else if (options.filename || value.name || value.path) {
10123
- filename = path.basename(options.filename || value.name || value.path);
10123
+ filename = path2.basename(options.filename || value.name || value.path);
10124
10124
  } else if (value.readable && Object.prototype.hasOwnProperty.call(value, "httpVersion")) {
10125
- filename = path.basename(value.client._httpMessage.path || "");
10125
+ filename = path2.basename(value.client._httpMessage.path || "");
10126
10126
  }
10127
10127
  if (filename) {
10128
10128
  contentDisposition = 'filename="' + filename + '"';
@@ -11656,7 +11656,14 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
11656
11656
 
11657
11657
  // src/server.ts
11658
11658
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
11659
- import { ListToolsRequestSchema, CallToolRequestSchema } from "@modelcontextprotocol/sdk/types.js";
11659
+ import {
11660
+ ListToolsRequestSchema,
11661
+ CallToolRequestSchema,
11662
+ ListPromptsRequestSchema,
11663
+ GetPromptRequestSchema,
11664
+ ListResourcesRequestSchema,
11665
+ ReadResourceRequestSchema
11666
+ } from "@modelcontextprotocol/sdk/types.js";
11660
11667
 
11661
11668
  // src/openapi-loader.ts
11662
11669
  import { readFile } from "fs/promises";
@@ -14377,8 +14384,8 @@ function parseToolId(toolId) {
14377
14384
  if (!pathPart) {
14378
14385
  return { method, path: "" };
14379
14386
  }
14380
- const path = pathPart.replace(/__/g, "/");
14381
- return { method, path: "/" + path };
14387
+ const path2 = pathPart.replace(/__/g, "/");
14388
+ return { method, path: "/" + path2 };
14382
14389
  }
14383
14390
  function sanitizeForToolId(input) {
14384
14391
  let result = input.replace(/[^A-Za-z0-9_.-]/g, "").replace(/_{3,}/g, "__");
@@ -14388,8 +14395,8 @@ function sanitizeForToolId(input) {
14388
14395
  function collapseExcessiveHyphens(input) {
14389
14396
  return input.replace(/-{4,}/g, "---");
14390
14397
  }
14391
- function generateToolId(method, path) {
14392
- const cleanPath = path.replace(/^\//, "").replace(/\/+/g, "/").replace(/\{([^}]+)\}/g, "---$1").replace(/\//g, "__");
14398
+ function generateToolId(method, path2) {
14399
+ const cleanPath = path2.replace(/^\//, "").replace(/\/+/g, "/").replace(/\{([^}]+)\}/g, "---$1").replace(/\//g, "__");
14393
14400
  const sanitizedPath = sanitizeForToolId(cleanPath);
14394
14401
  return `${method.toUpperCase()}::${sanitizedPath}`;
14395
14402
  }
@@ -14456,7 +14463,7 @@ var OpenAPISpecLoader = class {
14456
14463
  * Load spec content from standard input
14457
14464
  */
14458
14465
  async loadFromStdin() {
14459
- return new Promise((resolve5, reject) => {
14466
+ return new Promise((resolve6, reject) => {
14460
14467
  let data = "";
14461
14468
  process.stdin.setEncoding("utf8");
14462
14469
  process.stdin.on("data", (chunk) => {
@@ -14466,7 +14473,7 @@ var OpenAPISpecLoader = class {
14466
14473
  if (data.trim().length === 0) {
14467
14474
  reject(new Error("No data received from stdin"));
14468
14475
  } else {
14469
- resolve5(data);
14476
+ resolve6(data);
14470
14477
  }
14471
14478
  });
14472
14479
  process.stdin.on("error", (error) => {
@@ -14646,8 +14653,8 @@ var OpenAPISpecLoader = class {
14646
14653
  * - "/api/v1/users/{id}/posts" -> "posts"
14647
14654
  * - "/health" -> "health"
14648
14655
  */
14649
- extractResourceName(path) {
14650
- const segments = path.replace(/^\//, "").split("/");
14656
+ extractResourceName(path2) {
14657
+ const segments = path2.replace(/^\//, "").split("/");
14651
14658
  for (let i = segments.length - 1; i >= 0; i--) {
14652
14659
  const segment = segments[i];
14653
14660
  if (!segment.includes("{") && !segment.includes("}") && segment.length > 0) {
@@ -14661,7 +14668,7 @@ var OpenAPISpecLoader = class {
14661
14668
  */
14662
14669
  parseOpenAPISpec(spec) {
14663
14670
  const tools = /* @__PURE__ */ new Map();
14664
- for (const [path, pathItem] of Object.entries(spec.paths)) {
14671
+ for (const [path2, pathItem] of Object.entries(spec.paths)) {
14665
14672
  if (!pathItem) continue;
14666
14673
  const pathLevelParameters = [];
14667
14674
  if (pathItem.parameters) {
@@ -14703,16 +14710,16 @@ var OpenAPISpecLoader = class {
14703
14710
  if (!["get", "post", "put", "patch", "delete", "options", "head"].includes(
14704
14711
  method.toLowerCase()
14705
14712
  )) {
14706
- console.warn(`Skipping non-HTTP method "${method}" for path ${path}`);
14713
+ console.warn(`Skipping non-HTTP method "${method}" for path ${path2}`);
14707
14714
  continue;
14708
14715
  }
14709
14716
  const op = operation;
14710
- const toolId = generateToolId(method, path);
14711
- const nameSource = op.operationId || op.summary || `${method.toUpperCase()} ${path}`;
14717
+ const toolId = generateToolId(method, path2);
14718
+ const nameSource = op.operationId || op.summary || `${method.toUpperCase()} ${path2}`;
14712
14719
  const name = this.abbreviateOperationId(nameSource);
14713
14720
  const tool = {
14714
14721
  name,
14715
- description: op.description || `Make a ${method.toUpperCase()} request to ${path}`,
14722
+ description: op.description || `Make a ${method.toUpperCase()} request to ${path2}`,
14716
14723
  inputSchema: {
14717
14724
  type: "object",
14718
14725
  properties: {}
@@ -14720,10 +14727,10 @@ var OpenAPISpecLoader = class {
14720
14727
  // Add metadata for filtering
14721
14728
  tags: op.tags || [],
14722
14729
  httpMethod: method.toUpperCase(),
14723
- resourceName: this.extractResourceName(path),
14724
- originalPath: path
14730
+ resourceName: this.extractResourceName(path2),
14731
+ originalPath: path2
14725
14732
  };
14726
- tool["x-original-path"] = path;
14733
+ tool["x-original-path"] = path2;
14727
14734
  const requiredParams = [];
14728
14735
  const parameterMap = /* @__PURE__ */ new Map();
14729
14736
  for (const pathParam of pathLevelParameters) {
@@ -15651,9 +15658,9 @@ function isVisitable(thing) {
15651
15658
  function removeBrackets(key) {
15652
15659
  return utils_default.endsWith(key, "[]") ? key.slice(0, -2) : key;
15653
15660
  }
15654
- function renderKey(path, key, dots) {
15655
- if (!path) return key;
15656
- return path.concat(key).map(function each(token, i) {
15661
+ function renderKey(path2, key, dots) {
15662
+ if (!path2) return key;
15663
+ return path2.concat(key).map(function each(token, i) {
15657
15664
  token = removeBrackets(token);
15658
15665
  return !dots && i ? "[" + token + "]" : token;
15659
15666
  }).join(dots ? "." : "");
@@ -15701,9 +15708,9 @@ function toFormData(obj, formData, options) {
15701
15708
  }
15702
15709
  return value;
15703
15710
  }
15704
- function defaultVisitor(value, key, path) {
15711
+ function defaultVisitor(value, key, path2) {
15705
15712
  let arr = value;
15706
- if (value && !path && typeof value === "object") {
15713
+ if (value && !path2 && typeof value === "object") {
15707
15714
  if (utils_default.endsWith(key, "{}")) {
15708
15715
  key = metaTokens ? key : key.slice(0, -2);
15709
15716
  value = JSON.stringify(value);
@@ -15722,7 +15729,7 @@ function toFormData(obj, formData, options) {
15722
15729
  if (isVisitable(value)) {
15723
15730
  return true;
15724
15731
  }
15725
- formData.append(renderKey(path, key, dots), convertValue(value));
15732
+ formData.append(renderKey(path2, key, dots), convertValue(value));
15726
15733
  return false;
15727
15734
  }
15728
15735
  const stack = [];
@@ -15731,10 +15738,10 @@ function toFormData(obj, formData, options) {
15731
15738
  convertValue,
15732
15739
  isVisitable
15733
15740
  });
15734
- function build(value, path) {
15741
+ function build(value, path2) {
15735
15742
  if (utils_default.isUndefined(value)) return;
15736
15743
  if (stack.indexOf(value) !== -1) {
15737
- throw Error("Circular reference detected in " + path.join("."));
15744
+ throw Error("Circular reference detected in " + path2.join("."));
15738
15745
  }
15739
15746
  stack.push(value);
15740
15747
  utils_default.forEach(value, function each(el, key) {
@@ -15742,11 +15749,11 @@ function toFormData(obj, formData, options) {
15742
15749
  formData,
15743
15750
  el,
15744
15751
  utils_default.isString(key) ? key.trim() : key,
15745
- path,
15752
+ path2,
15746
15753
  exposedHelpers
15747
15754
  );
15748
15755
  if (result === true) {
15749
- build(el, path ? path.concat(key) : [key]);
15756
+ build(el, path2 ? path2.concat(key) : [key]);
15750
15757
  }
15751
15758
  });
15752
15759
  stack.pop();
@@ -15958,7 +15965,7 @@ var platform_default = {
15958
15965
  // node_modules/axios/lib/helpers/toURLEncodedForm.js
15959
15966
  function toURLEncodedForm(data, options) {
15960
15967
  return toFormData_default(data, new platform_default.classes.URLSearchParams(), Object.assign({
15961
- visitor: function(value, key, path, helpers) {
15968
+ visitor: function(value, key, path2, helpers) {
15962
15969
  if (platform_default.isNode && utils_default.isBuffer(value)) {
15963
15970
  this.append(key, value.toString("base64"));
15964
15971
  return false;
@@ -15987,11 +15994,11 @@ function arrayToObject(arr) {
15987
15994
  return obj;
15988
15995
  }
15989
15996
  function formDataToJSON(formData) {
15990
- function buildPath(path, value, target, index) {
15991
- let name = path[index++];
15997
+ function buildPath(path2, value, target, index) {
15998
+ let name = path2[index++];
15992
15999
  if (name === "__proto__") return true;
15993
16000
  const isNumericKey = Number.isFinite(+name);
15994
- const isLast = index >= path.length;
16001
+ const isLast = index >= path2.length;
15995
16002
  name = !name && utils_default.isArray(target) ? target.length : name;
15996
16003
  if (isLast) {
15997
16004
  if (utils_default.hasOwnProp(target, name)) {
@@ -16004,7 +16011,7 @@ function formDataToJSON(formData) {
16004
16011
  if (!target[name] || !utils_default.isObject(target[name])) {
16005
16012
  target[name] = [];
16006
16013
  }
16007
- const result = buildPath(path, value, target[name], index);
16014
+ const result = buildPath(path2, value, target[name], index);
16008
16015
  if (result && utils_default.isArray(target[name])) {
16009
16016
  target[name] = arrayToObject(target[name]);
16010
16017
  }
@@ -16433,10 +16440,10 @@ utils_default.inherits(CanceledError, AxiosError_default, {
16433
16440
  var CanceledError_default = CanceledError;
16434
16441
 
16435
16442
  // node_modules/axios/lib/core/settle.js
16436
- function settle(resolve5, reject, response) {
16443
+ function settle(resolve6, reject, response) {
16437
16444
  const validateStatus2 = response.config.validateStatus;
16438
16445
  if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
16439
- resolve5(response);
16446
+ resolve6(response);
16440
16447
  } else {
16441
16448
  reject(new AxiosError_default(
16442
16449
  "Request failed with status code " + response.status,
@@ -16937,7 +16944,7 @@ function setProxy(options, configProxy, location) {
16937
16944
  }
16938
16945
  var isHttpAdapterSupported = typeof process !== "undefined" && utils_default.kindOf(process) === "process";
16939
16946
  var wrapAsync = (asyncExecutor) => {
16940
- return new Promise((resolve5, reject) => {
16947
+ return new Promise((resolve6, reject) => {
16941
16948
  let onDone;
16942
16949
  let isDone;
16943
16950
  const done = (value, isRejected) => {
@@ -16947,7 +16954,7 @@ var wrapAsync = (asyncExecutor) => {
16947
16954
  };
16948
16955
  const _resolve = (value) => {
16949
16956
  done(value);
16950
- resolve5(value);
16957
+ resolve6(value);
16951
16958
  };
16952
16959
  const _reject = (reason) => {
16953
16960
  done(reason, true);
@@ -16967,7 +16974,7 @@ var resolveFamily = ({ address, family }) => {
16967
16974
  };
16968
16975
  var buildAddressEntry = (address, family) => resolveFamily(utils_default.isObject(address) ? address : { address, family });
16969
16976
  var http_default = isHttpAdapterSupported && function httpAdapter(config) {
16970
- return wrapAsync(async function dispatchHttpRequest(resolve5, reject, onDone) {
16977
+ return wrapAsync(async function dispatchHttpRequest(resolve6, reject, onDone) {
16971
16978
  let { data, lookup, family } = config;
16972
16979
  const { responseType, responseEncoding } = config;
16973
16980
  const method = config.method.toUpperCase();
@@ -17019,7 +17026,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
17019
17026
  if (protocol === "data:") {
17020
17027
  let convertedData;
17021
17028
  if (method !== "GET") {
17022
- return settle(resolve5, reject, {
17029
+ return settle(resolve6, reject, {
17023
17030
  status: 405,
17024
17031
  statusText: "method not allowed",
17025
17032
  headers: {},
@@ -17041,7 +17048,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
17041
17048
  } else if (responseType === "stream") {
17042
17049
  convertedData = stream3.Readable.from(convertedData);
17043
17050
  }
17044
- return settle(resolve5, reject, {
17051
+ return settle(resolve6, reject, {
17045
17052
  data: convertedData,
17046
17053
  status: 200,
17047
17054
  statusText: "OK",
@@ -17139,9 +17146,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
17139
17146
  auth = urlUsername + ":" + urlPassword;
17140
17147
  }
17141
17148
  auth && headers.delete("authorization");
17142
- let path;
17149
+ let path2;
17143
17150
  try {
17144
- path = buildURL(
17151
+ path2 = buildURL(
17145
17152
  parsed.pathname + parsed.search,
17146
17153
  config.params,
17147
17154
  config.paramsSerializer
@@ -17159,7 +17166,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
17159
17166
  false
17160
17167
  );
17161
17168
  const options = {
17162
- path,
17169
+ path: path2,
17163
17170
  method,
17164
17171
  headers: headers.toJSON(),
17165
17172
  agents: { http: config.httpAgent, https: config.httpsAgent },
@@ -17259,7 +17266,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
17259
17266
  };
17260
17267
  if (responseType === "stream") {
17261
17268
  response.data = responseStream;
17262
- settle(resolve5, reject, response);
17269
+ settle(resolve6, reject, response);
17263
17270
  } else {
17264
17271
  const responseBuffer = [];
17265
17272
  let totalResponseBytes = 0;
@@ -17307,7 +17314,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
17307
17314
  } catch (err) {
17308
17315
  return reject(AxiosError_default.from(err, null, config, response.request, response));
17309
17316
  }
17310
- settle(resolve5, reject, response);
17317
+ settle(resolve6, reject, response);
17311
17318
  });
17312
17319
  }
17313
17320
  emitter.once("abort", (err) => {
@@ -17389,10 +17396,10 @@ var isURLSameOrigin_default = platform_default.hasStandardBrowserEnv ? /* @__PUR
17389
17396
  var cookies_default = platform_default.hasStandardBrowserEnv ? (
17390
17397
  // Standard browser envs support document.cookie
17391
17398
  {
17392
- write(name, value, expires, path, domain, secure) {
17399
+ write(name, value, expires, path2, domain, secure) {
17393
17400
  const cookie = [name + "=" + encodeURIComponent(value)];
17394
17401
  utils_default.isNumber(expires) && cookie.push("expires=" + new Date(expires).toGMTString());
17395
- utils_default.isString(path) && cookie.push("path=" + path);
17402
+ utils_default.isString(path2) && cookie.push("path=" + path2);
17396
17403
  utils_default.isString(domain) && cookie.push("domain=" + domain);
17397
17404
  secure === true && cookie.push("secure");
17398
17405
  document.cookie = cookie.join("; ");
@@ -17534,7 +17541,7 @@ var resolveConfig_default = (config) => {
17534
17541
  // node_modules/axios/lib/adapters/xhr.js
17535
17542
  var isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
17536
17543
  var xhr_default = isXHRAdapterSupported && function(config) {
17537
- return new Promise(function dispatchXhrRequest(resolve5, reject) {
17544
+ return new Promise(function dispatchXhrRequest(resolve6, reject) {
17538
17545
  const _config = resolveConfig_default(config);
17539
17546
  let requestData = _config.data;
17540
17547
  const requestHeaders = AxiosHeaders_default.from(_config.headers).normalize();
@@ -17568,7 +17575,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
17568
17575
  request
17569
17576
  };
17570
17577
  settle(function _resolve(value) {
17571
- resolve5(value);
17578
+ resolve6(value);
17572
17579
  done();
17573
17580
  }, function _reject(err) {
17574
17581
  reject(err);
@@ -17911,8 +17918,8 @@ var fetch_default = isFetchSupported && (async (config) => {
17911
17918
  responseType = responseType || "text";
17912
17919
  let responseData = await resolvers[utils_default.findKey(resolvers, responseType) || "text"](response, config);
17913
17920
  !isStreamResponse && unsubscribe && unsubscribe();
17914
- return await new Promise((resolve5, reject) => {
17915
- settle(resolve5, reject, {
17921
+ return await new Promise((resolve6, reject) => {
17922
+ settle(resolve6, reject, {
17916
17923
  data: responseData,
17917
17924
  headers: AxiosHeaders_default.from(response.headers),
17918
17925
  status: response.status,
@@ -18278,8 +18285,8 @@ var CancelToken = class _CancelToken {
18278
18285
  throw new TypeError("executor must be a function.");
18279
18286
  }
18280
18287
  let resolvePromise;
18281
- this.promise = new Promise(function promiseExecutor(resolve5) {
18282
- resolvePromise = resolve5;
18288
+ this.promise = new Promise(function promiseExecutor(resolve6) {
18289
+ resolvePromise = resolve6;
18283
18290
  });
18284
18291
  const token = this;
18285
18292
  this.promise.then((cancel) => {
@@ -18292,9 +18299,9 @@ var CancelToken = class _CancelToken {
18292
18299
  });
18293
18300
  this.promise.then = (onfulfilled) => {
18294
18301
  let _resolve;
18295
- const promise = new Promise((resolve5) => {
18296
- token.subscribe(resolve5);
18297
- _resolve = resolve5;
18302
+ const promise = new Promise((resolve6) => {
18303
+ token.subscribe(resolve6);
18304
+ _resolve = resolve6;
18298
18305
  }).then(onfulfilled);
18299
18306
  promise.cancel = function reject() {
18300
18307
  token.unsubscribe(_resolve);
@@ -18621,10 +18628,10 @@ var ApiClient = class {
18621
18628
  if (toolId === "INVOKE-API-ENDPOINT") {
18622
18629
  return this.handleInvokeApiEndpoint(toolId, params);
18623
18630
  }
18624
- const { method, path } = this.parseToolId(toolId);
18631
+ const { method, path: path2 } = this.parseToolId(toolId);
18625
18632
  const toolDef = this.getToolDefinition(toolId);
18626
18633
  const paramsCopy = { ...params };
18627
- let resolvedPath = path;
18634
+ let resolvedPath = path2;
18628
18635
  const escapeRegExp = (str2) => {
18629
18636
  return str2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
18630
18637
  };
@@ -18749,7 +18756,7 @@ var ApiClient = class {
18749
18756
  async handleListApiEndpoints() {
18750
18757
  const endpoints = [];
18751
18758
  if (this.openApiSpec) {
18752
- for (const [path, pathItem] of Object.entries(this.openApiSpec.paths)) {
18759
+ for (const [path2, pathItem] of Object.entries(this.openApiSpec.paths)) {
18753
18760
  if (!pathItem) continue;
18754
18761
  for (const [method, operation] of Object.entries(pathItem)) {
18755
18762
  if (method === "parameters" || !operation) continue;
@@ -18759,7 +18766,7 @@ var ApiClient = class {
18759
18766
  const op = operation;
18760
18767
  endpoints.push({
18761
18768
  method: method.toUpperCase(),
18762
- path,
18769
+ path: path2,
18763
18770
  summary: op.summary || "",
18764
18771
  description: op.description || "",
18765
18772
  operationId: op.operationId || "",
@@ -18773,13 +18780,13 @@ var ApiClient = class {
18773
18780
  continue;
18774
18781
  }
18775
18782
  try {
18776
- const { method, path } = this.parseToolId(toolId);
18783
+ const { method, path: path2 } = this.parseToolId(toolId);
18777
18784
  endpoints.push({
18778
18785
  toolId,
18779
18786
  name: tool.name,
18780
18787
  description: tool.description,
18781
18788
  method: method.toUpperCase(),
18782
- path
18789
+ path: path2
18783
18790
  });
18784
18791
  } catch (error) {
18785
18792
  continue;
@@ -18837,8 +18844,8 @@ var ApiClient = class {
18837
18844
  let matchingToolId;
18838
18845
  for (const [toolId2, tool] of this.toolsMap.entries()) {
18839
18846
  try {
18840
- const { path } = this.parseToolId(toolId2);
18841
- if (path === endpoint) {
18847
+ const { path: path2 } = this.parseToolId(toolId2);
18848
+ if (path2 === endpoint) {
18842
18849
  matchingTool = tool;
18843
18850
  matchingToolId = toolId2;
18844
18851
  break;
@@ -18875,8 +18882,8 @@ var ApiClient = class {
18875
18882
  } else if (this.openApiSpec) {
18876
18883
  const pathItem = this.openApiSpec.paths[endpoint];
18877
18884
  if (pathItem && pathItem[method.toLowerCase()]) {
18878
- const { method: httpMethod, path } = { method: method.toUpperCase(), path: endpoint };
18879
- return this.makeDirectHttpRequest(httpMethod, path, endpointParams);
18885
+ const { method: httpMethod, path: path2 } = { method: method.toUpperCase(), path: endpoint };
18886
+ return this.makeDirectHttpRequest(httpMethod, path2, endpointParams);
18880
18887
  } else {
18881
18888
  throw new Error(
18882
18889
  `No endpoint found for path '${endpoint}' with method '${method}' in tool '${toolId2}'`
@@ -18905,11 +18912,11 @@ var ApiClient = class {
18905
18912
  * Make a direct HTTP request without going through the tool system
18906
18913
  * Used by dynamic meta-tools when we have OpenAPI spec but no corresponding tool
18907
18914
  */
18908
- async makeDirectHttpRequest(method, path, params) {
18915
+ async makeDirectHttpRequest(method, path2, params) {
18909
18916
  const authHeaders = await this.authProvider.getAuthHeaders();
18910
18917
  const config = {
18911
18918
  method: method.toLowerCase(),
18912
- url: path,
18919
+ url: path2,
18913
18920
  headers: authHeaders
18914
18921
  };
18915
18922
  if (isGetLikeMethod(method)) {
@@ -18932,22 +18939,265 @@ var ApiClient = class {
18932
18939
  }
18933
18940
  };
18934
18941
 
18942
+ // src/prompts-manager.ts
18943
+ var PromptsManager = class {
18944
+ prompts = /* @__PURE__ */ new Map();
18945
+ constructor(config) {
18946
+ if (config.prompts) {
18947
+ for (const prompt of config.prompts) {
18948
+ this.addPrompt(prompt);
18949
+ }
18950
+ }
18951
+ }
18952
+ /**
18953
+ * Add a prompt definition
18954
+ */
18955
+ addPrompt(prompt) {
18956
+ if (!prompt.name) {
18957
+ throw new Error("Prompt name is required");
18958
+ }
18959
+ if (!prompt.template) {
18960
+ throw new Error(`Prompt "${prompt.name}" requires a template`);
18961
+ }
18962
+ this.prompts.set(prompt.name, prompt);
18963
+ }
18964
+ /**
18965
+ * Remove a prompt by name
18966
+ */
18967
+ removePrompt(name) {
18968
+ return this.prompts.delete(name);
18969
+ }
18970
+ /**
18971
+ * Get all prompts in MCP format for listing
18972
+ */
18973
+ getAllPrompts() {
18974
+ return Array.from(this.prompts.values()).map((def) => this.toMCPPrompt(def));
18975
+ }
18976
+ /**
18977
+ * Get a specific prompt with arguments applied
18978
+ */
18979
+ getPrompt(name, args) {
18980
+ const def = this.prompts.get(name);
18981
+ if (!def) {
18982
+ throw new Error(`Prompt not found: ${name}`);
18983
+ }
18984
+ if (def.arguments) {
18985
+ for (const arg of def.arguments) {
18986
+ if (arg.required && (!args || args[arg.name] === void 0)) {
18987
+ throw new Error(`Missing required argument: ${arg.name}`);
18988
+ }
18989
+ }
18990
+ }
18991
+ const renderedText = this.renderTemplate(def.template, args || {});
18992
+ const messages = [
18993
+ {
18994
+ role: "user",
18995
+ content: {
18996
+ type: "text",
18997
+ text: renderedText
18998
+ }
18999
+ }
19000
+ ];
19001
+ return {
19002
+ description: def.description,
19003
+ messages
19004
+ };
19005
+ }
19006
+ /**
19007
+ * Check if a prompt exists
19008
+ */
19009
+ hasPrompt(name) {
19010
+ return this.prompts.has(name);
19011
+ }
19012
+ /**
19013
+ * Get the count of prompts
19014
+ */
19015
+ get count() {
19016
+ return this.prompts.size;
19017
+ }
19018
+ /**
19019
+ * Convert internal prompt definition to MCP Prompt format
19020
+ */
19021
+ toMCPPrompt(def) {
19022
+ const prompt = {
19023
+ name: def.name,
19024
+ description: def.description
19025
+ };
19026
+ if (def.arguments && def.arguments.length > 0) {
19027
+ prompt.arguments = def.arguments.map(
19028
+ (arg) => ({
19029
+ name: arg.name,
19030
+ description: arg.description,
19031
+ required: arg.required
19032
+ })
19033
+ );
19034
+ }
19035
+ return prompt;
19036
+ }
19037
+ /**
19038
+ * Render a template string by replacing {{argName}} placeholders
19039
+ */
19040
+ renderTemplate(template, args) {
19041
+ return template.replace(/\{\{(\w+)\}\}/g, (match, argName) => {
19042
+ if (args[argName] !== void 0) {
19043
+ return args[argName];
19044
+ }
19045
+ return "";
19046
+ });
19047
+ }
19048
+ };
19049
+
19050
+ // src/resources-manager.ts
19051
+ var ResourcesManager = class {
19052
+ resources = /* @__PURE__ */ new Map();
19053
+ constructor(config) {
19054
+ if (config.resources) {
19055
+ for (const resource of config.resources) {
19056
+ this.addResource(resource);
19057
+ }
19058
+ }
19059
+ }
19060
+ /**
19061
+ * Add a resource definition
19062
+ */
19063
+ addResource(resource) {
19064
+ if (!resource.uri) {
19065
+ throw new Error("Resource URI is required");
19066
+ }
19067
+ if (!resource.name) {
19068
+ throw new Error(`Resource "${resource.uri}" requires a name`);
19069
+ }
19070
+ if (!resource.text && !resource.blob && !resource.contentProvider) {
19071
+ throw new Error(
19072
+ `Resource "${resource.uri}" requires content (text, blob, or contentProvider)`
19073
+ );
19074
+ }
19075
+ this.resources.set(resource.uri, resource);
19076
+ }
19077
+ /**
19078
+ * Remove a resource by URI
19079
+ */
19080
+ removeResource(uri) {
19081
+ return this.resources.delete(uri);
19082
+ }
19083
+ /**
19084
+ * Get all resources in MCP format for listing
19085
+ */
19086
+ getAllResources() {
19087
+ return Array.from(this.resources.values()).map((def) => this.toMCPResource(def));
19088
+ }
19089
+ /**
19090
+ * Read a specific resource by URI
19091
+ */
19092
+ async readResource(uri) {
19093
+ const def = this.resources.get(uri);
19094
+ if (!def) {
19095
+ throw new Error(`Resource not found: ${uri}`);
19096
+ }
19097
+ let contents;
19098
+ if (def.contentProvider) {
19099
+ let content;
19100
+ try {
19101
+ content = await def.contentProvider();
19102
+ } catch (error) {
19103
+ throw new Error(
19104
+ `Failed to load content for resource "${uri}": ${error instanceof Error ? error.message : String(error)}`
19105
+ );
19106
+ }
19107
+ if (typeof content === "string") {
19108
+ contents = [
19109
+ {
19110
+ uri: def.uri,
19111
+ mimeType: def.mimeType,
19112
+ text: content
19113
+ }
19114
+ ];
19115
+ } else {
19116
+ contents = [
19117
+ {
19118
+ uri: def.uri,
19119
+ mimeType: def.mimeType,
19120
+ blob: content.blob
19121
+ }
19122
+ ];
19123
+ }
19124
+ } else if (def.text !== void 0) {
19125
+ contents = [
19126
+ {
19127
+ uri: def.uri,
19128
+ mimeType: def.mimeType,
19129
+ text: def.text
19130
+ }
19131
+ ];
19132
+ } else if (def.blob !== void 0) {
19133
+ contents = [
19134
+ {
19135
+ uri: def.uri,
19136
+ mimeType: def.mimeType,
19137
+ blob: def.blob
19138
+ }
19139
+ ];
19140
+ } else {
19141
+ throw new Error(`Resource "${uri}" has no content`);
19142
+ }
19143
+ return { contents };
19144
+ }
19145
+ /**
19146
+ * Check if a resource exists
19147
+ */
19148
+ hasResource(uri) {
19149
+ return this.resources.has(uri);
19150
+ }
19151
+ /**
19152
+ * Get the count of resources
19153
+ */
19154
+ get count() {
19155
+ return this.resources.size;
19156
+ }
19157
+ /**
19158
+ * Convert internal resource definition to MCP Resource format
19159
+ */
19160
+ toMCPResource(def) {
19161
+ return {
19162
+ uri: def.uri,
19163
+ name: def.name,
19164
+ description: def.description,
19165
+ mimeType: def.mimeType
19166
+ };
19167
+ }
19168
+ };
19169
+
18935
19170
  // src/server.ts
18936
19171
  var OpenAPIServer = class {
18937
19172
  server;
18938
19173
  toolsManager;
18939
19174
  apiClient;
19175
+ promptsManager;
19176
+ resourcesManager;
19177
+ config;
18940
19178
  constructor(config) {
19179
+ this.config = config;
19180
+ if (config.prompts?.length) {
19181
+ this.promptsManager = new PromptsManager({ prompts: config.prompts });
19182
+ }
19183
+ if (config.resources?.length) {
19184
+ this.resourcesManager = new ResourcesManager({ resources: config.resources });
19185
+ }
19186
+ const capabilities = {
19187
+ tools: {
19188
+ list: true,
19189
+ execute: true
19190
+ }
19191
+ };
19192
+ if (this.promptsManager) {
19193
+ capabilities.prompts = {};
19194
+ }
19195
+ if (this.resourcesManager) {
19196
+ capabilities.resources = {};
19197
+ }
18941
19198
  this.server = new Server(
18942
19199
  { name: config.name, version: config.version },
18943
- {
18944
- capabilities: {
18945
- tools: {
18946
- list: true,
18947
- execute: true
18948
- }
18949
- }
18950
- }
19200
+ { capabilities }
18951
19201
  );
18952
19202
  this.toolsManager = new ToolsManager(config);
18953
19203
  const authProviderOrHeaders = config.authProvider || new StaticAuthProvider(config.headers);
@@ -19009,6 +19259,25 @@ var OpenAPIServer = class {
19009
19259
  throw error;
19010
19260
  }
19011
19261
  });
19262
+ if (this.promptsManager) {
19263
+ this.server.setRequestHandler(ListPromptsRequestSchema, async () => ({
19264
+ prompts: this.promptsManager.getAllPrompts()
19265
+ }));
19266
+ this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {
19267
+ return this.promptsManager.getPrompt(
19268
+ request.params.name,
19269
+ request.params.arguments
19270
+ );
19271
+ });
19272
+ }
19273
+ if (this.resourcesManager) {
19274
+ this.server.setRequestHandler(ListResourcesRequestSchema, async () => ({
19275
+ resources: this.resourcesManager.getAllResources()
19276
+ }));
19277
+ this.server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
19278
+ return this.resourcesManager.readResource(request.params.uri);
19279
+ });
19280
+ }
19012
19281
  }
19013
19282
  /**
19014
19283
  * Start the server with the given transport
@@ -19026,6 +19295,18 @@ var OpenAPIServer = class {
19026
19295
  }
19027
19296
  await this.server.connect(transport);
19028
19297
  }
19298
+ /**
19299
+ * Get the prompts manager (for library users to add prompts dynamically)
19300
+ */
19301
+ getPromptsManager() {
19302
+ return this.promptsManager;
19303
+ }
19304
+ /**
19305
+ * Get the resources manager (for library users to add resources dynamically)
19306
+ */
19307
+ getResourcesManager() {
19308
+ return this.resourcesManager;
19309
+ }
19029
19310
  };
19030
19311
 
19031
19312
  // node_modules/yargs/lib/platform-shims/esm.mjs
@@ -20304,11 +20585,11 @@ var parser = new YargsParser({
20304
20585
  resolve: resolve2,
20305
20586
  // TODO: figure out a way to combine ESM and CJS coverage, such that
20306
20587
  // we can exercise all the lines below:
20307
- require: (path) => {
20588
+ require: (path2) => {
20308
20589
  if (typeof __require !== "undefined") {
20309
- return __require(path);
20310
- } else if (path.match(/\.json$/)) {
20311
- return JSON.parse(readFileSync(path, "utf8"));
20590
+ return __require(path2);
20591
+ } else if (path2.match(/\.json$/)) {
20592
+ return JSON.parse(readFileSync(path2, "utf8"));
20312
20593
  } else {
20313
20594
  throw Error("only .json config files are supported in ESM");
20314
20595
  }
@@ -22833,12 +23114,12 @@ var YargsInstance = class {
22833
23114
  async getCompletion(args, done) {
22834
23115
  argsert("<array> [function]", [args, done], arguments.length);
22835
23116
  if (!done) {
22836
- return new Promise((resolve5, reject) => {
23117
+ return new Promise((resolve6, reject) => {
22837
23118
  __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
22838
23119
  if (err)
22839
23120
  reject(err);
22840
23121
  else
22841
- resolve5(completions);
23122
+ resolve6(completions);
22842
23123
  });
22843
23124
  });
22844
23125
  } else {
@@ -23957,6 +24238,18 @@ function loadConfig() {
23957
24238
  }).option("disable-abbreviation", {
23958
24239
  type: "boolean",
23959
24240
  description: "Disable name optimization"
24241
+ }).option("prompts", {
24242
+ type: "string",
24243
+ description: "Path or URL to prompts JSON/YAML file"
24244
+ }).option("prompts-inline", {
24245
+ type: "string",
24246
+ description: "Provide prompts directly as JSON string"
24247
+ }).option("resources", {
24248
+ type: "string",
24249
+ description: "Path or URL to resources JSON/YAML file"
24250
+ }).option("resources-inline", {
24251
+ type: "string",
24252
+ description: "Provide resources directly as JSON string"
23960
24253
  }).help().parseSync();
23961
24254
  let transportType;
23962
24255
  if (argv.transport === "http" || process.env.TRANSPORT_TYPE === "http") {
@@ -24034,7 +24327,11 @@ function loadConfig() {
24034
24327
  includeResources: argv.resource,
24035
24328
  includeOperations: argv.operation,
24036
24329
  toolsMode,
24037
- disableAbbreviation: disableAbbreviation ? true : void 0
24330
+ disableAbbreviation: disableAbbreviation ? true : void 0,
24331
+ promptsPath: argv.prompts || process.env.PROMPTS_PATH,
24332
+ promptsInline: argv["prompts-inline"] || process.env.PROMPTS_INLINE,
24333
+ resourcesPath: argv.resources || process.env.RESOURCES_PATH,
24334
+ resourcesInline: argv["resources-inline"] || process.env.RESOURCES_INLINE
24038
24335
  };
24039
24336
  }
24040
24337
 
@@ -24103,13 +24400,13 @@ var StreamableHttpServerTransport = class {
24103
24400
  if (this.started) {
24104
24401
  throw new Error("Transport already started");
24105
24402
  }
24106
- return new Promise((resolve5, reject) => {
24403
+ return new Promise((resolve6, reject) => {
24107
24404
  this.server.listen(this.port, this.host, () => {
24108
24405
  this.started = true;
24109
24406
  console.error(
24110
24407
  `Streamable HTTP transport listening on http://${this.host}:${this.port}${this.endpointPath}`
24111
24408
  );
24112
- resolve5();
24409
+ resolve6();
24113
24410
  });
24114
24411
  this.server.on("error", (err) => {
24115
24412
  reject(err);
@@ -24139,7 +24436,7 @@ var StreamableHttpServerTransport = class {
24139
24436
  }
24140
24437
  return;
24141
24438
  }
24142
- return new Promise((resolve5, reject) => {
24439
+ return new Promise((resolve6, reject) => {
24143
24440
  this.server.close((err) => {
24144
24441
  if (err) {
24145
24442
  reject(err instanceof Error ? err : new Error(String(err)));
@@ -24148,7 +24445,7 @@ var StreamableHttpServerTransport = class {
24148
24445
  if (this.onclose) {
24149
24446
  this.onclose();
24150
24447
  }
24151
- resolve5();
24448
+ resolve6();
24152
24449
  }
24153
24450
  });
24154
24451
  });
@@ -24630,10 +24927,82 @@ var StreamableHttpServerTransport = class {
24630
24927
  }
24631
24928
  };
24632
24929
 
24930
+ // src/content-loader.ts
24931
+ import * as fs from "fs";
24932
+ import * as path from "path";
24933
+ async function loadContent(pathOrUrl, inline) {
24934
+ if (inline) {
24935
+ return inline;
24936
+ }
24937
+ if (!pathOrUrl) {
24938
+ return void 0;
24939
+ }
24940
+ if (pathOrUrl.startsWith("http://") || pathOrUrl.startsWith("https://")) {
24941
+ const response = await axios_default.get(pathOrUrl, {
24942
+ responseType: "text",
24943
+ headers: { Accept: "application/json, application/yaml, text/yaml" }
24944
+ });
24945
+ return response.data;
24946
+ }
24947
+ const absolutePath = path.isAbsolute(pathOrUrl) ? pathOrUrl : path.resolve(process.cwd(), pathOrUrl);
24948
+ return fs.readFileSync(absolutePath, "utf-8");
24949
+ }
24950
+ function parseContent(content, source) {
24951
+ try {
24952
+ return JSON.parse(content);
24953
+ } catch {
24954
+ try {
24955
+ return js_yaml_default.load(content);
24956
+ } catch (yamlError) {
24957
+ throw new Error(
24958
+ `Failed to parse ${source} as JSON or YAML: ${yamlError}`
24959
+ );
24960
+ }
24961
+ }
24962
+ }
24963
+ async function loadPrompts(pathOrUrl, inline) {
24964
+ const content = await loadContent(pathOrUrl, inline);
24965
+ if (!content) {
24966
+ return void 0;
24967
+ }
24968
+ const source = inline ? "inline prompts" : pathOrUrl;
24969
+ const prompts = parseContent(content, source);
24970
+ if (!Array.isArray(prompts)) {
24971
+ throw new Error(`Prompts must be an array, got: ${typeof prompts}`);
24972
+ }
24973
+ return prompts;
24974
+ }
24975
+ async function loadResources(pathOrUrl, inline) {
24976
+ const content = await loadContent(pathOrUrl, inline);
24977
+ if (!content) {
24978
+ return void 0;
24979
+ }
24980
+ const source = inline ? "inline resources" : pathOrUrl;
24981
+ const resources = parseContent(content, source);
24982
+ if (!Array.isArray(resources)) {
24983
+ throw new Error(`Resources must be an array, got: ${typeof resources}`);
24984
+ }
24985
+ return resources;
24986
+ }
24987
+
24633
24988
  // src/index.ts
24634
24989
  async function main() {
24635
24990
  try {
24636
24991
  const config = loadConfig();
24992
+ if (config.promptsPath || config.promptsInline) {
24993
+ const prompts = await loadPrompts(config.promptsPath, config.promptsInline);
24994
+ if (prompts) {
24995
+ config.prompts = prompts;
24996
+ console.error(`Loaded ${prompts.length} prompt(s)`);
24997
+ }
24998
+ }
24999
+ if (config.resourcesPath || config.resourcesInline) {
25000
+ const resources = await loadResources(config.resourcesPath, config.resourcesInline);
25001
+ if (resources) {
25002
+ config.resources = resources;
25003
+ console.error(`Loaded ${resources.length} resource(s)`);
25004
+ }
25005
+ }
24637
25006
  const server = new OpenAPIServer(config);
24638
25007
  let transport;
24639
25008
  if (config.transportType === "http") {