@kubb/mcp 5.0.6 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -7,13 +7,12 @@ import { McpServer } from "tmcp";
7
7
  * @example
8
8
  * `const server = createMcpServer()`
9
9
  */
10
- declare function createMcpServer(): McpServer<import("valibot").GenericSchema, undefined>;
10
+ export declare function createMcpServer(): McpServer<import("valibot").GenericSchema, undefined>;
11
11
  //#endregion
12
12
  //#region src/index.d.ts
13
13
  /**
14
14
  * Entry point that starts the MCP server over stdio.
15
15
  */
16
- declare function run(): Promise<void>;
16
+ export declare function run(): Promise<void>;
17
17
  //#endregion
18
- export { createMcpServer, run };
19
18
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -8,10 +8,10 @@ import { defineTool } from "tmcp/tool";
8
8
  import { tool } from "tmcp/utils";
9
9
  import * as v from "valibot";
10
10
  import fs, { existsSync } from "node:fs";
11
- import path from "node:path";
11
+ import path, { isAbsolute, relative, resolve } from "node:path";
12
12
  import process$1 from "node:process";
13
13
  //#region package.json
14
- var version = "5.0.6";
14
+ var version = "5.2.0";
15
15
  //#endregion
16
16
  //#region src/schemas/generateSchema.ts
17
17
  const generateSchema = v.object({
@@ -4335,12 +4335,12 @@ var import_jiti = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((expor
4335
4335
  value: E
4336
4336
  });
4337
4337
  }, je.readInt = function(e, t, i) {
4338
- for (var n = this.options.ecmaVersion >= 12 && void 0 === t, a = i && 48 === this.input.charCodeAt(this.pos), c = this.pos, l = 0, y = 0, E = 0, w = null == t ? Infinity : t; E < w; ++E, ++this.pos) {
4338
+ for (var n = this.options.ecmaVersion >= 12 && void 0 === t, a = i && 48 === this.input.charCodeAt(this.pos), c = this.pos, l = 0, y = 0, E = 0, w = null == t ? 1 / 0 : t; E < w; ++E, ++this.pos) {
4339
4339
  var C = this.input.charCodeAt(this.pos);
4340
4340
  var S = void 0;
4341
4341
  if (n && 95 === C) a && this.raiseRecoverable(this.pos, "Numeric separator is not allowed in legacy octal numeric literals"), 95 === y && this.raiseRecoverable(this.pos, "Numeric separator must be exactly one underscore"), 0 === E && this.raiseRecoverable(this.pos, "Numeric separator is not allowed at the first of digits"), y = C;
4342
4342
  else {
4343
- if ((S = C >= 97 ? C - 97 + 10 : C >= 65 ? C - 65 + 10 : C >= 48 && C <= 57 ? C - 48 : Infinity) >= e) break;
4343
+ if ((S = C >= 97 ? C - 97 + 10 : C >= 65 ? C - 65 + 10 : C >= 48 && C <= 57 ? C - 48 : 1 / 0) >= e) break;
4344
4344
  y = C, l = l * e + S;
4345
4345
  }
4346
4346
  }
@@ -4361,8 +4361,8 @@ var import_jiti = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((expor
4361
4361
  return ++this.pos, isIdentifierStart(this.fullCharCodeAtPos()) && this.raise(this.pos, "Identifier directly after number"), this.finishToken(O.num, a);
4362
4362
  }
4363
4363
  i && /[89]/.test(this.input.slice(t, this.pos)) && (i = !1), 46 !== n || i || (++this.pos, this.readInt(10), n = this.input.charCodeAt(this.pos)), 69 !== n && 101 !== n || i || (43 !== (n = this.input.charCodeAt(++this.pos)) && 45 !== n || ++this.pos, null === this.readInt(10) && this.raise(t, "Invalid number")), isIdentifierStart(this.fullCharCodeAtPos()) && this.raise(this.pos, "Identifier directly after number");
4364
- var c;
4365
- var l = (c = this.input.slice(t, this.pos), i ? parseInt(c, 8) : parseFloat(c.replace(/_/g, "")));
4364
+ var c = this.input.slice(t, this.pos);
4365
+ var l = i ? parseInt(c, 8) : parseFloat(c.replace(/_/g, ""));
4366
4366
  return this.finishToken(O.num, l);
4367
4367
  }, je.readCodePoint = function() {
4368
4368
  var e;
@@ -5984,6 +5984,29 @@ function createModuleLoader() {
5984
5984
  } };
5985
5985
  }
5986
5986
  //#endregion
5987
+ //#region ../../internals/utils/src/fs.ts
5988
+ /**
5989
+ * Resolves to `true` when `path` is `parent` itself or nested inside it. Both sides are resolved
5990
+ * to absolute paths first, so relative and `..`-containing inputs compare correctly.
5991
+ *
5992
+ * Guards a destructive or an out-of-tree operation: before wiping an output directory, check that
5993
+ * it does not contain the project root, and before loading a path a caller supplied, check that it
5994
+ * did not escape the directory it is allowed to read from.
5995
+ *
5996
+ * @example
5997
+ * isPathInside('./src/gen', '.') // true — nested inside the root
5998
+ * isPathInside('.', '.') // true — the same directory counts as inside
5999
+ * isPathInside('.', './src/gen') // false — the root is not inside its own output
6000
+ * isPathInside('../other', '.') // false — escapes the root
6001
+ */
6002
+ function isPathInside(path, parent) {
6003
+ const resolvedPath = resolve(path);
6004
+ const resolvedParent = resolve(parent);
6005
+ if (resolvedPath === resolvedParent) return true;
6006
+ const rel = relative(resolvedParent, resolvedPath);
6007
+ return rel !== "" && !rel.startsWith("..") && !isAbsolute(rel);
6008
+ }
6009
+ //#endregion
5987
6010
  //#region ../../internals/utils/src/promise.ts
5988
6011
  /** Returns `true` when `result` is a thenable `Promise`.
5989
6012
  *
@@ -6055,8 +6078,7 @@ async function loadUserConfig(configPath, { notify }) {
6055
6078
  }
6056
6079
  const base = path.resolve(process.cwd());
6057
6080
  const resolvedConfigPath = path.resolve(base, configPath);
6058
- const relative = path.relative(base, resolvedConfigPath);
6059
- if (relative.startsWith("..") || path.isAbsolute(relative)) {
6081
+ if (!isPathInside(resolvedConfigPath, base)) {
6060
6082
  const msg = "Invalid config file path: must be within the current working directory";
6061
6083
  await notify("CONFIG_ERROR", msg);
6062
6084
  throw new Error(msg);