@kubb/mcp 5.0.0-beta.85 → 5.0.0-beta.87
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 +14 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -15
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -37,7 +37,7 @@ let jiti = require("jiti");
|
|
|
37
37
|
let node_process = require("node:process");
|
|
38
38
|
node_process = __toESM(node_process, 1);
|
|
39
39
|
//#region package.json
|
|
40
|
-
var version = "5.0.0-beta.
|
|
40
|
+
var version = "5.0.0-beta.87";
|
|
41
41
|
//#endregion
|
|
42
42
|
//#region src/constants.ts
|
|
43
43
|
/**
|
|
@@ -365,45 +365,45 @@ const generateTool = (0, tmcp_tool.defineTool)({
|
|
|
365
365
|
}, async function generate(schema) {
|
|
366
366
|
const { config: configPath, input, output, logLevel } = schema;
|
|
367
367
|
try {
|
|
368
|
-
const hooks = new _kubb_core.
|
|
368
|
+
const hooks = new _kubb_core.Hookable();
|
|
369
369
|
const messages = [];
|
|
370
370
|
const notify = async (type, message, data) => {
|
|
371
371
|
messages.push(data ? `${type}: ${message} ${JSON.stringify(data)}` : `${type}: ${message}`);
|
|
372
372
|
};
|
|
373
|
-
hooks.
|
|
373
|
+
hooks.hook("kubb:info", async ({ message }) => {
|
|
374
374
|
await notify(NotifyTypes.INFO, message);
|
|
375
375
|
});
|
|
376
|
-
hooks.
|
|
376
|
+
hooks.hook("kubb:success", async ({ message }) => {
|
|
377
377
|
await notify(NotifyTypes.SUCCESS, message);
|
|
378
378
|
});
|
|
379
|
-
hooks.
|
|
379
|
+
hooks.hook("kubb:error", async ({ error }) => {
|
|
380
380
|
await notify(NotifyTypes.ERROR, error.message);
|
|
381
381
|
});
|
|
382
|
-
hooks.
|
|
382
|
+
hooks.hook("kubb:warn", async ({ message }) => {
|
|
383
383
|
await notify(NotifyTypes.WARN, message);
|
|
384
384
|
});
|
|
385
|
-
hooks.
|
|
385
|
+
hooks.hook("kubb:diagnostic", async ({ diagnostic }) => {
|
|
386
386
|
await notify(NotifyTypes.DIAGNOSTIC, diagnostic.message, _kubb_core.Diagnostics.serialize(diagnostic));
|
|
387
387
|
});
|
|
388
|
-
hooks.
|
|
388
|
+
hooks.hook("kubb:plugin:start", async ({ plugin }) => {
|
|
389
389
|
await notify(NotifyTypes.PLUGIN_START, `Plugin starting: ${plugin.name}`);
|
|
390
390
|
});
|
|
391
|
-
hooks.
|
|
391
|
+
hooks.hook("kubb:plugin:end", async ({ plugin, duration }) => {
|
|
392
392
|
await notify(NotifyTypes.PLUGIN_END, `Plugin finished: ${plugin.name}`, { duration });
|
|
393
393
|
});
|
|
394
|
-
hooks.
|
|
394
|
+
hooks.hook("kubb:files:processing:start", async () => {
|
|
395
395
|
await notify(NotifyTypes.FILES_START, "Starting file processing");
|
|
396
396
|
});
|
|
397
|
-
hooks.
|
|
397
|
+
hooks.hook("kubb:files:processing:update", async ({ files }) => {
|
|
398
398
|
await notify(NotifyTypes.FILES_UPDATE, `Processing ${files.length} files`);
|
|
399
399
|
});
|
|
400
|
-
hooks.
|
|
400
|
+
hooks.hook("kubb:files:processing:end", async () => {
|
|
401
401
|
await notify(NotifyTypes.FILES_END, "File processing complete");
|
|
402
402
|
});
|
|
403
|
-
hooks.
|
|
403
|
+
hooks.hook("kubb:generation:start", async () => {
|
|
404
404
|
await notify(NotifyTypes.GENERATION_START, "Generation started");
|
|
405
405
|
});
|
|
406
|
-
hooks.
|
|
406
|
+
hooks.hook("kubb:generation:end", async () => {
|
|
407
407
|
await notify(NotifyTypes.GENERATION_END, "Generation ended");
|
|
408
408
|
});
|
|
409
409
|
let userConfig;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["v","jiti","path","AsyncEventEmitter","Diagnostics","tool","v","path","process","fs","tool","v","tool","Diagnostics","McpServer","ValibotJsonSchemaAdapter","StdioTransport"],"sources":["../package.json","../src/constants.ts","../src/schemas/generateSchema.ts","../../../internals/shared/src/constants.ts","../../../internals/shared/src/init.ts","../../../internals/shared/src/loader.ts","../../../internals/utils/src/promise.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 * 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-axios',\n label: 'Axios Client',\n packageName: '@kubb/plugin-axios',\n importName: 'pluginAxios',\n category: 'client',\n },\n {\n value: 'plugin-fetch',\n label: 'Fetch Client',\n packageName: '@kubb/plugin-fetch',\n importName: 'pluginFetch',\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","import 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.map((plugin) => ` ${plugin.importName}(),`).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 { 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\n/**\n * Loads `.ts`/`.js` modules via jiti.\n */\nexport type ModuleLoader = {\n load<T = unknown>(filePath: string, options?: LoadModuleOptions): Promise<T>\n}\n\n/**\n * Creates a jiti-based loader for Kubb's TypeScript and JavaScript config modules.\n *\n * jiti transpiles TypeScript and the `@kubb/renderer-jsx` JSX runtime on the fly.\n *\n * @example\n * ```ts\n * const config = await createModuleLoader().load('/abs/kubb.config.ts', { default: true })\n * ```\n */\nexport function createModuleLoader(): ModuleLoader {\n const jiti = createJiti(import.meta.url, JITI_OPTIONS)\n\n return {\n load<T>(filePath: string, options?: LoadModuleOptions) {\n return (options?.default ? jiti.import(filePath, { default: true }) : jiti.import(filePath)) as Promise<T>\n },\n }\n}\n","import { toError } from './errors.ts'\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\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\ntype SerialRunnerOptions = {\n /**\n * The async work to serialize.\n */\n run(): Promise<void>\n /**\n * Receives errors thrown by `run`, so a failure never rejects the returned trigger.\n */\n onError(error: Error): void\n}\n\n/**\n * Wraps `run` so invocations never overlap: a trigger that lands while a run is in flight\n * marks it dirty and runs once more after it finishes, no matter how many triggers arrived.\n * Useful for event-driven reruns (a file watcher, a queue drain) where bursts should\n * coalesce into a single trailing run.\n *\n * @example\n * ```ts\n * const rebuild = createSerialRunner({\n * run: () => build(),\n * onError: (error) => log.error(error.message),\n * })\n * watcher.on('change', () => void rebuild())\n * ```\n */\nexport function createSerialRunner({ run, onError }: SerialRunnerOptions): () => Promise<void> {\n let running = false\n let dirty = false\n\n return async (): Promise<void> => {\n if (running) {\n dirty = true\n return\n }\n running = true\n do {\n dirty = false\n try {\n await run()\n } catch (error) {\n onError(toError(error))\n }\n } while (dirty)\n running = false\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\n return (Array.isArray(resolved) ? resolved[0] : resolved) as Config\n}\n","import { type Config, createKubb, type Diagnostic, Diagnostics, type KubbHooks, AsyncEventEmitter } 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACIA,MAAa,4CAA4B,IAAI,IAAI;CAAC;CAAO;CAAQ;CAAQ;CAAO;CAAQ;AAAM,CAAC;;;;;AAM/F,MAAa,cAAc;CACzB,MAAM;CACN,SAAS;CACT,OAAO;CACP,MAAM;CACN,YAAY;CACZ,cAAc;CACd,YAAY;CACZ,aAAa;CACb,cAAc;CACd,WAAW;CACX,kBAAkB;CAClB,gBAAgB;CAChB,eAAe;CACf,cAAc;CACd,cAAc;CACd,aAAa;CACb,WAAW;CACX,aAAa;CACb,WAAW;CACX,cAAc;CACd,eAAe;AACjB;;;AC9BA,MAAa,iBAAiBA,QAAE,OAAO;CACrC,QAAQA,QAAE,SACRA,QAAE,KAAKA,QAAE,OAAO,GAAGA,QAAE,UAAU,CAAC,GAAGA,QAAE,YAAY,iIAAiI,CAAC,CACrL;CACA,OAAOA,QAAE,SAASA,QAAE,KAAKA,QAAE,OAAO,GAAGA,QAAE,UAAU,CAAC,GAAGA,QAAE,YAAY,sDAAsD,CAAC,CAAC;CAC3H,QAAQA,QAAE,SAASA,QAAE,KAAKA,QAAE,OAAO,GAAGA,QAAE,UAAU,CAAC,GAAGA,QAAE,YAAY,0CAA0C,CAAC,CAAC;CAChH,UAAUA,QAAE,SACVA,QAAE,KAAKA,QA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G,CAAC;EAC9D,OAAOD,WAAAA,KAAK,MAAM,uBAAuB,kBAAkB,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"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["v","jiti","path","Hookable","Diagnostics","tool","v","path","process","fs","tool","v","tool","Diagnostics","McpServer","ValibotJsonSchemaAdapter","StdioTransport"],"sources":["../package.json","../src/constants.ts","../src/schemas/generateSchema.ts","../../../internals/shared/src/constants.ts","../../../internals/shared/src/init.ts","../../../internals/shared/src/loader.ts","../../../internals/utils/src/promise.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 * 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-axios',\n label: 'Axios Client',\n packageName: '@kubb/plugin-axios',\n importName: 'pluginAxios',\n category: 'client',\n },\n {\n value: 'plugin-fetch',\n label: 'Fetch Client',\n packageName: '@kubb/plugin-fetch',\n importName: 'pluginFetch',\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","import 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.map((plugin) => ` ${plugin.importName}(),`).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 { 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\n/**\n * Loads `.ts`/`.js` modules via jiti.\n */\nexport type ModuleLoader = {\n load<T = unknown>(filePath: string, options?: LoadModuleOptions): Promise<T>\n}\n\n/**\n * Creates a jiti-based loader for Kubb's TypeScript and JavaScript config modules.\n *\n * jiti transpiles TypeScript and the `@kubb/renderer-jsx` JSX runtime on the fly.\n *\n * @example\n * ```ts\n * const config = await createModuleLoader().load('/abs/kubb.config.ts', { default: true })\n * ```\n */\nexport function createModuleLoader(): ModuleLoader {\n const jiti = createJiti(import.meta.url, JITI_OPTIONS)\n\n return {\n load<T>(filePath: string, options?: LoadModuleOptions) {\n return (options?.default ? jiti.import(filePath, { default: true }) : jiti.import(filePath)) as Promise<T>\n },\n }\n}\n","import { toError } from './errors.ts'\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\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\ntype SerialRunnerOptions = {\n /**\n * The async work to serialize.\n */\n run(): Promise<void>\n /**\n * Receives errors thrown by `run`, so a failure never rejects the returned trigger.\n */\n onError(error: Error): void\n}\n\n/**\n * Wraps `run` so invocations never overlap: a trigger that lands while a run is in flight\n * marks it dirty and runs once more after it finishes, no matter how many triggers arrived.\n * Useful for event-driven reruns (a file watcher, a queue drain) where bursts should\n * coalesce into a single trailing run.\n *\n * @example\n * ```ts\n * const rebuild = createSerialRunner({\n * run: () => build(),\n * onError: (error) => log.error(error.message),\n * })\n * watcher.on('change', () => void rebuild())\n * ```\n */\nexport function createSerialRunner({ run, onError }: SerialRunnerOptions): () => Promise<void> {\n let running = false\n let dirty = false\n\n return async (): Promise<void> => {\n if (running) {\n dirty = true\n return\n }\n running = true\n do {\n dirty = false\n try {\n await run()\n } catch (error) {\n onError(toError(error))\n }\n } while (dirty)\n running = false\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\n return (Array.isArray(resolved) ? resolved[0] : resolved) as Config\n}\n","import { type Config, createKubb, type Diagnostic, Diagnostics, type KubbHooks, Hookable } 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 Hookable<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.hook('kubb:info', async ({ message }: { message: string }) => {\n await notify(NotifyTypes.INFO, message)\n })\n\n hooks.hook('kubb:success', async ({ message }: { message: string }) => {\n await notify(NotifyTypes.SUCCESS, message)\n })\n\n hooks.hook('kubb:error', async ({ error }: { error: Error }) => {\n await notify(NotifyTypes.ERROR, error.message)\n })\n\n hooks.hook('kubb:warn', async ({ message }: { message: string }) => {\n await notify(NotifyTypes.WARN, message)\n })\n\n hooks.hook('kubb:diagnostic', async ({ diagnostic }: { diagnostic: Diagnostic }) => {\n await notify(NotifyTypes.DIAGNOSTIC, diagnostic.message, Diagnostics.serialize(diagnostic))\n })\n\n hooks.hook('kubb:plugin:start', async ({ plugin }) => {\n await notify(NotifyTypes.PLUGIN_START, `Plugin starting: ${plugin.name}`)\n })\n\n hooks.hook('kubb:plugin:end', async ({ plugin, duration }) => {\n await notify(NotifyTypes.PLUGIN_END, `Plugin finished: ${plugin.name}`, { duration })\n })\n\n hooks.hook('kubb:files:processing:start', async () => {\n await notify(NotifyTypes.FILES_START, 'Starting file processing')\n })\n\n hooks.hook('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.hook('kubb:files:processing:end', async () => {\n await notify(NotifyTypes.FILES_END, 'File processing complete')\n })\n\n hooks.hook('kubb:generation:start', async () => {\n await notify(NotifyTypes.GENERATION_START, 'Generation started')\n })\n\n hooks.hook('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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACIA,MAAa,4CAA4B,IAAI,IAAI;CAAC;CAAO;CAAQ;CAAQ;CAAO;CAAQ;AAAM,CAAC;;;;;AAM/F,MAAa,cAAc;CACzB,MAA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
|
@@ -2,7 +2,7 @@ import "./rolldown-runtime-C0LytTxp.js";
|
|
|
2
2
|
import { ValibotJsonSchemaAdapter } from "@tmcp/adapter-valibot";
|
|
3
3
|
import { StdioTransport } from "@tmcp/transport-stdio";
|
|
4
4
|
import { McpServer } from "tmcp";
|
|
5
|
-
import {
|
|
5
|
+
import { Diagnostics, Hookable, createKubb } from "@kubb/core";
|
|
6
6
|
import { defineTool } from "tmcp/tool";
|
|
7
7
|
import { tool } from "tmcp/utils";
|
|
8
8
|
import * as v from "valibot";
|
|
@@ -11,7 +11,7 @@ import path from "node:path";
|
|
|
11
11
|
import { createJiti } from "jiti";
|
|
12
12
|
import process$1 from "node:process";
|
|
13
13
|
//#region package.json
|
|
14
|
-
var version = "5.0.0-beta.
|
|
14
|
+
var version = "5.0.0-beta.87";
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/constants.ts
|
|
17
17
|
/**
|
|
@@ -339,45 +339,45 @@ const generateTool = defineTool({
|
|
|
339
339
|
}, async function generate(schema) {
|
|
340
340
|
const { config: configPath, input, output, logLevel } = schema;
|
|
341
341
|
try {
|
|
342
|
-
const hooks = new
|
|
342
|
+
const hooks = new Hookable();
|
|
343
343
|
const messages = [];
|
|
344
344
|
const notify = async (type, message, data) => {
|
|
345
345
|
messages.push(data ? `${type}: ${message} ${JSON.stringify(data)}` : `${type}: ${message}`);
|
|
346
346
|
};
|
|
347
|
-
hooks.
|
|
347
|
+
hooks.hook("kubb:info", async ({ message }) => {
|
|
348
348
|
await notify(NotifyTypes.INFO, message);
|
|
349
349
|
});
|
|
350
|
-
hooks.
|
|
350
|
+
hooks.hook("kubb:success", async ({ message }) => {
|
|
351
351
|
await notify(NotifyTypes.SUCCESS, message);
|
|
352
352
|
});
|
|
353
|
-
hooks.
|
|
353
|
+
hooks.hook("kubb:error", async ({ error }) => {
|
|
354
354
|
await notify(NotifyTypes.ERROR, error.message);
|
|
355
355
|
});
|
|
356
|
-
hooks.
|
|
356
|
+
hooks.hook("kubb:warn", async ({ message }) => {
|
|
357
357
|
await notify(NotifyTypes.WARN, message);
|
|
358
358
|
});
|
|
359
|
-
hooks.
|
|
359
|
+
hooks.hook("kubb:diagnostic", async ({ diagnostic }) => {
|
|
360
360
|
await notify(NotifyTypes.DIAGNOSTIC, diagnostic.message, Diagnostics.serialize(diagnostic));
|
|
361
361
|
});
|
|
362
|
-
hooks.
|
|
362
|
+
hooks.hook("kubb:plugin:start", async ({ plugin }) => {
|
|
363
363
|
await notify(NotifyTypes.PLUGIN_START, `Plugin starting: ${plugin.name}`);
|
|
364
364
|
});
|
|
365
|
-
hooks.
|
|
365
|
+
hooks.hook("kubb:plugin:end", async ({ plugin, duration }) => {
|
|
366
366
|
await notify(NotifyTypes.PLUGIN_END, `Plugin finished: ${plugin.name}`, { duration });
|
|
367
367
|
});
|
|
368
|
-
hooks.
|
|
368
|
+
hooks.hook("kubb:files:processing:start", async () => {
|
|
369
369
|
await notify(NotifyTypes.FILES_START, "Starting file processing");
|
|
370
370
|
});
|
|
371
|
-
hooks.
|
|
371
|
+
hooks.hook("kubb:files:processing:update", async ({ files }) => {
|
|
372
372
|
await notify(NotifyTypes.FILES_UPDATE, `Processing ${files.length} files`);
|
|
373
373
|
});
|
|
374
|
-
hooks.
|
|
374
|
+
hooks.hook("kubb:files:processing:end", async () => {
|
|
375
375
|
await notify(NotifyTypes.FILES_END, "File processing complete");
|
|
376
376
|
});
|
|
377
|
-
hooks.
|
|
377
|
+
hooks.hook("kubb:generation:start", async () => {
|
|
378
378
|
await notify(NotifyTypes.GENERATION_START, "Generation started");
|
|
379
379
|
});
|
|
380
|
-
hooks.
|
|
380
|
+
hooks.hook("kubb:generation:end", async () => {
|
|
381
381
|
await notify(NotifyTypes.GENERATION_END, "Generation ended");
|
|
382
382
|
});
|
|
383
383
|
let userConfig;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["process"],"sources":["../package.json","../src/constants.ts","../src/schemas/generateSchema.ts","../../../internals/shared/src/constants.ts","../../../internals/shared/src/init.ts","../../../internals/shared/src/loader.ts","../../../internals/utils/src/promise.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 * 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-axios',\n label: 'Axios Client',\n packageName: '@kubb/plugin-axios',\n importName: 'pluginAxios',\n category: 'client',\n },\n {\n value: 'plugin-fetch',\n label: 'Fetch Client',\n packageName: '@kubb/plugin-fetch',\n importName: 'pluginFetch',\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","import 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.map((plugin) => ` ${plugin.importName}(),`).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 { 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\n/**\n * Loads `.ts`/`.js` modules via jiti.\n */\nexport type ModuleLoader = {\n load<T = unknown>(filePath: string, options?: LoadModuleOptions): Promise<T>\n}\n\n/**\n * Creates a jiti-based loader for Kubb's TypeScript and JavaScript config modules.\n *\n * jiti transpiles TypeScript and the `@kubb/renderer-jsx` JSX runtime on the fly.\n *\n * @example\n * ```ts\n * const config = await createModuleLoader().load('/abs/kubb.config.ts', { default: true })\n * ```\n */\nexport function createModuleLoader(): ModuleLoader {\n const jiti = createJiti(import.meta.url, JITI_OPTIONS)\n\n return {\n load<T>(filePath: string, options?: LoadModuleOptions) {\n return (options?.default ? jiti.import(filePath, { default: true }) : jiti.import(filePath)) as Promise<T>\n },\n }\n}\n","import { toError } from './errors.ts'\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\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\ntype SerialRunnerOptions = {\n /**\n * The async work to serialize.\n */\n run(): Promise<void>\n /**\n * Receives errors thrown by `run`, so a failure never rejects the returned trigger.\n */\n onError(error: Error): void\n}\n\n/**\n * Wraps `run` so invocations never overlap: a trigger that lands while a run is in flight\n * marks it dirty and runs once more after it finishes, no matter how many triggers arrived.\n * Useful for event-driven reruns (a file watcher, a queue drain) where bursts should\n * coalesce into a single trailing run.\n *\n * @example\n * ```ts\n * const rebuild = createSerialRunner({\n * run: () => build(),\n * onError: (error) => log.error(error.message),\n * })\n * watcher.on('change', () => void rebuild())\n * ```\n */\nexport function createSerialRunner({ run, onError }: SerialRunnerOptions): () => Promise<void> {\n let running = false\n let dirty = false\n\n return async (): Promise<void> => {\n if (running) {\n dirty = true\n return\n }\n running = true\n do {\n dirty = false\n try {\n await run()\n } catch (error) {\n onError(toError(error))\n }\n } while (dirty)\n running = false\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\n return (Array.isArray(resolved) ? resolved[0] : resolved) as Config\n}\n","import { type Config, createKubb, type Diagnostic, Diagnostics, type KubbHooks, AsyncEventEmitter } 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":";;;;;;;;;;;;;;;;;;;;ACIA,MAAa,4CAA4B,IAAI,IAAI;CAAC;CAAO;CAAQ;CAAQ;CAAO;CAAQ;AAAM,CAAC;;;;;AAM/F,MAAa,cAAc;CACzB,MAAM;CACN,SAAS;CACT,OAAO;CACP,MAAM;CACN,YAAY;CACZ,cAAc;CACd,YAAY;CACZ,aAAa;CACb,cAAc;CACd,WAAW;CACX,kBAAkB;CAClB,gBAAgB;CAChB,eAAe;CACf,cAAc;CACd,cAAc;CACd,aAAa;CACb,WAAW;CACX,aAAa;CACb,WAAW;CACX,cAAc;CACd,eAAe;AACjB;;;AC9BA,MAAa,iBAAiB,EAAE,OAAO;CACrC,QAAQ,EAAE,SACR,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,YAAY,iIAAiI,CAAC,CACrL;CACA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,YAAY,sDAAsD,CAAC,CAAC;CAC3H,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,YAAY,0CAA0C,CAAC,CAAC;CAChH,UAAU,EAAE,SACV,EAAE,KAAK,EAAE,SAAS;EAAC;EAAU;EAAQ;CAAS,CAAC,GAAG,EAAE,YAAY,4BAA4B,CAAC,GAC7F,MACF;AACF,CAAC;;;AC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],"sources":["../package.json","../src/constants.ts","../src/schemas/generateSchema.ts","../../../internals/shared/src/constants.ts","../../../internals/shared/src/init.ts","../../../internals/shared/src/loader.ts","../../../internals/utils/src/promise.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 * 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-axios',\n label: 'Axios Client',\n packageName: '@kubb/plugin-axios',\n importName: 'pluginAxios',\n category: 'client',\n },\n {\n value: 'plugin-fetch',\n label: 'Fetch Client',\n packageName: '@kubb/plugin-fetch',\n importName: 'pluginFetch',\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","import 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.map((plugin) => ` ${plugin.importName}(),`).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 { 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\n/**\n * Loads `.ts`/`.js` modules via jiti.\n */\nexport type ModuleLoader = {\n load<T = unknown>(filePath: string, options?: LoadModuleOptions): Promise<T>\n}\n\n/**\n * Creates a jiti-based loader for Kubb's TypeScript and JavaScript config modules.\n *\n * jiti transpiles TypeScript and the `@kubb/renderer-jsx` JSX runtime on the fly.\n *\n * @example\n * ```ts\n * const config = await createModuleLoader().load('/abs/kubb.config.ts', { default: true })\n * ```\n */\nexport function createModuleLoader(): ModuleLoader {\n const jiti = createJiti(import.meta.url, JITI_OPTIONS)\n\n return {\n load<T>(filePath: string, options?: LoadModuleOptions) {\n return (options?.default ? jiti.import(filePath, { default: true }) : jiti.import(filePath)) as Promise<T>\n },\n }\n}\n","import { toError } from './errors.ts'\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\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\ntype SerialRunnerOptions = {\n /**\n * The async work to serialize.\n */\n run(): Promise<void>\n /**\n * Receives errors thrown by `run`, so a failure never rejects the returned trigger.\n */\n onError(error: Error): void\n}\n\n/**\n * Wraps `run` so invocations never overlap: a trigger that lands while a run is in flight\n * marks it dirty and runs once more after it finishes, no matter how many triggers arrived.\n * Useful for event-driven reruns (a file watcher, a queue drain) where bursts should\n * coalesce into a single trailing run.\n *\n * @example\n * ```ts\n * const rebuild = createSerialRunner({\n * run: () => build(),\n * onError: (error) => log.error(error.message),\n * })\n * watcher.on('change', () => void rebuild())\n * ```\n */\nexport function createSerialRunner({ run, onError }: SerialRunnerOptions): () => Promise<void> {\n let running = false\n let dirty = false\n\n return async (): Promise<void> => {\n if (running) {\n dirty = true\n return\n }\n running = true\n do {\n dirty = false\n try {\n await run()\n } catch (error) {\n onError(toError(error))\n }\n } while (dirty)\n running = false\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\n return (Array.isArray(resolved) ? resolved[0] : resolved) as Config\n}\n","import { type Config, createKubb, type Diagnostic, Diagnostics, type KubbHooks, Hookable } 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 Hookable<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.hook('kubb:info', async ({ message }: { message: string }) => {\n await notify(NotifyTypes.INFO, message)\n })\n\n hooks.hook('kubb:success', async ({ message }: { message: string }) => {\n await notify(NotifyTypes.SUCCESS, message)\n })\n\n hooks.hook('kubb:error', async ({ error }: { error: Error }) => {\n await notify(NotifyTypes.ERROR, error.message)\n })\n\n hooks.hook('kubb:warn', async ({ message }: { message: string }) => {\n await notify(NotifyTypes.WARN, message)\n })\n\n hooks.hook('kubb:diagnostic', async ({ diagnostic }: { diagnostic: Diagnostic }) => {\n await notify(NotifyTypes.DIAGNOSTIC, diagnostic.message, Diagnostics.serialize(diagnostic))\n })\n\n hooks.hook('kubb:plugin:start', async ({ plugin }) => {\n await notify(NotifyTypes.PLUGIN_START, `Plugin starting: ${plugin.name}`)\n })\n\n hooks.hook('kubb:plugin:end', async ({ plugin, duration }) => {\n await notify(NotifyTypes.PLUGIN_END, `Plugin finished: ${plugin.name}`, { duration })\n })\n\n hooks.hook('kubb:files:processing:start', async () => {\n await notify(NotifyTypes.FILES_START, 'Starting file processing')\n })\n\n hooks.hook('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.hook('kubb:files:processing:end', async () => {\n await notify(NotifyTypes.FILES_END, 'File processing complete')\n })\n\n hooks.hook('kubb:generation:start', async () => {\n await notify(NotifyTypes.GENERATION_START, 'Generation started')\n })\n\n hooks.hook('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":";;;;;;;;;;;;;;;;;;;;ACIA,MAAa,4CAA4B,IAAI,IAAI;CAAC;CAAO;CAAQ;CAAQ;CAAO;CAAQ;AAAM,CAAC;;;;;AAM/F,MAAa,cAAc;CACzB,MAAM;CACN,SAAS;CACT,OAAO;CACP,MAAM;CACN,YAAY;CACZ,cAAc;CACd,YAAY;CACZ,aAAa;CACb,cAAc;CACd,WAAW;CACX,kBAAkB;CAClB,gBAAgB;CAChB,eAAe;CACf,cAAc;CACd,cAAc;CACd,aAAa;CACb,WAAW;CACX,aAAa;CACb,WAAW;CACX,cAAc;CACd,eAAe;AACjB;;;AC9BA,MAAa,iBAAiB,EAAE,OAAO;CACrC,QAAQ,EAAE,SACR,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,YAAY,iIAAiI,CAAC,CACrL;CACA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,YAAY,sDAAsD,CAAC,CAAC;CAC3H,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,YAAY,0CAA0C,CAAC,CAAC;CAChH,UAAU,EAAE,SACV,EAAE,KAAK,EAAE,SAAS;EAAC;EAAU;EAAQ;CAAS,CAAC,GAAG,EAAE,YAAY,4BAA4B,CAA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json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/mcp",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.87",
|
|
4
4
|
"description": "MCP server for Kubb. Exposes code generation as a tool over the Model Context Protocol so AI assistants like Claude, Cursor, and other MCP-compatible clients can generate TypeScript types, clients, and more.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -51,16 +51,16 @@
|
|
|
51
51
|
"jiti": "^2.7.0",
|
|
52
52
|
"tmcp": "^1.19.4",
|
|
53
53
|
"valibot": "^1.4.2",
|
|
54
|
-
"@kubb/adapter-oas": "5.0.0-beta.
|
|
55
|
-
"@kubb/core": "5.0.0-beta.
|
|
54
|
+
"@kubb/adapter-oas": "5.0.0-beta.87",
|
|
55
|
+
"@kubb/core": "5.0.0-beta.87"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@internals/shared": "0.0.0",
|
|
59
|
-
"@kubb/renderer-jsx": "5.0.0-beta.
|
|
59
|
+
"@kubb/renderer-jsx": "5.0.0-beta.87",
|
|
60
60
|
"@internals/utils": "0.0.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@kubb/renderer-jsx": "5.0.0-beta.
|
|
63
|
+
"@kubb/renderer-jsx": "5.0.0-beta.87"
|
|
64
64
|
},
|
|
65
65
|
"engines": {
|
|
66
66
|
"node": ">=22"
|