@kubb/mcp 5.0.0-beta.62 → 5.0.0-beta.64

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.cjs CHANGED
@@ -21,11 +21,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  enumerable: true
22
22
  }) : target, mod));
23
23
  //#endregion
24
- let node_http = require("node:http");
25
- node_http = __toESM(node_http, 1);
26
- let _remix_run_node_fetch_server = require("@remix-run/node-fetch-server");
27
24
  let _tmcp_adapter_valibot = require("@tmcp/adapter-valibot");
28
- let _tmcp_transport_http = require("@tmcp/transport-http");
29
25
  let _tmcp_transport_stdio = require("@tmcp/transport-stdio");
30
26
  let tmcp = require("tmcp");
31
27
  let node_events = require("node:events");
@@ -43,7 +39,7 @@ let jiti = require("jiti");
43
39
  let node_process = require("node:process");
44
40
  node_process = __toESM(node_process, 1);
45
41
  //#region package.json
46
- var version = "5.0.0-beta.62";
42
+ var version = "5.0.0-beta.64";
47
43
  //#endregion
48
44
  //#region ../../internals/utils/src/errors.ts
49
45
  /**
@@ -273,6 +269,10 @@ var Runtime = class {
273
269
  const runtime = new Runtime();
274
270
  //#endregion
275
271
  //#region src/constants.ts
272
+ /**
273
+ * File extensions a Kubb config is allowed to use. A config path with any other
274
+ * extension is rejected before it is loaded.
275
+ */
276
276
  const ALLOWED_CONFIG_EXTENSIONS = new Set([
277
277
  ".ts",
278
278
  ".mts",
@@ -281,6 +281,10 @@ const ALLOWED_CONFIG_EXTENSIONS = new Set([
281
281
  ".mjs",
282
282
  ".cjs"
283
283
  ]);
284
+ /**
285
+ * Notification kinds reported back to the MCP client while loading config and
286
+ * running generation, covering progress, results, and errors.
287
+ */
284
288
  const NotifyTypes = {
285
289
  INFO: "INFO",
286
290
  SUCCESS: "SUCCESS",
@@ -483,11 +487,11 @@ function formatDiagnostics(diagnostics) {
483
487
  return diagnostics.map((diagnostic) => formatDiagnostic(diagnostic)).join("\n\n");
484
488
  }
485
489
  function formatDiagnostic(diagnostic) {
486
- const { code, severity, message, location, help, plugin, docsUrl } = diagnostic;
487
- const lines = [`${severity} ${plugin ? `${plugin}(${code})` : code}: ${message}`];
488
- if (location && "pointer" in location) lines.push(` at ${location.pointer}`);
489
- if (help) lines.push(` help: ${help}`);
490
- if (docsUrl) lines.push(` docs: ${docsUrl}`);
490
+ const { code, message, location, help, plugin, docsUrl } = diagnostic;
491
+ const lines = [plugin ? `[${code}] ${plugin}: ${message}` : `[${code}]: ${message}`];
492
+ if (location && "pointer" in location) lines.push(` at: ${location.pointer}`);
493
+ if (help) lines.push(` fix: ${help}`);
494
+ if (docsUrl) lines.push(` see: ${docsUrl}`);
491
495
  return lines.join("\n");
492
496
  }
493
497
  const loader = createModuleLoader();
@@ -500,6 +504,14 @@ async function loadModule(filePath) {
500
504
  loadedModules.set(filePath, mod);
501
505
  return mod;
502
506
  }
507
+ /**
508
+ * Loads the user's Kubb config and returns it with the directory it was found in.
509
+ *
510
+ * When `configPath` is given it must use an allowed extension and resolve inside
511
+ * the current working directory, otherwise loading throws. When omitted, the
512
+ * known `kubb.config.*` file names are tried in the current directory. Every
513
+ * outcome is reported through `notify` before the function returns or throws.
514
+ */
503
515
  async function loadUserConfig(configPath, { notify }) {
504
516
  if (configPath) {
505
517
  const ext = node_path.default.extname(configPath);
@@ -568,6 +580,12 @@ function resolveCwd(userConfig, cwd) {
568
580
  }
569
581
  return cwd;
570
582
  }
583
+ /**
584
+ * Normalizes a possible config into a single resolved `Config`.
585
+ *
586
+ * Calls the config when it is a function, awaits it when it is a promise, and
587
+ * picks the first entry when it resolves to an array.
588
+ */
571
589
  async function resolveUserConfig(config, options) {
572
590
  const result = typeof config === "function" ? config({
573
591
  logLevel: options.logLevel,
@@ -686,6 +704,10 @@ const initSchema = valibot.object({
686
704
  });
687
705
  //#endregion
688
706
  //#region src/tools/init.ts
707
+ /**
708
+ * Resolves a comma-separated plugin flag into the matching known plugin options.
709
+ * Unrecognized names are dropped, and a missing flag yields an empty list.
710
+ */
689
711
  function resolvePlugins(pluginsFlag) {
690
712
  if (!pluginsFlag) return [];
691
713
  const requested = pluginsFlag.split(",").map((v) => v.trim()).filter(Boolean);
@@ -734,6 +756,12 @@ const validateTool = (0, tmcp_tool.defineTool)({
734
756
  });
735
757
  //#endregion
736
758
  //#region src/server.ts
759
+ /**
760
+ * Builds the Kubb MCP server with the generate, validate, and init tools registered.
761
+ *
762
+ * @example
763
+ * `const server = createMcpServer()`
764
+ */
737
765
  function createMcpServer() {
738
766
  const server = new tmcp.McpServer({
739
767
  name: "Kubb",
@@ -749,31 +777,21 @@ function createMcpServer() {
749
777
  ]);
750
778
  return server;
751
779
  }
752
- async function startServer({ port, host = "localhost" } = {}) {
753
- const server = createMcpServer();
754
- if (port === void 0) {
755
- new _tmcp_transport_stdio.StdioTransport(server).listen();
756
- return;
757
- }
758
- const transport = new _tmcp_transport_http.HttpTransport(server, { path: "/mcp" });
759
- const httpServer = node_http.default.createServer((0, _remix_run_node_fetch_server.createRequestListener)(async (request) => {
760
- return await transport.respond(request) ?? new Response("Not Found", { status: 404 });
761
- }));
762
- httpServer.listen(port, host, () => {
763
- console.log(`Kubb MCP server on http://${host}:${port}`);
764
- });
765
- const closeServer = () => httpServer.close();
766
- process.once("SIGINT", closeServer);
767
- process.once("SIGTERM", closeServer);
768
- httpServer.once("close", () => {
769
- process.off("SIGINT", closeServer);
770
- process.off("SIGTERM", closeServer);
771
- });
780
+ /**
781
+ * Starts the Kubb MCP server over stdio, the transport every local MCP client
782
+ * (Claude, Copilot, editors) uses when it launches the server as a subprocess.
783
+ */
784
+ async function startServer() {
785
+ new _tmcp_transport_stdio.StdioTransport(createMcpServer()).listen();
772
786
  }
773
787
  //#endregion
774
788
  //#region src/index.ts
775
- async function run(_argv, options) {
776
- await startServer(options);
789
+ /**
790
+ * Entry point that starts the MCP server over stdio. The argument is accepted
791
+ * for CLI parity but ignored.
792
+ */
793
+ async function run(_argv) {
794
+ await startServer();
777
795
  }
778
796
  //#endregion
779
797
  exports.createMcpServer = createMcpServer;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["#emitter","NodeEventEmitter","#emitAll","v","jiti","path","Diagnostics","tool","v","path","process","fs","tool","v","tool","Diagnostics","McpServer","ValibotJsonSchemaAdapter","StdioTransport","HttpTransport","http"],"sources":["../package.json","../../../internals/utils/src/errors.ts","../../../internals/utils/src/asyncEventEmitter.ts","../../../internals/utils/src/promise.ts","../../../internals/utils/src/runtime.ts","../src/constants.ts","../src/schemas/generateSchema.ts","../../../internals/shared/src/constants.ts","../../../internals/shared/src/init.ts","../../../internals/shared/src/loader.ts","../src/utils.ts","../src/tools/generate.ts","../src/schemas/initSchema.ts","../src/tools/init.ts","../src/schemas/validateSchema.ts","../src/tools/validate.ts","../src/server.ts","../src/index.ts"],"sourcesContent":["","/**\n * Thrown when one or more errors occur during a Kubb build.\n * Carries the full list of underlying errors on `errors`.\n *\n * @example\n * ```ts\n * throw new BuildError('Build failed', { errors: [err1, err2] })\n * ```\n */\nexport class BuildError extends Error {\n errors: Array<Error>\n\n constructor(message: string, options: { cause?: Error; errors: Array<Error> }) {\n super(message, { cause: options.cause })\n this.name = 'BuildError'\n this.errors = options.errors\n }\n}\n\n/**\n * Coerces an unknown thrown value to an `Error` instance.\n * Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.\n *\n * @example\n * ```ts\n * try { ... } catch(err) {\n * throw new BuildError('Build failed', { cause: toError(err), errors: [] })\n * }\n * ```\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Extracts a human-readable message from any thrown value.\n *\n * @example\n * ```ts\n * getErrorMessage(new Error('oops')) // 'oops'\n * getErrorMessage('plain string') // 'plain string'\n * ```\n */\nexport function getErrorMessage(value: unknown): string {\n return value instanceof Error ? value.message : String(value)\n}\n\n/**\n * Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.\n *\n * @example\n * ```ts\n * const cause = toCause(buildError) // Error | undefined\n * ```\n */\nexport function toCause(error: Error): Error | undefined {\n return error.cause instanceof Error ? error.cause : undefined\n}\n","import { EventEmitter as NodeEventEmitter } from 'node:events'\nimport { toError } from './errors.ts'\n\n/**\n * A function that can be registered as an event listener, synchronous or async.\n */\ntype AsyncListener<TArgs extends Array<unknown>> = (...args: TArgs) => void | Promise<void>\n\n/**\n * Typed `EventEmitter` that awaits all async listeners before resolving.\n * Wraps Node's `EventEmitter` with full TypeScript event-map inference.\n *\n * @example\n * ```ts\n * const emitter = new AsyncEventEmitter<{ build: [name: string] }>()\n * emitter.on('build', async (name) => { console.log(name) })\n * await emitter.emit('build', 'petstore') // all listeners awaited\n * ```\n */\nexport class AsyncEventEmitter<TEvents extends { [K in keyof TEvents]: Array<unknown> }> {\n /**\n * Maximum number of listeners per event before Node emits a memory-leak warning.\n * @default 10\n */\n constructor(maxListener = 10) {\n this.#emitter.setMaxListeners(maxListener)\n }\n\n #emitter = new NodeEventEmitter()\n\n /**\n * Emits `eventName` and awaits all registered listeners sequentially.\n * Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.\n *\n * @example\n * ```ts\n * await emitter.emit('build', 'petstore')\n * ```\n */\n emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void> | void {\n const listeners = this.#emitter.listeners(eventName) as Array<AsyncListener<TEvents[TEventName]>>\n\n if (listeners.length === 0) {\n return\n }\n\n return this.#emitAll(eventName, listeners, eventArgs)\n }\n\n async #emitAll<TEventName extends keyof TEvents & string>(\n eventName: TEventName,\n listeners: Array<AsyncListener<TEvents[TEventName]>>,\n eventArgs: TEvents[TEventName],\n ): Promise<void> {\n for (const listener of listeners) {\n try {\n await listener(...eventArgs)\n } catch (err) {\n let serializedArgs: string\n try {\n serializedArgs = JSON.stringify(eventArgs)\n } catch {\n serializedArgs = String(eventArgs)\n }\n throw new Error(`Error in async listener for \"${eventName}\" with eventArgs ${serializedArgs}`, { cause: toError(err) })\n }\n }\n }\n\n /**\n * Registers a persistent listener for `eventName`.\n *\n * @example\n * ```ts\n * emitter.on('build', async (name) => { console.log(name) })\n * ```\n */\n on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void {\n this.#emitter.on(eventName, handler as AsyncListener<Array<unknown>>)\n }\n\n /**\n * Registers a one-shot listener that removes itself after the first invocation.\n *\n * @example\n * ```ts\n * emitter.onOnce('build', async (name) => { console.log(name) })\n * ```\n */\n onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void {\n const wrapper: AsyncListener<TEvents[TEventName]> = (...args) => {\n this.off(eventName, wrapper)\n return handler(...args)\n }\n this.on(eventName, wrapper)\n }\n\n /**\n * Removes a previously registered listener.\n *\n * @example\n * ```ts\n * emitter.off('build', handler)\n * ```\n */\n off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void {\n this.#emitter.off(eventName, handler as AsyncListener<Array<unknown>>)\n }\n\n /**\n * Returns the number of listeners registered for `eventName`.\n *\n * @example\n * ```ts\n * emitter.on('build', handler)\n * emitter.listenerCount('build') // 1\n * ```\n */\n listenerCount<TEventName extends keyof TEvents & string>(eventName: TEventName): number {\n return this.#emitter.listenerCount(eventName)\n }\n\n /**\n * Raises or lowers the per-event listener ceiling before Node warns about a memory leak.\n * Set this above the expected listener count when many listeners attach by design.\n *\n * @example\n * ```ts\n * emitter.setMaxListeners(40)\n * ```\n */\n setMaxListeners(max: number): void {\n this.#emitter.setMaxListeners(max)\n }\n\n /**\n * Returns the current per-event listener ceiling.\n */\n getMaxListeners(): number {\n return this.#emitter.getMaxListeners()\n }\n\n /**\n * Removes all listeners from every event channel.\n *\n * @example\n * ```ts\n * emitter.removeAll()\n * ```\n */\n removeAll(): void {\n this.#emitter.removeAllListeners()\n }\n}\n","function* chunks<T>(arr: ReadonlyArray<T>, size: number): Generator<Array<T>> {\n for (let i = 0; i < arr.length; i += size) {\n yield arr.slice(i, i + size)\n }\n}\n\nexport type ForBatchesOptions = {\n /**\n * Maximum batch size handed to `process`.\n * Parallel dispatch within a batch is the caller's responsibility\n * (typically via `Promise.all(batch.map(...))`).\n */\n concurrency: number\n /**\n * Called after every batch.\n *\n * Use a cheap, idempotent callback (e.g. one that short-circuits when there\n * is nothing new to do). The helper does not coalesce calls — if you need\n * throttling, do it inside `flush` itself.\n */\n flush?: () => Promise<void>\n}\n\n/**\n * Slices `source` into batches of `concurrency` items and awaits `process` for each batch.\n * Accepts both plain arrays (sync) and `AsyncIterable` (streaming).\n *\n * `process` controls whether items inside a batch run in parallel; this helper only\n * controls batch size and per-batch flushing.\n *\n * @example\n * ```ts\n * // parallel dispatch inside each batch\n * await forBatches(schemas, (batch) => Promise.all(batch.map(process)), { concurrency: 8 })\n *\n * // async iterable with a flush after every batch\n * await forBatches(stream.schemas, (batch) => dispatch(batch), { concurrency: 8, flush })\n * ```\n */\nexport async function forBatches<T>(\n source: ReadonlyArray<T> | AsyncIterable<T>,\n process: (batch: Array<T>) => Promise<unknown>,\n options: ForBatchesOptions,\n): Promise<void> {\n const { concurrency, flush } = options\n\n if (Array.isArray(source)) {\n for (const batch of chunks(source, concurrency)) {\n await process(batch)\n if (flush) await flush()\n }\n return\n }\n\n const batch: Array<T> = []\n for await (const item of source) {\n batch.push(item)\n if (batch.length >= concurrency) {\n await process(batch.splice(0))\n\n if (flush) await flush()\n }\n }\n if (batch.length > 0) {\n await process(batch.splice(0))\n\n if (flush) await flush()\n }\n}\n\n/** A value that may already be resolved or still pending.\n *\n * @example\n * ```ts\n * function load(id: string): PossiblePromise<string> {\n * return cache.get(id) ?? fetchRemote(id)\n * }\n * ```\n */\nexport type PossiblePromise<T> = Promise<T> | T\n\n/** Returns `true` when `result` is a thenable `Promise`.\n *\n * @example\n * ```ts\n * isPromise(Promise.resolve(1)) // true\n * isPromise(42) // false\n * ```\n */\nexport function isPromise<T>(result: PossiblePromise<T>): result is Promise<T> {\n return result !== null && result !== undefined && typeof (result as Record<string, unknown>)['then'] === 'function'\n}\n\n/** Returns `true` when `result` is a rejected `Promise.allSettled` result with a typed `reason`.\n *\n * @example\n * ```ts\n * const results = await Promise.allSettled([p1, p2])\n * results.filter(isPromiseRejectedResult<Error>).map((r) => r.reason.message)\n * ```\n */\nexport function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & { reason: T } {\n return result.status === 'rejected'\n}\n\ntype Store<TKey, TValue> = {\n has(key: TKey): boolean\n get(key: TKey): TValue | undefined\n set(key: TKey, value: TValue): unknown\n}\n\n/**\n * Wraps `factory` with a keyed cache backed by the provided store.\n *\n * Pass a `WeakMap` for object keys (results are GC-eligible when the key is\n * collected) or a `Map` for primitive keys. For multi-argument functions,\n * nest two `memoize` calls — the outer keyed by the first argument, the\n * inner (created once per outer miss) keyed by the second.\n *\n * Because the cache is owned by the caller, it can be shared, inspected, or\n * cleared independently of the memoized function.\n *\n * @example Single WeakMap key\n * ```ts\n * const cache = new WeakMap<SchemaNode, Set<string>>()\n * const getRefs = memoize(cache, (node) => collectRefs(node))\n * ```\n *\n * @example Single Map key (primitive)\n * ```ts\n * const cache = new Map<string, Resolver>()\n * const getResolver = memoize(cache, (name) => buildResolver(name))\n * ```\n *\n * @example Two-level (object + primitive)\n * ```ts\n * const outer = new WeakMap<Params[], Map<string, Params[]>>()\n * const fn = memoize(outer, (params) => memoize(new Map(), (key) => transform(params, key)))\n * fn(params)('camelcase')\n * ```\n */\nexport function memoize<TKey, TValue>(store: Store<TKey, TValue>, factory: (key: TKey) => TValue): (key: TKey) => TValue {\n return (key: TKey): TValue => {\n if (store.has(key)) return store.get(key)!\n const value = factory(key)\n store.set(key, value)\n return value\n }\n}\n\n/**\n * Container that switches between an eager `Array<T>` and a lazy `AsyncIterable<T>`.\n *\n * `Array<T>` by default. With `Stream` set to `true` it becomes `AsyncIterable<T>`, so large\n * collections can be produced lazily without holding every item in memory. Pairs with\n * {@link arrayToAsyncIterable}, which lifts a plain array into the streaming form.\n *\n * @example\n * ```ts\n * type Eager = Streamable<number> // Array<number>\n * type Lazy = Streamable<number, true> // AsyncIterable<number>\n * ```\n */\nexport type Streamable<T, Stream extends boolean = false> = Stream extends true ? AsyncIterable<T> : Array<T>\n\n/**\n * Wraps a plain array in a reusable `AsyncIterable`.\n * Each `[Symbol.asyncIterator]()` call returns a fresh generator so the\n * iterable can be consumed multiple times (e.g. once per plugin pre-scan).\n *\n * @example\n * ```ts\n * const stream = arrayToAsyncIterable([1, 2, 3])\n * for await (const n of stream) console.log(n) // 1, 2, 3\n * ```\n */\nexport function arrayToAsyncIterable<T>(arr: ReadonlyArray<T>): AsyncIterable<T> {\n return {\n [Symbol.asyncIterator]() {\n return (async function* () {\n yield* arr\n })()\n },\n }\n}\n","/**\n * Name of the JavaScript runtime executing the current process.\n */\ntype RuntimeName = 'bun' | 'deno' | 'node'\n\n/**\n * Detects the JavaScript runtime executing the current process and exposes its name and version.\n *\n * Prefer the shared {@link runtime} instance over constructing your own.\n */\nclass Runtime {\n /**\n * `true` when the current process is running under Bun.\n *\n * Detection keys off the global `Bun` object rather than `process.versions`,\n * because Bun polyfills `process.versions.node` for Node compatibility and would\n * otherwise look like Node.\n *\n * @example\n * ```ts\n * if (runtime.isBun) {\n * await Bun.write(path, data)\n * }\n * ```\n */\n get isBun(): boolean {\n return typeof Bun !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Deno.\n */\n get isDeno(): boolean {\n return typeof (globalThis as { Deno?: unknown }).Deno !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Node.\n *\n * Bun and Deno are excluded first so a polyfilled `process` does not register as Node.\n */\n get isNode(): boolean {\n return !this.isBun && !this.isDeno && typeof process !== 'undefined' && process.versions?.node != null\n }\n\n /**\n * Name of the runtime executing the current process.\n *\n * @example\n * ```ts\n * runtime.name // 'bun' when run with `bun kubb`, 'node' otherwise\n * ```\n */\n get name(): RuntimeName {\n if (this.isBun) return 'bun'\n if (this.isDeno) return 'deno'\n\n return 'node'\n }\n\n /**\n * Version of the active runtime, or an empty string when it cannot be read.\n *\n * @example\n * ```ts\n * runtime.version // '1.3.11' under Bun, '22.22.2' under Node\n * ```\n */\n get version(): string {\n if (this.isBun) return process.versions.bun ?? ''\n if (this.isDeno) return (globalThis as { Deno?: { version?: { deno?: string } } }).Deno?.version?.deno ?? ''\n\n return process.versions?.node ?? ''\n }\n}\n\n/**\n * Shared {@link Runtime} instance describing the JavaScript runtime executing the current process.\n */\nexport const runtime = new Runtime()\n","export const ALLOWED_CONFIG_EXTENSIONS = new Set(['.ts', '.mts', '.cts', '.js', '.mjs', '.cjs'])\n\nexport const NotifyTypes = {\n INFO: 'INFO',\n SUCCESS: 'SUCCESS',\n ERROR: 'ERROR',\n WARN: 'WARN',\n DIAGNOSTIC: 'DIAGNOSTIC',\n PLUGIN_START: 'PLUGIN_START',\n PLUGIN_END: 'PLUGIN_END',\n FILES_START: 'FILES_START',\n FILES_UPDATE: 'FILES_UPDATE',\n FILES_END: 'FILES_END',\n GENERATION_START: 'GENERATION_START',\n GENERATION_END: 'GENERATION_END',\n CONFIG_LOADED: 'CONFIG_LOADED',\n CONFIG_ERROR: 'CONFIG_ERROR',\n CONFIG_READY: 'CONFIG_READY',\n SETUP_START: 'SETUP_START',\n SETUP_END: 'SETUP_END',\n BUILD_START: 'BUILD_START',\n BUILD_END: 'BUILD_END',\n BUILD_FAILED: 'BUILD_FAILED',\n BUILD_SUCCESS: 'BUILD_SUCCESS',\n} as const\n","import * as v from 'valibot'\n\nexport const generateSchema = v.object({\n config: v.optional(\n v.pipe(v.string(), v.minLength(1), v.description('Path to kubb.config file (supports .ts, .js, .cjs). If not provided, will look for kubb.config.{ts,js,cjs} in current directory')),\n ),\n input: v.optional(v.pipe(v.string(), v.minLength(1), v.description('Path to OpenAPI/Swagger spec file (overrides config)'))),\n output: v.optional(v.pipe(v.string(), v.minLength(1), v.description('Output directory path (overrides config)'))),\n logLevel: v.optional(\n v.pipe(v.picklist(['silent', 'info', 'verbose']), v.description('Log level for build output')),\n 'info',\n ),\n})\n","import type { PluginOption } from './types.ts'\n\nexport const KUBB_CONFIG_FILENAME = 'kubb.config.ts' as const\n\nexport const initDefaults = {\n inputPath: './openapi.yaml',\n outputPath: './src/gen',\n plugins: ['plugin-ts'],\n} as const\n\nexport const availablePlugins: Array<PluginOption> = [\n {\n value: 'plugin-ts',\n label: 'TypeScript',\n hint: 'Recommended',\n packageName: '@kubb/plugin-ts',\n importName: 'pluginTs',\n category: 'types',\n },\n {\n value: 'plugin-client',\n label: 'Client (Fetch/Axios)',\n packageName: '@kubb/plugin-client',\n importName: 'pluginClient',\n category: 'client',\n },\n {\n value: 'plugin-react-query',\n label: 'React Query / TanStack Query',\n packageName: '@kubb/plugin-react-query',\n importName: 'pluginReactQuery',\n category: 'framework',\n },\n {\n value: 'plugin-vue-query',\n label: 'Vue Query',\n packageName: '@kubb/plugin-vue-query',\n importName: 'pluginVueQuery',\n category: 'framework',\n },\n {\n value: 'plugin-zod',\n label: 'Zod Schemas',\n packageName: '@kubb/plugin-zod',\n importName: 'pluginZod',\n category: 'validation',\n },\n {\n value: 'plugin-faker',\n label: 'Faker.js Mocks',\n packageName: '@kubb/plugin-faker',\n importName: 'pluginFaker',\n category: 'mocks',\n },\n {\n value: 'plugin-msw',\n label: 'MSW Handlers',\n packageName: '@kubb/plugin-msw',\n importName: 'pluginMsw',\n category: 'mocks',\n },\n {\n value: 'plugin-cypress',\n label: 'Cypress Tests',\n packageName: '@kubb/plugin-cypress',\n importName: 'pluginCypress',\n category: 'testing',\n },\n {\n value: 'plugin-mcp',\n label: 'MCP Server (AI / Model Context Protocol)',\n packageName: '@kubb/plugin-mcp',\n importName: 'pluginMcp',\n category: 'ai',\n },\n {\n value: 'plugin-redoc',\n label: 'ReDoc Documentation',\n packageName: '@kubb/plugin-redoc',\n importName: 'pluginRedoc',\n category: 'documentation',\n },\n]\n\nexport const pluginDefaultConfigs = {\n 'plugin-ts': `pluginTs()`,\n 'plugin-client': `pluginClient()`,\n 'plugin-react-query': `pluginReactQuery()`,\n 'plugin-vue-query': `pluginVueQuery()`,\n 'plugin-zod': `pluginZod()`,\n 'plugin-faker': `pluginFaker()`,\n 'plugin-msw': `pluginMsw()`,\n 'plugin-cypress': `pluginCypress()`,\n 'plugin-mcp': `pluginMcp()`,\n 'plugin-redoc': `pluginRedoc()`,\n} as const satisfies Record<string, string>\n","import { pluginDefaultConfigs } from './constants.ts'\nimport type { PluginOption } from './types.ts'\n\nexport function generateConfigFile({\n selectedPlugins,\n inputPath,\n outputPath,\n}: {\n selectedPlugins: Array<PluginOption>\n inputPath: string\n outputPath: string\n}): string {\n const imports = selectedPlugins.map((plugin) => `import { ${plugin.importName} } from '${plugin.packageName}'`).join('\\n')\n\n const pluginConfigs = selectedPlugins\n .map((plugin) => {\n const config = (pluginDefaultConfigs as Record<string, string>)[plugin.value] ?? `${plugin.importName}()`\n return ` ${config},`\n })\n .join('\\n')\n\n return `import { defineConfig } from 'kubb'\n${imports}\n\nexport default defineConfig({\n root: '.',\n input: {\n path: '${inputPath}',\n },\n output: {\n path: '${outputPath}',\n clean: true,\n },\n plugins: [\n${pluginConfigs}\n ],\n})\n`\n}\n","import { pathToFileURL } from 'node:url'\nimport { runtime } from '@internals/utils'\nimport { createJiti } from 'jiti'\n\n/**\n * jiti options for loading Kubb config modules: the automatic JSX runtime pointed at\n * `@kubb/renderer-jsx`, and `moduleCache` off so a re-load re-evaluates the file.\n */\nconst JITI_OPTIONS = {\n jsx: { runtime: 'automatic', importSource: '@kubb/renderer-jsx' },\n moduleCache: false,\n} satisfies Parameters<typeof createJiti>[1]\n\n/**\n * Per-call options for {@link ModuleLoader.load}.\n */\nexport type LoadModuleOptions = {\n /**\n * Return the module's default export instead of the full namespace.\n */\n default?: boolean\n /**\n * Cache-bust token appended to the import URL on the native path so a repeated load re-evaluates\n * the file instead of returning the URL-cached module. Use a file's mtime in watch mode. Ignored\n * on the jiti path, which already re-evaluates because `moduleCache` is off.\n */\n bust?: string | number\n}\n\n/**\n * Loads `.ts`/`.js` modules with a runtime-aware strategy.\n */\nexport type ModuleLoader = {\n load<T = unknown>(filePath: string, options?: LoadModuleOptions): Promise<T>\n}\n\n/**\n * Creates a runtime-aware loader for Kubb's TypeScript and JavaScript config modules.\n *\n * On Bun and Deno it imports the file natively, skipping jiti's transform step, and falls back to\n * jiti only when the native import throws. On Node it always uses jiti, which transpiles TypeScript\n * and the `@kubb/renderer-jsx` JSX runtime on the fly. The jiti instance is created lazily, so the\n * Bun/Deno happy path never pays for it.\n *\n * @example\n * ```ts\n * const config = await createModuleLoader().load('/abs/kubb.config.ts', { default: true })\n * ```\n */\nexport function createModuleLoader(): ModuleLoader {\n let jiti: ReturnType<typeof createJiti> | undefined\n const getJiti = () => (jiti ??= createJiti(import.meta.url, JITI_OPTIONS))\n\n const viaJiti = <T>(filePath: string, options?: LoadModuleOptions) =>\n (options?.default ? getJiti().import(filePath, { default: true }) : getJiti().import(filePath)) as Promise<T>\n\n const viaNative = async <T>(filePath: string, options?: LoadModuleOptions): Promise<T> => {\n const href = pathToFileURL(filePath).href\n const url = options?.bust != null ? `${href}?t=${options.bust}` : href\n const mod = (await import(url)) as Record<string, unknown>\n return (options?.default ? (mod.default ?? mod) : mod) as T\n }\n\n return {\n async load(filePath, options) {\n if (runtime.isBun || runtime.isDeno) {\n try {\n return await viaNative(filePath, options)\n } catch {\n // A native import can trip over config-specific transforms (e.g. the @kubb/renderer-jsx\n // JSX runtime). Retry through jiti, which applies them and surfaces the real error if the\n // config itself is broken.\n return viaJiti(filePath, options)\n }\n }\n return viaJiti(filePath, options)\n },\n }\n}\n","import { existsSync } from 'node:fs'\nimport path from 'node:path'\nimport { createModuleLoader } from '@internals/shared'\nimport { isPromise } from '@internals/utils'\nimport type { CLIOptions, Config, PossibleConfig, SerializedDiagnostic } from '@kubb/core'\nimport { ALLOWED_CONFIG_EXTENSIONS, NotifyTypes } from './constants.ts'\n\n/**\n * Renders serialized diagnostics as a plain-text block for an AI assistant. Each entry\n * keeps the stable `code`, the source pointer, the suggested fix, and the docs link, so\n * the agent can act on the problem rather than parsing a bare message. No ANSI styling,\n * unlike the CLI renderer.\n */\nexport function formatDiagnostics(diagnostics: ReadonlyArray<SerializedDiagnostic>): string {\n return diagnostics.map((diagnostic) => formatDiagnostic(diagnostic)).join('\\n\\n')\n}\n\nfunction formatDiagnostic(diagnostic: SerializedDiagnostic): string {\n const { code, severity, message, location, help, plugin, docsUrl } = diagnostic\n const rule = plugin ? `${plugin}(${code})` : code\n const lines = [`${severity} ${rule}: ${message}`]\n\n if (location && 'pointer' in location) {\n lines.push(` at ${location.pointer}`)\n }\n if (help) {\n lines.push(` help: ${help}`)\n }\n if (docsUrl) {\n lines.push(` docs: ${docsUrl}`)\n }\n\n return lines.join('\\n')\n}\n\ntype NotifyFunction = (type: string, message: string, data?: Record<string, unknown>) => Promise<void>\n\nconst loader = createModuleLoader()\n\nconst loadedModules = new Map<string, unknown>()\n\nasync function loadModule(filePath: string): Promise<unknown> {\n const ext = path.extname(filePath)\n if (!ALLOWED_CONFIG_EXTENSIONS.has(ext)) {\n throw new Error(`Invalid config file extension \"${ext}\". Allowed: ${[...ALLOWED_CONFIG_EXTENSIONS].join(', ')}`)\n }\n if (loadedModules.has(filePath)) {\n return loadedModules.get(filePath)\n }\n const mod = await loader.load(filePath, { default: true })\n loadedModules.set(filePath, mod)\n return mod\n}\n\nexport async function loadUserConfig(configPath: string | undefined, { notify }: { notify: NotifyFunction }): Promise<{ userConfig: Config; cwd: string }> {\n if (configPath) {\n const ext = path.extname(configPath)\n if (!ALLOWED_CONFIG_EXTENSIONS.has(ext)) {\n const msg = `Invalid config file extension \"${ext}\". Allowed: ${[...ALLOWED_CONFIG_EXTENSIONS].join(', ')}`\n await notify(NotifyTypes.CONFIG_ERROR, msg)\n throw new Error(msg)\n }\n const base = path.resolve(process.cwd())\n const resolvedConfigPath = path.resolve(base, configPath)\n const relative = path.relative(base, resolvedConfigPath)\n if (relative.startsWith('..') || path.isAbsolute(relative)) {\n const msg = 'Invalid config file path: must be within the current working directory'\n await notify(NotifyTypes.CONFIG_ERROR, msg)\n throw new Error(msg)\n }\n const cwd = path.dirname(resolvedConfigPath)\n try {\n const userConfig = (await loadModule(resolvedConfigPath)) as Config\n await notify(NotifyTypes.CONFIG_LOADED, `Loaded config from ${resolvedConfigPath}`)\n return { userConfig, cwd }\n } catch (error) {\n const msg = `Failed to load config: ${error instanceof Error ? error.message : String(error)}`\n await notify(NotifyTypes.CONFIG_ERROR, msg)\n throw new Error(msg)\n }\n }\n\n const cwd = process.cwd()\n const configFileNames = ['kubb.config.ts', 'kubb.config.mts', 'kubb.config.cts', 'kubb.config.js', 'kubb.config.cjs']\n\n for (const configFileName of configFileNames) {\n const configFilePath = path.resolve(process.cwd(), configFileName)\n if (!existsSync(configFilePath)) continue\n try {\n const userConfig = (await loadModule(configFilePath)) as Config\n await notify(NotifyTypes.CONFIG_LOADED, `Loaded ${configFileName} from current directory`)\n return { userConfig, cwd }\n } catch (err) {\n await notify(NotifyTypes.CONFIG_ERROR, `Failed to load ${configFileName}: ${err instanceof Error ? err.message : String(err)}`)\n }\n }\n\n await notify(NotifyTypes.CONFIG_ERROR, 'No config file found')\n throw new Error(`No config file found. Please provide a config path or create one of: ${configFileNames.join(', ')}`)\n}\n\n/**\n * Determine the root directory based on userConfig.root and resolvedConfigDir\n * 1. If userConfig.root exists and is absolute, use it as-is\n * 2. If userConfig.root exists and is relative, resolve it relative to config directory\n * 3. Otherwise, use the config directory as root\n */\nexport function resolveCwd(userConfig: Config, cwd: string): string {\n if (userConfig.root) {\n if (path.isAbsolute(userConfig.root)) {\n return userConfig.root\n }\n\n return path.resolve(cwd, userConfig.root)\n }\n\n return cwd\n}\n\nexport type ResolveUserConfigOptions = {\n configPath?: string\n logLevel?: string\n}\n\nexport async function resolveUserConfig(config: PossibleConfig<CLIOptions>, options: ResolveUserConfigOptions): Promise<Config> {\n const result = typeof config === 'function' ? config({ logLevel: options.logLevel as CLIOptions['logLevel'], config: options.configPath }) : config\n const resolved = isPromise(result) ? await result : result\n return (Array.isArray(resolved) ? resolved[0] : resolved) as Config\n}\n","import { AsyncEventEmitter } from '@internals/utils'\nimport { type Config, createKubb, type Diagnostic, Diagnostics, type KubbHooks } from '@kubb/core'\nimport { defineTool } from 'tmcp/tool'\nimport { tool } from 'tmcp/utils'\nimport type * as v from 'valibot'\nimport { NotifyTypes } from '../constants.ts'\nimport { generateSchema } from '../schemas/generateSchema.ts'\nimport { formatDiagnostics, loadUserConfig, resolveCwd, resolveUserConfig } from '../utils.ts'\n\nexport const generateTool = defineTool(\n {\n name: 'generate',\n description: 'Generate OpenAPI spec helpers using Kubb configuration',\n schema: generateSchema,\n },\n async function generate(schema: v.InferInput<typeof generateSchema>) {\n const { config: configPath, input, output, logLevel } = schema\n\n try {\n const hooks = new AsyncEventEmitter<KubbHooks>()\n const messages: Array<string> = []\n\n const notify = async (type: string, message: string, data?: Record<string, unknown>) => {\n messages.push(data ? `${type}: ${message} ${JSON.stringify(data)}` : `${type}: ${message}`)\n }\n\n hooks.on('kubb:info', async ({ message }: { message: string }) => {\n await notify(NotifyTypes.INFO, message)\n })\n\n hooks.on('kubb:success', async ({ message }: { message: string }) => {\n await notify(NotifyTypes.SUCCESS, message)\n })\n\n hooks.on('kubb:error', async ({ error }: { error: Error }) => {\n await notify(NotifyTypes.ERROR, error.message)\n })\n\n hooks.on('kubb:warn', async ({ message }: { message: string }) => {\n await notify(NotifyTypes.WARN, message)\n })\n\n hooks.on('kubb:diagnostic', async ({ diagnostic }: { diagnostic: Diagnostic }) => {\n await notify(NotifyTypes.DIAGNOSTIC, diagnostic.message, Diagnostics.serialize(diagnostic))\n })\n\n hooks.on('kubb:plugin:start', async ({ plugin }) => {\n await notify(NotifyTypes.PLUGIN_START, `Plugin starting: ${plugin.name}`)\n })\n\n hooks.on('kubb:plugin:end', async ({ plugin, duration }) => {\n await notify(NotifyTypes.PLUGIN_END, `Plugin finished: ${plugin.name}`, { duration })\n })\n\n hooks.on('kubb:files:processing:start', async () => {\n await notify(NotifyTypes.FILES_START, 'Starting file processing')\n })\n\n hooks.on('kubb:files:processing:update', async ({ files }: { files: Array<{ file: { name: string } }> }) => {\n await notify(NotifyTypes.FILES_UPDATE, `Processing ${files.length} files`)\n })\n\n hooks.on('kubb:files:processing:end', async () => {\n await notify(NotifyTypes.FILES_END, 'File processing complete')\n })\n\n hooks.on('kubb:generation:start', async () => {\n await notify(NotifyTypes.GENERATION_START, 'Generation started')\n })\n\n hooks.on('kubb:generation:end', async () => {\n await notify(NotifyTypes.GENERATION_END, 'Generation ended')\n })\n\n let userConfig: Config\n let cwd: string\n\n try {\n const configResult = await loadUserConfig(configPath, { notify })\n userConfig = configResult.userConfig\n cwd = configResult.cwd\n\n if (Array.isArray(userConfig)) {\n throw new Error('Array type in kubb.config.ts is not supported in this tool. Please provide a single configuration object.')\n }\n\n userConfig = await resolveUserConfig(userConfig, {\n configPath,\n logLevel,\n })\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error)\n await notify(NotifyTypes.CONFIG_ERROR, errorMessage)\n return tool.error(errorMessage)\n }\n\n const inputPath = input ?? (userConfig.input && 'path' in userConfig.input ? userConfig.input.path : undefined)\n\n const config: Config = {\n ...userConfig,\n root: resolveCwd(userConfig, cwd),\n input: inputPath\n ? {\n ...userConfig.input,\n path: inputPath,\n }\n : userConfig.input,\n output: output\n ? {\n ...userConfig.output,\n path: output,\n }\n : userConfig.output,\n }\n\n await notify(NotifyTypes.CONFIG_READY, 'Configuration ready')\n await notify(NotifyTypes.SETUP_START, 'Setting up Kubb')\n\n const kubb = createKubb(config, { hooks })\n await kubb.setup()\n await notify(NotifyTypes.SETUP_END, 'Kubb setup complete')\n\n await notify(NotifyTypes.BUILD_START, 'Starting build')\n const { files, diagnostics } = await kubb.safeBuild()\n await notify(NotifyTypes.BUILD_END, `Build complete - Generated ${files.length} files`)\n\n const problems = diagnostics.filter(Diagnostics.isProblem)\n const errors = problems.filter((diagnostic) => diagnostic.severity === 'error')\n if (errors.length > 0) {\n await notify(NotifyTypes.BUILD_FAILED, `Build failed with ${errors.length} diagnostic(s)`)\n\n const serialized = problems.map((diagnostic) => Diagnostics.serialize(diagnostic))\n return tool.error(`Build failed:\\n${formatDiagnostics(serialized)}\\n\\n\\`\\`\\`json\\n${JSON.stringify(serialized, null, 2)}\\n\\`\\`\\``)\n }\n\n await notify(NotifyTypes.BUILD_SUCCESS, `Build completed successfully - Generated ${files.length} files`)\n\n return tool.text(`Build completed successfully!\\n\\nGenerated ${files.length} files\\n\\n${messages.join('\\n')}`)\n } catch (caughtError) {\n const serialized = Diagnostics.serialize(Diagnostics.from(caughtError))\n return tool.error(`Build error:\\n${formatDiagnostics([serialized])}\\n\\n\\`\\`\\`json\\n${JSON.stringify(serialized, null, 2)}\\n\\`\\`\\``)\n }\n },\n)\n","import * as v from 'valibot'\n\nexport const initSchema = v.object({\n input: v.optional(v.pipe(v.string(), v.minLength(1), v.description('Path to OpenAPI spec (default: ./openapi.yaml)'))),\n output: v.optional(v.pipe(v.string(), v.minLength(1), v.description('Output directory (default: ./src/gen)'))),\n plugins: v.optional(v.pipe(v.string(), v.minLength(1), v.description('Comma-separated list of plugins: plugin-ts,plugin-zod,...'))),\n})\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { availablePlugins, generateConfigFile, KUBB_CONFIG_FILENAME, type PluginOption } from '@internals/shared'\nimport { defineTool } from 'tmcp/tool'\nimport { tool } from 'tmcp/utils'\nimport { initSchema } from '../schemas/initSchema.ts'\n\nexport function resolvePlugins(pluginsFlag: string | undefined): Array<PluginOption> {\n if (!pluginsFlag) {\n return []\n }\n const requested = pluginsFlag\n .split(',')\n .map((v) => v.trim())\n .filter(Boolean)\n return availablePlugins.filter((p) => requested.includes(p.value))\n}\n\nexport const initTool = defineTool(\n {\n name: 'init',\n description: 'Scaffold a kubb.config.ts in the current directory (non-interactive). Does not install packages.',\n schema: initSchema,\n },\n async ({ input = './openapi.yaml', output = './src/gen', plugins }) => {\n const selected = resolvePlugins(plugins)\n const content = generateConfigFile({ selectedPlugins: selected, inputPath: input, outputPath: output })\n const dest = path.join(process.cwd(), KUBB_CONFIG_FILENAME)\n if (fs.existsSync(dest)) {\n return tool.error(`${KUBB_CONFIG_FILENAME} already exists at ${dest}. Delete it first before running init again.`)\n }\n fs.writeFileSync(dest, content, 'utf-8')\n const packageList = ['kubb', ...selected.map((p) => p.packageName)].join(' ')\n return tool.text(`Created kubb.config.ts\\n\\nInstall packages:\\n npm install ${packageList}\\n\\nThen run:\\n npx kubb generate`)\n },\n)\n","import * as v from 'valibot'\n\nexport const validateSchema = v.object({\n input: v.pipe(v.string(), v.minLength(1), v.description('Path or URL to the OpenAPI/Swagger specification')),\n})\n","import { Diagnostics } from '@kubb/core'\nimport { defineTool } from 'tmcp/tool'\nimport { tool } from 'tmcp/utils'\nimport { validateSchema } from '../schemas/validateSchema.ts'\nimport { formatDiagnostics } from '../utils.ts'\n\nexport const validateTool = defineTool(\n {\n name: 'validate',\n description: 'Validate an OpenAPI/Swagger specification file or URL',\n schema: validateSchema,\n },\n async ({ input }) => {\n let mod: typeof import('@kubb/adapter-oas')\n try {\n mod = await import('@kubb/adapter-oas')\n } catch {\n return tool.error('The validate tool requires @kubb/adapter-oas.\\nInstall: npm install @kubb/adapter-oas')\n }\n try {\n await mod.adapterOas().validate(input, { throwOnError: true })\n return tool.text(`Validation successful: ${input}`)\n } catch (err) {\n const serialized = Diagnostics.serialize(Diagnostics.from(err))\n return tool.error(`Validation failed:\\n${formatDiagnostics([serialized])}\\n\\n\\`\\`\\`json\\n${JSON.stringify(serialized, null, 2)}\\n\\`\\`\\``)\n }\n },\n)\n","import http from 'node:http'\nimport { createRequestListener } from '@remix-run/node-fetch-server'\nimport { ValibotJsonSchemaAdapter } from '@tmcp/adapter-valibot'\nimport { HttpTransport } from '@tmcp/transport-http'\nimport { StdioTransport } from '@tmcp/transport-stdio'\nimport { McpServer } from 'tmcp'\nimport { version } from '../package.json'\nimport { generateTool } from './tools/generate.ts'\nimport { initTool } from './tools/init.ts'\nimport { validateTool } from './tools/validate.ts'\n\nexport type ServerOptions = {\n port?: number\n host?: string\n}\n\nexport function createMcpServer() {\n const server = new McpServer({ name: 'Kubb', version }, { adapter: new ValibotJsonSchemaAdapter(), capabilities: { tools: {} } })\n server.tools([generateTool, validateTool, initTool])\n return server\n}\n\nexport async function startServer({ port, host = 'localhost' }: ServerOptions = {}) {\n const server = createMcpServer()\n\n if (port === undefined) {\n new StdioTransport(server).listen()\n return\n }\n\n const transport = new HttpTransport(server, { path: '/mcp' })\n const httpServer = http.createServer(\n createRequestListener(async (request) => {\n const response = await transport.respond(request)\n return response ?? new Response('Not Found', { status: 404 })\n }),\n )\n httpServer.listen(port, host, () => {\n console.log(`Kubb MCP server on http://${host}:${port}`)\n })\n\n const closeServer = () => httpServer.close()\n process.once('SIGINT', closeServer)\n process.once('SIGTERM', closeServer)\n httpServer.once('close', () => {\n process.off('SIGINT', closeServer)\n process.off('SIGTERM', closeServer)\n })\n}\n","import { startServer } from './server.ts'\n\nexport { createMcpServer } from './server.ts'\nexport type { ServerOptions } from './server.ts'\n\nexport async function run(_argv?: Array<string>, options?: import('./server.ts').ServerOptions): Promise<void> {\n await startServer(options)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC8BA,SAAgB,QAAQ,OAAuB;CAC7C,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACjE;;;;;;;;;;;;;;ACbA,IAAa,oBAAb,MAAyF;;;;;CAKvF,YAAY,cAAc,IAAI;EAC5B,KAAKA,SAAS,gBAAgB,WAAW;CAC3C;CAEA,WAAW,IAAIC,YAAAA,aAAiB;;;;;;;;;;CAWhC,KAAgD,WAAuB,GAAG,WAAsD;EAC9H,MAAM,Y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ACA,OAAO,YAAY;EAEvC,OAAO,MADgB,UAAU,QAAQ,OAAO,KAC7B,IAAI,SAAS,aAAa,EAAE,QAAQ,IAAI,CAAC;CAC9D,CAAC,CACH;CACA,WAAW,OAAO,MAAM,YAAY;EAClC,QAAQ,IAAI,6BAA6B,KAAK,GAAG,MAAM;CACzD,CAAC;CAED,MAAM,oBAAoB,WAAW,MAAM;CAC3C,QAAQ,KAAK,UAAU,WAAW;CAClC,QAAQ,KAAK,WAAW,WAAW;CACnC,WAAW,KAAK,eAAe;EAC7B,QAAQ,IAAI,UAAU,WAAW;EACjC,QAAQ,IAAI,WAAW,WAAW;CACpC,CAAC;AACH;;;AC3CA,eAAsB,IAAI,OAAuB,SAA8D;CAC7G,MAAM,YAAY,OAAO;AAC3B"}
1
+ {"version":3,"file":"index.cjs","names":["#emitter","NodeEventEmitter","#emitAll","v","jiti","path","Diagnostics","tool","v","path","process","fs","tool","v","tool","Diagnostics","McpServer","ValibotJsonSchemaAdapter","StdioTransport"],"sources":["../package.json","../../../internals/utils/src/errors.ts","../../../internals/utils/src/asyncEventEmitter.ts","../../../internals/utils/src/promise.ts","../../../internals/utils/src/runtime.ts","../src/constants.ts","../src/schemas/generateSchema.ts","../../../internals/shared/src/constants.ts","../../../internals/shared/src/init.ts","../../../internals/shared/src/loader.ts","../src/utils.ts","../src/tools/generate.ts","../src/schemas/initSchema.ts","../src/tools/init.ts","../src/schemas/validateSchema.ts","../src/tools/validate.ts","../src/server.ts","../src/index.ts"],"sourcesContent":["","/**\n * Thrown when one or more errors occur during a Kubb build.\n * Carries the full list of underlying errors on `errors`.\n *\n * @example\n * ```ts\n * throw new BuildError('Build failed', { errors: [err1, err2] })\n * ```\n */\nexport class BuildError extends Error {\n errors: Array<Error>\n\n constructor(message: string, options: { cause?: Error; errors: Array<Error> }) {\n super(message, { cause: options.cause })\n this.name = 'BuildError'\n this.errors = options.errors\n }\n}\n\n/**\n * Coerces an unknown thrown value to an `Error` instance.\n * Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.\n *\n * @example\n * ```ts\n * try { ... } catch(err) {\n * throw new BuildError('Build failed', { cause: toError(err), errors: [] })\n * }\n * ```\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Extracts a human-readable message from any thrown value.\n *\n * @example\n * ```ts\n * getErrorMessage(new Error('oops')) // 'oops'\n * getErrorMessage('plain string') // 'plain string'\n * ```\n */\nexport function getErrorMessage(value: unknown): string {\n return value instanceof Error ? value.message : String(value)\n}\n\n/**\n * Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.\n *\n * @example\n * ```ts\n * const cause = toCause(buildError) // Error | undefined\n * ```\n */\nexport function toCause(error: Error): Error | undefined {\n return error.cause instanceof Error ? error.cause : undefined\n}\n","import { EventEmitter as NodeEventEmitter } from 'node:events'\nimport { toError } from './errors.ts'\n\n/**\n * A function that can be registered as an event listener, synchronous or async.\n */\ntype AsyncListener<TArgs extends Array<unknown>> = (...args: TArgs) => void | Promise<void>\n\n/**\n * Typed `EventEmitter` that awaits all async listeners before resolving.\n * Wraps Node's `EventEmitter` with full TypeScript event-map inference.\n *\n * @example\n * ```ts\n * const emitter = new AsyncEventEmitter<{ build: [name: string] }>()\n * emitter.on('build', async (name) => { console.log(name) })\n * await emitter.emit('build', 'petstore') // all listeners awaited\n * ```\n */\nexport class AsyncEventEmitter<TEvents extends { [K in keyof TEvents]: Array<unknown> }> {\n /**\n * Maximum number of listeners per event before Node emits a memory-leak warning.\n * @default 10\n */\n constructor(maxListener = 10) {\n this.#emitter.setMaxListeners(maxListener)\n }\n\n #emitter = new NodeEventEmitter()\n\n /**\n * Emits `eventName` and awaits all registered listeners sequentially.\n * Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.\n *\n * @example\n * ```ts\n * await emitter.emit('build', 'petstore')\n * ```\n */\n emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void> | void {\n const listeners = this.#emitter.listeners(eventName) as Array<AsyncListener<TEvents[TEventName]>>\n\n if (listeners.length === 0) {\n return\n }\n\n return this.#emitAll(eventName, listeners, eventArgs)\n }\n\n async #emitAll<TEventName extends keyof TEvents & string>(\n eventName: TEventName,\n listeners: Array<AsyncListener<TEvents[TEventName]>>,\n eventArgs: TEvents[TEventName],\n ): Promise<void> {\n for (const listener of listeners) {\n try {\n await listener(...eventArgs)\n } catch (err) {\n let serializedArgs: string\n try {\n serializedArgs = JSON.stringify(eventArgs)\n } catch {\n serializedArgs = String(eventArgs)\n }\n throw new Error(`Error in async listener for \"${eventName}\" with eventArgs ${serializedArgs}`, { cause: toError(err) })\n }\n }\n }\n\n /**\n * Registers a persistent listener for `eventName`.\n *\n * @example\n * ```ts\n * emitter.on('build', async (name) => { console.log(name) })\n * ```\n */\n on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void {\n this.#emitter.on(eventName, handler as AsyncListener<Array<unknown>>)\n }\n\n /**\n * Registers a one-shot listener that removes itself after the first invocation.\n *\n * @example\n * ```ts\n * emitter.onOnce('build', async (name) => { console.log(name) })\n * ```\n */\n onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void {\n const wrapper: AsyncListener<TEvents[TEventName]> = (...args) => {\n this.off(eventName, wrapper)\n return handler(...args)\n }\n this.on(eventName, wrapper)\n }\n\n /**\n * Removes a previously registered listener.\n *\n * @example\n * ```ts\n * emitter.off('build', handler)\n * ```\n */\n off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void {\n this.#emitter.off(eventName, handler as AsyncListener<Array<unknown>>)\n }\n\n /**\n * Returns the number of listeners registered for `eventName`.\n *\n * @example\n * ```ts\n * emitter.on('build', handler)\n * emitter.listenerCount('build') // 1\n * ```\n */\n listenerCount<TEventName extends keyof TEvents & string>(eventName: TEventName): number {\n return this.#emitter.listenerCount(eventName)\n }\n\n /**\n * Raises or lowers the per-event listener ceiling before Node warns about a memory leak.\n * Set this above the expected listener count when many listeners attach by design.\n *\n * @example\n * ```ts\n * emitter.setMaxListeners(40)\n * ```\n */\n setMaxListeners(max: number): void {\n this.#emitter.setMaxListeners(max)\n }\n\n /**\n * Returns the current per-event listener ceiling.\n */\n getMaxListeners(): number {\n return this.#emitter.getMaxListeners()\n }\n\n /**\n * Removes all listeners from every event channel.\n *\n * @example\n * ```ts\n * emitter.removeAll()\n * ```\n */\n removeAll(): void {\n this.#emitter.removeAllListeners()\n }\n}\n","function* chunks<T>(arr: ReadonlyArray<T>, size: number): Generator<Array<T>> {\n for (let i = 0; i < arr.length; i += size) {\n yield arr.slice(i, i + size)\n }\n}\n\nexport type ForBatchesOptions = {\n /**\n * Maximum batch size handed to `process`.\n * Parallel dispatch within a batch is the caller's responsibility\n * (typically via `Promise.all(batch.map(...))`).\n */\n concurrency: number\n /**\n * Called after every batch.\n *\n * Use a cheap, idempotent callback (e.g. one that short-circuits when there\n * is nothing new to do). The helper does not coalesce calls — if you need\n * throttling, do it inside `flush` itself.\n */\n flush?: () => Promise<void>\n}\n\n/**\n * Slices `source` into batches of `concurrency` items and awaits `process` for each batch.\n * Accepts both plain arrays (sync) and `AsyncIterable` (streaming).\n *\n * `process` controls whether items inside a batch run in parallel; this helper only\n * controls batch size and per-batch flushing.\n *\n * @example\n * ```ts\n * // parallel dispatch inside each batch\n * await forBatches(schemas, (batch) => Promise.all(batch.map(process)), { concurrency: 8 })\n *\n * // async iterable with a flush after every batch\n * await forBatches(stream.schemas, (batch) => dispatch(batch), { concurrency: 8, flush })\n * ```\n */\nexport async function forBatches<T>(\n source: ReadonlyArray<T> | AsyncIterable<T>,\n process: (batch: Array<T>) => Promise<unknown>,\n options: ForBatchesOptions,\n): Promise<void> {\n const { concurrency, flush } = options\n\n if (Array.isArray(source)) {\n for (const batch of chunks(source, concurrency)) {\n await process(batch)\n if (flush) await flush()\n }\n return\n }\n\n const batch: Array<T> = []\n for await (const item of source) {\n batch.push(item)\n if (batch.length >= concurrency) {\n await process(batch.splice(0))\n\n if (flush) await flush()\n }\n }\n if (batch.length > 0) {\n await process(batch.splice(0))\n\n if (flush) await flush()\n }\n}\n\n/** A value that may already be resolved or still pending.\n *\n * @example\n * ```ts\n * function load(id: string): PossiblePromise<string> {\n * return cache.get(id) ?? fetchRemote(id)\n * }\n * ```\n */\nexport type PossiblePromise<T> = Promise<T> | T\n\n/** Returns `true` when `result` is a thenable `Promise`.\n *\n * @example\n * ```ts\n * isPromise(Promise.resolve(1)) // true\n * isPromise(42) // false\n * ```\n */\nexport function isPromise<T>(result: PossiblePromise<T>): result is Promise<T> {\n return result !== null && result !== undefined && typeof (result as Record<string, unknown>)['then'] === 'function'\n}\n\n/** Returns `true` when `result` is a rejected `Promise.allSettled` result with a typed `reason`.\n *\n * @example\n * ```ts\n * const results = await Promise.allSettled([p1, p2])\n * results.filter(isPromiseRejectedResult<Error>).map((r) => r.reason.message)\n * ```\n */\nexport function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & { reason: T } {\n return result.status === 'rejected'\n}\n\ntype Store<TKey, TValue> = {\n has(key: TKey): boolean\n get(key: TKey): TValue | undefined\n set(key: TKey, value: TValue): unknown\n}\n\n/**\n * Wraps `factory` with a keyed cache backed by the provided store.\n *\n * Pass a `WeakMap` for object keys (results are GC-eligible when the key is\n * collected) or a `Map` for primitive keys. For multi-argument functions,\n * nest two `memoize` calls — the outer keyed by the first argument, the\n * inner (created once per outer miss) keyed by the second.\n *\n * Because the cache is owned by the caller, it can be shared, inspected, or\n * cleared independently of the memoized function.\n *\n * @example Single WeakMap key\n * ```ts\n * const cache = new WeakMap<SchemaNode, Set<string>>()\n * const getRefs = memoize(cache, (node) => collectRefs(node))\n * ```\n *\n * @example Single Map key (primitive)\n * ```ts\n * const cache = new Map<string, Resolver>()\n * const getResolver = memoize(cache, (name) => buildResolver(name))\n * ```\n *\n * @example Two-level (object + primitive)\n * ```ts\n * const outer = new WeakMap<Params[], Map<string, Params[]>>()\n * const fn = memoize(outer, (params) => memoize(new Map(), (key) => transform(params, key)))\n * fn(params)('camelcase')\n * ```\n */\nexport function memoize<TKey, TValue>(store: Store<TKey, TValue>, factory: (key: TKey) => TValue): (key: TKey) => TValue {\n return (key: TKey): TValue => {\n if (store.has(key)) return store.get(key)!\n const value = factory(key)\n store.set(key, value)\n return value\n }\n}\n\n/**\n * Container that switches between an eager `Array<T>` and a lazy `AsyncIterable<T>`.\n *\n * `Array<T>` by default. With `Stream` set to `true` it becomes `AsyncIterable<T>`, so large\n * collections can be produced lazily without holding every item in memory. Pairs with\n * {@link arrayToAsyncIterable}, which lifts a plain array into the streaming form.\n *\n * @example\n * ```ts\n * type Eager = Streamable<number> // Array<number>\n * type Lazy = Streamable<number, true> // AsyncIterable<number>\n * ```\n */\nexport type Streamable<T, Stream extends boolean = false> = Stream extends true ? AsyncIterable<T> : Array<T>\n\n/**\n * Wraps a plain array in a reusable `AsyncIterable`.\n * Each `[Symbol.asyncIterator]()` call returns a fresh generator so the\n * iterable can be consumed multiple times (e.g. once per plugin pre-scan).\n *\n * @example\n * ```ts\n * const stream = arrayToAsyncIterable([1, 2, 3])\n * for await (const n of stream) console.log(n) // 1, 2, 3\n * ```\n */\nexport function arrayToAsyncIterable<T>(arr: ReadonlyArray<T>): AsyncIterable<T> {\n return {\n [Symbol.asyncIterator]() {\n return (async function* () {\n yield* arr\n })()\n },\n }\n}\n","/**\n * Name of the JavaScript runtime executing the current process.\n */\ntype RuntimeName = 'bun' | 'deno' | 'node'\n\n/**\n * Detects the JavaScript runtime executing the current process and exposes its name and version.\n *\n * Prefer the shared {@link runtime} instance over constructing your own.\n */\nclass Runtime {\n /**\n * `true` when the current process is running under Bun.\n *\n * Detection keys off the global `Bun` object rather than `process.versions`,\n * because Bun polyfills `process.versions.node` for Node compatibility and would\n * otherwise look like Node.\n *\n * @example\n * ```ts\n * if (runtime.isBun) {\n * await Bun.write(path, data)\n * }\n * ```\n */\n get isBun(): boolean {\n return typeof Bun !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Deno.\n */\n get isDeno(): boolean {\n return typeof (globalThis as { Deno?: unknown }).Deno !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Node.\n *\n * Bun and Deno are excluded first so a polyfilled `process` does not register as Node.\n */\n get isNode(): boolean {\n return !this.isBun && !this.isDeno && typeof process !== 'undefined' && process.versions?.node != null\n }\n\n /**\n * Name of the runtime executing the current process.\n *\n * @example\n * ```ts\n * runtime.name // 'bun' when run with `bun kubb`, 'node' otherwise\n * ```\n */\n get name(): RuntimeName {\n if (this.isBun) return 'bun'\n if (this.isDeno) return 'deno'\n\n return 'node'\n }\n\n /**\n * Version of the active runtime, or an empty string when it cannot be read.\n *\n * @example\n * ```ts\n * runtime.version // '1.3.11' under Bun, '22.22.2' under Node\n * ```\n */\n get version(): string {\n if (this.isBun) return process.versions.bun ?? ''\n if (this.isDeno) return (globalThis as { Deno?: { version?: { deno?: string } } }).Deno?.version?.deno ?? ''\n\n return process.versions?.node ?? ''\n }\n}\n\n/**\n * Shared {@link Runtime} instance describing the JavaScript runtime executing the current process.\n */\nexport const runtime = new Runtime()\n","/**\n * File extensions a Kubb config is allowed to use. A config path with any other\n * extension is rejected before it is loaded.\n */\nexport const ALLOWED_CONFIG_EXTENSIONS = new Set(['.ts', '.mts', '.cts', '.js', '.mjs', '.cjs'])\n\n/**\n * Notification kinds reported back to the MCP client while loading config and\n * running generation, covering progress, results, and errors.\n */\nexport const NotifyTypes = {\n INFO: 'INFO',\n SUCCESS: 'SUCCESS',\n ERROR: 'ERROR',\n WARN: 'WARN',\n DIAGNOSTIC: 'DIAGNOSTIC',\n PLUGIN_START: 'PLUGIN_START',\n PLUGIN_END: 'PLUGIN_END',\n FILES_START: 'FILES_START',\n FILES_UPDATE: 'FILES_UPDATE',\n FILES_END: 'FILES_END',\n GENERATION_START: 'GENERATION_START',\n GENERATION_END: 'GENERATION_END',\n CONFIG_LOADED: 'CONFIG_LOADED',\n CONFIG_ERROR: 'CONFIG_ERROR',\n CONFIG_READY: 'CONFIG_READY',\n SETUP_START: 'SETUP_START',\n SETUP_END: 'SETUP_END',\n BUILD_START: 'BUILD_START',\n BUILD_END: 'BUILD_END',\n BUILD_FAILED: 'BUILD_FAILED',\n BUILD_SUCCESS: 'BUILD_SUCCESS',\n} as const\n","import * as v from 'valibot'\n\nexport const generateSchema = v.object({\n config: v.optional(\n v.pipe(v.string(), v.minLength(1), v.description('Path to kubb.config file (supports .ts, .js, .cjs). If not provided, will look for kubb.config.{ts,js,cjs} in current directory')),\n ),\n input: v.optional(v.pipe(v.string(), v.minLength(1), v.description('Path to OpenAPI/Swagger spec file (overrides config)'))),\n output: v.optional(v.pipe(v.string(), v.minLength(1), v.description('Output directory path (overrides config)'))),\n logLevel: v.optional(\n v.pipe(v.picklist(['silent', 'info', 'verbose']), v.description('Log level for build output')),\n 'info',\n ),\n})\n","import type { PluginOption } from './types.ts'\n\nexport const KUBB_CONFIG_FILENAME = 'kubb.config.ts' as const\n\nexport const initDefaults = {\n inputPath: './openapi.yaml',\n outputPath: './src/gen',\n plugins: ['plugin-ts'],\n} as const\n\nexport const availablePlugins: Array<PluginOption> = [\n {\n value: 'plugin-ts',\n label: 'TypeScript',\n hint: 'Recommended',\n packageName: '@kubb/plugin-ts',\n importName: 'pluginTs',\n category: 'types',\n },\n {\n value: 'plugin-client',\n label: 'Client (Fetch/Axios)',\n packageName: '@kubb/plugin-client',\n importName: 'pluginClient',\n category: 'client',\n },\n {\n value: 'plugin-react-query',\n label: 'React Query / TanStack Query',\n packageName: '@kubb/plugin-react-query',\n importName: 'pluginReactQuery',\n category: 'framework',\n },\n {\n value: 'plugin-vue-query',\n label: 'Vue Query',\n packageName: '@kubb/plugin-vue-query',\n importName: 'pluginVueQuery',\n category: 'framework',\n },\n {\n value: 'plugin-zod',\n label: 'Zod Schemas',\n packageName: '@kubb/plugin-zod',\n importName: 'pluginZod',\n category: 'validation',\n },\n {\n value: 'plugin-faker',\n label: 'Faker.js Mocks',\n packageName: '@kubb/plugin-faker',\n importName: 'pluginFaker',\n category: 'mocks',\n },\n {\n value: 'plugin-msw',\n label: 'MSW Handlers',\n packageName: '@kubb/plugin-msw',\n importName: 'pluginMsw',\n category: 'mocks',\n },\n {\n value: 'plugin-cypress',\n label: 'Cypress Tests',\n packageName: '@kubb/plugin-cypress',\n importName: 'pluginCypress',\n category: 'testing',\n },\n {\n value: 'plugin-mcp',\n label: 'MCP Server (AI / Model Context Protocol)',\n packageName: '@kubb/plugin-mcp',\n importName: 'pluginMcp',\n category: 'ai',\n },\n {\n value: 'plugin-redoc',\n label: 'ReDoc Documentation',\n packageName: '@kubb/plugin-redoc',\n importName: 'pluginRedoc',\n category: 'documentation',\n },\n]\n\nexport const pluginDefaultConfigs = {\n 'plugin-ts': `pluginTs()`,\n 'plugin-client': `pluginClient()`,\n 'plugin-react-query': `pluginReactQuery()`,\n 'plugin-vue-query': `pluginVueQuery()`,\n 'plugin-zod': `pluginZod()`,\n 'plugin-faker': `pluginFaker()`,\n 'plugin-msw': `pluginMsw()`,\n 'plugin-cypress': `pluginCypress()`,\n 'plugin-mcp': `pluginMcp()`,\n 'plugin-redoc': `pluginRedoc()`,\n} as const satisfies Record<string, string>\n","import { pluginDefaultConfigs } from './constants.ts'\nimport type { PluginOption } from './types.ts'\n\nexport function generateConfigFile({\n selectedPlugins,\n inputPath,\n outputPath,\n}: {\n selectedPlugins: Array<PluginOption>\n inputPath: string\n outputPath: string\n}): string {\n const imports = selectedPlugins.map((plugin) => `import { ${plugin.importName} } from '${plugin.packageName}'`).join('\\n')\n\n const pluginConfigs = selectedPlugins\n .map((plugin) => {\n const config = (pluginDefaultConfigs as Record<string, string>)[plugin.value] ?? `${plugin.importName}()`\n return ` ${config},`\n })\n .join('\\n')\n\n return `import { defineConfig } from 'kubb'\n${imports}\n\nexport default defineConfig({\n root: '.',\n input: {\n path: '${inputPath}',\n },\n output: {\n path: '${outputPath}',\n clean: true,\n },\n plugins: [\n${pluginConfigs}\n ],\n})\n`\n}\n","import { pathToFileURL } from 'node:url'\nimport { runtime } from '@internals/utils'\nimport { createJiti } from 'jiti'\n\n/**\n * jiti options for loading Kubb config modules: the automatic JSX runtime pointed at\n * `@kubb/renderer-jsx`, and `moduleCache` off so a re-load re-evaluates the file.\n */\nconst JITI_OPTIONS = {\n jsx: { runtime: 'automatic', importSource: '@kubb/renderer-jsx' },\n moduleCache: false,\n} satisfies Parameters<typeof createJiti>[1]\n\n/**\n * Per-call options for {@link ModuleLoader.load}.\n */\nexport type LoadModuleOptions = {\n /**\n * Return the module's default export instead of the full namespace.\n */\n default?: boolean\n /**\n * Cache-bust token appended to the import URL on the native path so a repeated load re-evaluates\n * the file instead of returning the URL-cached module. Use a file's mtime in watch mode. Ignored\n * on the jiti path, which already re-evaluates because `moduleCache` is off.\n */\n bust?: string | number\n}\n\n/**\n * Loads `.ts`/`.js` modules with a runtime-aware strategy.\n */\nexport type ModuleLoader = {\n load<T = unknown>(filePath: string, options?: LoadModuleOptions): Promise<T>\n}\n\n/**\n * Creates a runtime-aware loader for Kubb's TypeScript and JavaScript config modules.\n *\n * On Bun and Deno it imports the file natively, skipping jiti's transform step, and falls back to\n * jiti only when the native import throws. On Node it always uses jiti, which transpiles TypeScript\n * and the `@kubb/renderer-jsx` JSX runtime on the fly. The jiti instance is created lazily, so the\n * Bun/Deno happy path never pays for it.\n *\n * @example\n * ```ts\n * const config = await createModuleLoader().load('/abs/kubb.config.ts', { default: true })\n * ```\n */\nexport function createModuleLoader(): ModuleLoader {\n let jiti: ReturnType<typeof createJiti> | undefined\n const getJiti = () => (jiti ??= createJiti(import.meta.url, JITI_OPTIONS))\n\n const viaJiti = <T>(filePath: string, options?: LoadModuleOptions) =>\n (options?.default ? getJiti().import(filePath, { default: true }) : getJiti().import(filePath)) as Promise<T>\n\n const viaNative = async <T>(filePath: string, options?: LoadModuleOptions): Promise<T> => {\n const href = pathToFileURL(filePath).href\n const url = options?.bust != null ? `${href}?t=${options.bust}` : href\n const mod = (await import(url)) as Record<string, unknown>\n return (options?.default ? (mod.default ?? mod) : mod) as T\n }\n\n return {\n async load(filePath, options) {\n if (runtime.isBun || runtime.isDeno) {\n try {\n return await viaNative(filePath, options)\n } catch {\n // A native import can trip over config-specific transforms (e.g. the @kubb/renderer-jsx\n // JSX runtime). Retry through jiti, which applies them and surfaces the real error if the\n // config itself is broken.\n return viaJiti(filePath, options)\n }\n }\n return viaJiti(filePath, options)\n },\n }\n}\n","import { existsSync } from 'node:fs'\nimport path from 'node:path'\nimport { createModuleLoader } from '@internals/shared'\nimport { isPromise } from '@internals/utils'\nimport type { CLIOptions, Config, PossibleConfig, SerializedDiagnostic } from '@kubb/core'\nimport { ALLOWED_CONFIG_EXTENSIONS, NotifyTypes } from './constants.ts'\n\n/**\n * Renders serialized diagnostics as a plain-text block for an AI assistant. Each entry\n * keeps the stable `code`, the source pointer, the suggested fix, and the docs link, so\n * the agent can act on the problem rather than parsing a bare message. No ANSI styling,\n * unlike the CLI renderer.\n */\nexport function formatDiagnostics(diagnostics: ReadonlyArray<SerializedDiagnostic>): string {\n return diagnostics.map((diagnostic) => formatDiagnostic(diagnostic)).join('\\n\\n')\n}\n\nfunction formatDiagnostic(diagnostic: SerializedDiagnostic): string {\n const { code, message, location, help, plugin, docsUrl } = diagnostic\n const lines = [plugin ? `[${code}] ${plugin}: ${message}` : `[${code}]: ${message}`]\n\n if (location && 'pointer' in location) {\n lines.push(` at: ${location.pointer}`)\n }\n if (help) {\n lines.push(` fix: ${help}`)\n }\n if (docsUrl) {\n lines.push(` see: ${docsUrl}`)\n }\n\n return lines.join('\\n')\n}\n\ntype NotifyFunction = (type: string, message: string, data?: Record<string, unknown>) => Promise<void>\n\nconst loader = createModuleLoader()\n\nconst loadedModules = new Map<string, unknown>()\n\nasync function loadModule(filePath: string): Promise<unknown> {\n const ext = path.extname(filePath)\n if (!ALLOWED_CONFIG_EXTENSIONS.has(ext)) {\n throw new Error(`Invalid config file extension \"${ext}\". Allowed: ${[...ALLOWED_CONFIG_EXTENSIONS].join(', ')}`)\n }\n if (loadedModules.has(filePath)) {\n return loadedModules.get(filePath)\n }\n const mod = await loader.load(filePath, { default: true })\n loadedModules.set(filePath, mod)\n return mod\n}\n\n/**\n * Loads the user's Kubb config and returns it with the directory it was found in.\n *\n * When `configPath` is given it must use an allowed extension and resolve inside\n * the current working directory, otherwise loading throws. When omitted, the\n * known `kubb.config.*` file names are tried in the current directory. Every\n * outcome is reported through `notify` before the function returns or throws.\n */\nexport async function loadUserConfig(configPath: string | undefined, { notify }: { notify: NotifyFunction }): Promise<{ userConfig: Config; cwd: string }> {\n if (configPath) {\n const ext = path.extname(configPath)\n if (!ALLOWED_CONFIG_EXTENSIONS.has(ext)) {\n const msg = `Invalid config file extension \"${ext}\". Allowed: ${[...ALLOWED_CONFIG_EXTENSIONS].join(', ')}`\n await notify(NotifyTypes.CONFIG_ERROR, msg)\n throw new Error(msg)\n }\n const base = path.resolve(process.cwd())\n const resolvedConfigPath = path.resolve(base, configPath)\n const relative = path.relative(base, resolvedConfigPath)\n if (relative.startsWith('..') || path.isAbsolute(relative)) {\n const msg = 'Invalid config file path: must be within the current working directory'\n await notify(NotifyTypes.CONFIG_ERROR, msg)\n throw new Error(msg)\n }\n const cwd = path.dirname(resolvedConfigPath)\n try {\n const userConfig = (await loadModule(resolvedConfigPath)) as Config\n await notify(NotifyTypes.CONFIG_LOADED, `Loaded config from ${resolvedConfigPath}`)\n return { userConfig, cwd }\n } catch (error) {\n const msg = `Failed to load config: ${error instanceof Error ? error.message : String(error)}`\n await notify(NotifyTypes.CONFIG_ERROR, msg)\n throw new Error(msg)\n }\n }\n\n const cwd = process.cwd()\n const configFileNames = ['kubb.config.ts', 'kubb.config.mts', 'kubb.config.cts', 'kubb.config.js', 'kubb.config.cjs']\n\n for (const configFileName of configFileNames) {\n const configFilePath = path.resolve(process.cwd(), configFileName)\n if (!existsSync(configFilePath)) continue\n try {\n const userConfig = (await loadModule(configFilePath)) as Config\n await notify(NotifyTypes.CONFIG_LOADED, `Loaded ${configFileName} from current directory`)\n return { userConfig, cwd }\n } catch (err) {\n await notify(NotifyTypes.CONFIG_ERROR, `Failed to load ${configFileName}: ${err instanceof Error ? err.message : String(err)}`)\n }\n }\n\n await notify(NotifyTypes.CONFIG_ERROR, 'No config file found')\n throw new Error(`No config file found. Please provide a config path or create one of: ${configFileNames.join(', ')}`)\n}\n\n/**\n * Determine the root directory based on userConfig.root and resolvedConfigDir\n * 1. If userConfig.root exists and is absolute, use it as-is\n * 2. If userConfig.root exists and is relative, resolve it relative to config directory\n * 3. Otherwise, use the config directory as root\n */\nexport function resolveCwd(userConfig: Config, cwd: string): string {\n if (userConfig.root) {\n if (path.isAbsolute(userConfig.root)) {\n return userConfig.root\n }\n\n return path.resolve(cwd, userConfig.root)\n }\n\n return cwd\n}\n\n/**\n * Inputs forwarded to a config when it is defined as a function.\n */\nexport type ResolveUserConfigOptions = {\n /**\n * Path of the loaded config, passed through to the config function as `config`.\n */\n configPath?: string\n /**\n * Log level passed through to the config function.\n */\n logLevel?: string\n}\n\n/**\n * Normalizes a possible config into a single resolved `Config`.\n *\n * Calls the config when it is a function, awaits it when it is a promise, and\n * picks the first entry when it resolves to an array.\n */\nexport async function resolveUserConfig(config: PossibleConfig<CLIOptions>, options: ResolveUserConfigOptions): Promise<Config> {\n const result = typeof config === 'function' ? config({ logLevel: options.logLevel as CLIOptions['logLevel'], config: options.configPath }) : config\n const resolved = isPromise(result) ? await result : result\n return (Array.isArray(resolved) ? resolved[0] : resolved) as Config\n}\n","import { AsyncEventEmitter } from '@internals/utils'\nimport { type Config, createKubb, type Diagnostic, Diagnostics, type KubbHooks } from '@kubb/core'\nimport { defineTool } from 'tmcp/tool'\nimport { tool } from 'tmcp/utils'\nimport type * as v from 'valibot'\nimport { NotifyTypes } from '../constants.ts'\nimport { generateSchema } from '../schemas/generateSchema.ts'\nimport { formatDiagnostics, loadUserConfig, resolveCwd, resolveUserConfig } from '../utils.ts'\n\nexport const generateTool = defineTool(\n {\n name: 'generate',\n description: 'Generate OpenAPI spec helpers using Kubb configuration',\n schema: generateSchema,\n },\n async function generate(schema: v.InferInput<typeof generateSchema>) {\n const { config: configPath, input, output, logLevel } = schema\n\n try {\n const hooks = new AsyncEventEmitter<KubbHooks>()\n const messages: Array<string> = []\n\n const notify = async (type: string, message: string, data?: Record<string, unknown>) => {\n messages.push(data ? `${type}: ${message} ${JSON.stringify(data)}` : `${type}: ${message}`)\n }\n\n hooks.on('kubb:info', async ({ message }: { message: string }) => {\n await notify(NotifyTypes.INFO, message)\n })\n\n hooks.on('kubb:success', async ({ message }: { message: string }) => {\n await notify(NotifyTypes.SUCCESS, message)\n })\n\n hooks.on('kubb:error', async ({ error }: { error: Error }) => {\n await notify(NotifyTypes.ERROR, error.message)\n })\n\n hooks.on('kubb:warn', async ({ message }: { message: string }) => {\n await notify(NotifyTypes.WARN, message)\n })\n\n hooks.on('kubb:diagnostic', async ({ diagnostic }: { diagnostic: Diagnostic }) => {\n await notify(NotifyTypes.DIAGNOSTIC, diagnostic.message, Diagnostics.serialize(diagnostic))\n })\n\n hooks.on('kubb:plugin:start', async ({ plugin }) => {\n await notify(NotifyTypes.PLUGIN_START, `Plugin starting: ${plugin.name}`)\n })\n\n hooks.on('kubb:plugin:end', async ({ plugin, duration }) => {\n await notify(NotifyTypes.PLUGIN_END, `Plugin finished: ${plugin.name}`, { duration })\n })\n\n hooks.on('kubb:files:processing:start', async () => {\n await notify(NotifyTypes.FILES_START, 'Starting file processing')\n })\n\n hooks.on('kubb:files:processing:update', async ({ files }: { files: Array<{ file: { name: string } }> }) => {\n await notify(NotifyTypes.FILES_UPDATE, `Processing ${files.length} files`)\n })\n\n hooks.on('kubb:files:processing:end', async () => {\n await notify(NotifyTypes.FILES_END, 'File processing complete')\n })\n\n hooks.on('kubb:generation:start', async () => {\n await notify(NotifyTypes.GENERATION_START, 'Generation started')\n })\n\n hooks.on('kubb:generation:end', async () => {\n await notify(NotifyTypes.GENERATION_END, 'Generation ended')\n })\n\n let userConfig: Config\n let cwd: string\n\n try {\n const configResult = await loadUserConfig(configPath, { notify })\n userConfig = configResult.userConfig\n cwd = configResult.cwd\n\n if (Array.isArray(userConfig)) {\n throw new Error('Array type in kubb.config.ts is not supported in this tool. Please provide a single configuration object.')\n }\n\n userConfig = await resolveUserConfig(userConfig, {\n configPath,\n logLevel,\n })\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error)\n await notify(NotifyTypes.CONFIG_ERROR, errorMessage)\n return tool.error(errorMessage)\n }\n\n const inputPath = input ?? (userConfig.input && 'path' in userConfig.input ? userConfig.input.path : undefined)\n\n const config: Config = {\n ...userConfig,\n root: resolveCwd(userConfig, cwd),\n input: inputPath\n ? {\n ...userConfig.input,\n path: inputPath,\n }\n : userConfig.input,\n output: output\n ? {\n ...userConfig.output,\n path: output,\n }\n : userConfig.output,\n }\n\n await notify(NotifyTypes.CONFIG_READY, 'Configuration ready')\n await notify(NotifyTypes.SETUP_START, 'Setting up Kubb')\n\n const kubb = createKubb(config, { hooks })\n await kubb.setup()\n await notify(NotifyTypes.SETUP_END, 'Kubb setup complete')\n\n await notify(NotifyTypes.BUILD_START, 'Starting build')\n const { files, diagnostics } = await kubb.safeBuild()\n await notify(NotifyTypes.BUILD_END, `Build complete - Generated ${files.length} files`)\n\n const problems = diagnostics.filter(Diagnostics.isProblem)\n const errors = problems.filter((diagnostic) => diagnostic.severity === 'error')\n if (errors.length > 0) {\n await notify(NotifyTypes.BUILD_FAILED, `Build failed with ${errors.length} diagnostic(s)`)\n\n const serialized = problems.map((diagnostic) => Diagnostics.serialize(diagnostic))\n return tool.error(`Build failed:\\n${formatDiagnostics(serialized)}\\n\\n\\`\\`\\`json\\n${JSON.stringify(serialized, null, 2)}\\n\\`\\`\\``)\n }\n\n await notify(NotifyTypes.BUILD_SUCCESS, `Build completed successfully - Generated ${files.length} files`)\n\n return tool.text(`Build completed successfully!\\n\\nGenerated ${files.length} files\\n\\n${messages.join('\\n')}`)\n } catch (caughtError) {\n const serialized = Diagnostics.serialize(Diagnostics.from(caughtError))\n return tool.error(`Build error:\\n${formatDiagnostics([serialized])}\\n\\n\\`\\`\\`json\\n${JSON.stringify(serialized, null, 2)}\\n\\`\\`\\``)\n }\n },\n)\n","import * as v from 'valibot'\n\nexport const initSchema = v.object({\n input: v.optional(v.pipe(v.string(), v.minLength(1), v.description('Path to OpenAPI spec (default: ./openapi.yaml)'))),\n output: v.optional(v.pipe(v.string(), v.minLength(1), v.description('Output directory (default: ./src/gen)'))),\n plugins: v.optional(v.pipe(v.string(), v.minLength(1), v.description('Comma-separated list of plugins: plugin-ts,plugin-zod,...'))),\n})\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { availablePlugins, generateConfigFile, KUBB_CONFIG_FILENAME, type PluginOption } from '@internals/shared'\nimport { defineTool } from 'tmcp/tool'\nimport { tool } from 'tmcp/utils'\nimport { initSchema } from '../schemas/initSchema.ts'\n\n/**\n * Resolves a comma-separated plugin flag into the matching known plugin options.\n * Unrecognized names are dropped, and a missing flag yields an empty list.\n */\nexport function resolvePlugins(pluginsFlag: string | undefined): Array<PluginOption> {\n if (!pluginsFlag) {\n return []\n }\n const requested = pluginsFlag\n .split(',')\n .map((v) => v.trim())\n .filter(Boolean)\n return availablePlugins.filter((p) => requested.includes(p.value))\n}\n\nexport const initTool = defineTool(\n {\n name: 'init',\n description: 'Scaffold a kubb.config.ts in the current directory (non-interactive). Does not install packages.',\n schema: initSchema,\n },\n async ({ input = './openapi.yaml', output = './src/gen', plugins }) => {\n const selected = resolvePlugins(plugins)\n const content = generateConfigFile({ selectedPlugins: selected, inputPath: input, outputPath: output })\n const dest = path.join(process.cwd(), KUBB_CONFIG_FILENAME)\n if (fs.existsSync(dest)) {\n return tool.error(`${KUBB_CONFIG_FILENAME} already exists at ${dest}. Delete it first before running init again.`)\n }\n fs.writeFileSync(dest, content, 'utf-8')\n const packageList = ['kubb', ...selected.map((p) => p.packageName)].join(' ')\n return tool.text(`Created kubb.config.ts\\n\\nInstall packages:\\n npm install ${packageList}\\n\\nThen run:\\n npx kubb generate`)\n },\n)\n","import * as v from 'valibot'\n\nexport const validateSchema = v.object({\n input: v.pipe(v.string(), v.minLength(1), v.description('Path or URL to the OpenAPI/Swagger specification')),\n})\n","import { Diagnostics } from '@kubb/core'\nimport { defineTool } from 'tmcp/tool'\nimport { tool } from 'tmcp/utils'\nimport { validateSchema } from '../schemas/validateSchema.ts'\nimport { formatDiagnostics } from '../utils.ts'\n\nexport const validateTool = defineTool(\n {\n name: 'validate',\n description: 'Validate an OpenAPI/Swagger specification file or URL',\n schema: validateSchema,\n },\n async ({ input }) => {\n let mod: typeof import('@kubb/adapter-oas')\n try {\n mod = await import('@kubb/adapter-oas')\n } catch {\n return tool.error('The validate tool requires @kubb/adapter-oas.\\nInstall: npm install @kubb/adapter-oas')\n }\n try {\n await mod.adapterOas().validate(input, { throwOnError: true })\n return tool.text(`Validation successful: ${input}`)\n } catch (err) {\n const serialized = Diagnostics.serialize(Diagnostics.from(err))\n return tool.error(`Validation failed:\\n${formatDiagnostics([serialized])}\\n\\n\\`\\`\\`json\\n${JSON.stringify(serialized, null, 2)}\\n\\`\\`\\``)\n }\n },\n)\n","import { ValibotJsonSchemaAdapter } from '@tmcp/adapter-valibot'\nimport { StdioTransport } from '@tmcp/transport-stdio'\nimport { McpServer } from 'tmcp'\nimport { version } from '../package.json'\nimport { generateTool } from './tools/generate.ts'\nimport { initTool } from './tools/init.ts'\nimport { validateTool } from './tools/validate.ts'\n\n/**\n * Builds the Kubb MCP server with the generate, validate, and init tools registered.\n *\n * @example\n * `const server = createMcpServer()`\n */\nexport function createMcpServer() {\n const server = new McpServer({ name: 'Kubb', version }, { adapter: new ValibotJsonSchemaAdapter(), capabilities: { tools: {} } })\n server.tools([generateTool, validateTool, initTool])\n return server\n}\n\n/**\n * Starts the Kubb MCP server over stdio, the transport every local MCP client\n * (Claude, Copilot, editors) uses when it launches the server as a subprocess.\n */\nexport async function startServer() {\n new StdioTransport(createMcpServer()).listen()\n}\n","import { startServer } from './server.ts'\n\nexport { createMcpServer } from './server.ts'\n\n/**\n * Entry point that starts the MCP server over stdio. The argument is accepted\n * for CLI parity but ignored.\n */\nexport async function run(_argv?: Array<string>): Promise<void> {\n await startServer()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC8BA,SAAgB,QAAQ,OAAuB;CAC7C,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACjE;;;;;;;;;;;;;;ACbA,IAAa,oBAAb,MAAyF;;;;;CAKvF,YAAY,cAAc,IAAI;EAC5B,KAAKA,SAAS,gBAAgB,WAAW;CAC3C;CAEA,WAAW,IAAIC,YAAAA,aAAiB;;;;;;;;;;CAWhC,KAAgD,WAAuB,GAAG,WAAsD;EAC9H,MAAM,YAAY,KAAKD,SAAS,UAAU,SAAS;EAEnD,IAAI,UAAU,WAAW,GACvB;EAGF,OAAO,KAAKE,SAAS,WAAW,WAAW,SAAS;CACtD;CAEA,MAAMA,SACJ,WACA,WACA,WACe;EACf,KAAK,MAAM,YAAY,WACrB,IAAI;GACF,MAAM,SAAS,GAAG,SAAS;EAC7B,SAAS,KAAK;GACZ,IAAI;GACJ,IAAI;IACF,iBAAiB,KAAK,UAAU,SAAS;GAC3C,QAAQ;IACN,iBAAiB,OAAO,SAAS;GACnC;GACA,MAAM,IAAI,MAAM,gCAAgC,UAAU,mBAAmB,kBAAkB,EAAE,OAAO,QAAQ,GAAG,EAAE,CAAC;EACxH;CAEJ;;;;;;;;;CAUA,GAA8C,WAAuB,SAAmD;EACtH,KAAKF,SAAS,GAAG,WAAW,OAAwC;CACtE;;;;;;;;;CAUA,OAAkD,WAAuB,SAAmD;EAC1H,MAAM,WAA+C,GAAG,SAAS;GAC/D,KAAK,IAAI,WA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B,CAAC,UAAU,CAAC,EAAE,kBAAkB,KAAK,UAAU,YAAY,MAAM,CAAC,EAAE,SAAS;CAC1I;AACF,CACF;;;;;;;;;ACbA,SAAgB,kBAAkB;CAChC,MAAM,SAAS,IAAIE,KAAAA,UAAU;EAAE,MAAM;EAAQ;CAAQ,GAAG;EAAE,SAAS,IAAIC,sBAAAA,yBAAyB;EAAG,cAAc,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC;CAChI,OAAO,MAAM;EAAC;EAAc;EAAc;CAAQ,CAAC;CACnD,OAAO;AACT;;;;;AAMA,eAAsB,cAAc;CAClC,IAAIC,sBAAAA,eAAe,gBAAgB,CAAC,CAAC,CAAC,OAAO;AAC/C;;;;;;;AClBA,eAAsB,IAAI,OAAsC;CAC9D,MAAM,YAAY;AACpB"}
package/dist/index.d.ts CHANGED
@@ -1,15 +1,21 @@
1
- import { t as __name } from "./chunk-C0LytTxp.js";
1
+ import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
2
  import { McpServer } from "tmcp";
3
3
 
4
4
  //#region src/server.d.ts
5
- type ServerOptions = {
6
- port?: number;
7
- host?: string;
8
- };
5
+ /**
6
+ * Builds the Kubb MCP server with the generate, validate, and init tools registered.
7
+ *
8
+ * @example
9
+ * `const server = createMcpServer()`
10
+ */
9
11
  declare function createMcpServer(): McpServer<import("valibot").GenericSchema, undefined>;
10
12
  //#endregion
11
13
  //#region src/index.d.ts
12
- declare function run(_argv?: Array<string>, options?: ServerOptions): Promise<void>;
14
+ /**
15
+ * Entry point that starts the MCP server over stdio. The argument is accepted
16
+ * for CLI parity but ignored.
17
+ */
18
+ declare function run(_argv?: Array<string>): Promise<void>;
13
19
  //#endregion
14
- export { type ServerOptions, createMcpServer, run };
20
+ export { createMcpServer, run };
15
21
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,8 +1,5 @@
1
- import "./chunk-C0LytTxp.js";
2
- import http from "node:http";
3
- import { createRequestListener } from "@remix-run/node-fetch-server";
1
+ import "./rolldown-runtime-C0LytTxp.js";
4
2
  import { ValibotJsonSchemaAdapter } from "@tmcp/adapter-valibot";
5
- import { HttpTransport } from "@tmcp/transport-http";
6
3
  import { StdioTransport } from "@tmcp/transport-stdio";
7
4
  import { McpServer } from "tmcp";
8
5
  import { EventEmitter } from "node:events";
@@ -16,7 +13,7 @@ import { pathToFileURL } from "node:url";
16
13
  import { createJiti } from "jiti";
17
14
  import process$1 from "node:process";
18
15
  //#region package.json
19
- var version = "5.0.0-beta.62";
16
+ var version = "5.0.0-beta.64";
20
17
  //#endregion
21
18
  //#region ../../internals/utils/src/errors.ts
22
19
  /**
@@ -246,6 +243,10 @@ var Runtime = class {
246
243
  const runtime = new Runtime();
247
244
  //#endregion
248
245
  //#region src/constants.ts
246
+ /**
247
+ * File extensions a Kubb config is allowed to use. A config path with any other
248
+ * extension is rejected before it is loaded.
249
+ */
249
250
  const ALLOWED_CONFIG_EXTENSIONS = new Set([
250
251
  ".ts",
251
252
  ".mts",
@@ -254,6 +255,10 @@ const ALLOWED_CONFIG_EXTENSIONS = new Set([
254
255
  ".mjs",
255
256
  ".cjs"
256
257
  ]);
258
+ /**
259
+ * Notification kinds reported back to the MCP client while loading config and
260
+ * running generation, covering progress, results, and errors.
261
+ */
257
262
  const NotifyTypes = {
258
263
  INFO: "INFO",
259
264
  SUCCESS: "SUCCESS",
@@ -456,11 +461,11 @@ function formatDiagnostics(diagnostics) {
456
461
  return diagnostics.map((diagnostic) => formatDiagnostic(diagnostic)).join("\n\n");
457
462
  }
458
463
  function formatDiagnostic(diagnostic) {
459
- const { code, severity, message, location, help, plugin, docsUrl } = diagnostic;
460
- const lines = [`${severity} ${plugin ? `${plugin}(${code})` : code}: ${message}`];
461
- if (location && "pointer" in location) lines.push(` at ${location.pointer}`);
462
- if (help) lines.push(` help: ${help}`);
463
- if (docsUrl) lines.push(` docs: ${docsUrl}`);
464
+ const { code, message, location, help, plugin, docsUrl } = diagnostic;
465
+ const lines = [plugin ? `[${code}] ${plugin}: ${message}` : `[${code}]: ${message}`];
466
+ if (location && "pointer" in location) lines.push(` at: ${location.pointer}`);
467
+ if (help) lines.push(` fix: ${help}`);
468
+ if (docsUrl) lines.push(` see: ${docsUrl}`);
464
469
  return lines.join("\n");
465
470
  }
466
471
  const loader = createModuleLoader();
@@ -473,6 +478,14 @@ async function loadModule(filePath) {
473
478
  loadedModules.set(filePath, mod);
474
479
  return mod;
475
480
  }
481
+ /**
482
+ * Loads the user's Kubb config and returns it with the directory it was found in.
483
+ *
484
+ * When `configPath` is given it must use an allowed extension and resolve inside
485
+ * the current working directory, otherwise loading throws. When omitted, the
486
+ * known `kubb.config.*` file names are tried in the current directory. Every
487
+ * outcome is reported through `notify` before the function returns or throws.
488
+ */
476
489
  async function loadUserConfig(configPath, { notify }) {
477
490
  if (configPath) {
478
491
  const ext = path.extname(configPath);
@@ -541,6 +554,12 @@ function resolveCwd(userConfig, cwd) {
541
554
  }
542
555
  return cwd;
543
556
  }
557
+ /**
558
+ * Normalizes a possible config into a single resolved `Config`.
559
+ *
560
+ * Calls the config when it is a function, awaits it when it is a promise, and
561
+ * picks the first entry when it resolves to an array.
562
+ */
544
563
  async function resolveUserConfig(config, options) {
545
564
  const result = typeof config === "function" ? config({
546
565
  logLevel: options.logLevel,
@@ -659,6 +678,10 @@ const initSchema = v.object({
659
678
  });
660
679
  //#endregion
661
680
  //#region src/tools/init.ts
681
+ /**
682
+ * Resolves a comma-separated plugin flag into the matching known plugin options.
683
+ * Unrecognized names are dropped, and a missing flag yields an empty list.
684
+ */
662
685
  function resolvePlugins(pluginsFlag) {
663
686
  if (!pluginsFlag) return [];
664
687
  const requested = pluginsFlag.split(",").map((v) => v.trim()).filter(Boolean);
@@ -704,6 +727,12 @@ const validateTool = defineTool({
704
727
  });
705
728
  //#endregion
706
729
  //#region src/server.ts
730
+ /**
731
+ * Builds the Kubb MCP server with the generate, validate, and init tools registered.
732
+ *
733
+ * @example
734
+ * `const server = createMcpServer()`
735
+ */
707
736
  function createMcpServer() {
708
737
  const server = new McpServer({
709
738
  name: "Kubb",
@@ -719,31 +748,21 @@ function createMcpServer() {
719
748
  ]);
720
749
  return server;
721
750
  }
722
- async function startServer({ port, host = "localhost" } = {}) {
723
- const server = createMcpServer();
724
- if (port === void 0) {
725
- new StdioTransport(server).listen();
726
- return;
727
- }
728
- const transport = new HttpTransport(server, { path: "/mcp" });
729
- const httpServer = http.createServer(createRequestListener(async (request) => {
730
- return await transport.respond(request) ?? new Response("Not Found", { status: 404 });
731
- }));
732
- httpServer.listen(port, host, () => {
733
- console.log(`Kubb MCP server on http://${host}:${port}`);
734
- });
735
- const closeServer = () => httpServer.close();
736
- process.once("SIGINT", closeServer);
737
- process.once("SIGTERM", closeServer);
738
- httpServer.once("close", () => {
739
- process.off("SIGINT", closeServer);
740
- process.off("SIGTERM", closeServer);
741
- });
751
+ /**
752
+ * Starts the Kubb MCP server over stdio, the transport every local MCP client
753
+ * (Claude, Copilot, editors) uses when it launches the server as a subprocess.
754
+ */
755
+ async function startServer() {
756
+ new StdioTransport(createMcpServer()).listen();
742
757
  }
743
758
  //#endregion
744
759
  //#region src/index.ts
745
- async function run(_argv, options) {
746
- await startServer(options);
760
+ /**
761
+ * Entry point that starts the MCP server over stdio. The argument is accepted
762
+ * for CLI parity but ignored.
763
+ */
764
+ async function run(_argv) {
765
+ await startServer();
747
766
  }
748
767
  //#endregion
749
768
  export { createMcpServer, run };