@kubb/plugin-mcp 4.11.0 → 4.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { a as OperationSchemas } from "./index-LobIH03Q.cjs";
1
+ import { a as OperationSchemas } from "./index-CXth3-Jh.cjs";
2
2
  import { KubbFile } from "@kubb/fabric-core/types";
3
3
  import { KubbNode } from "@kubb/react-fabric/types";
4
4
 
@@ -1,4 +1,4 @@
1
- import { a as OperationSchemas } from "./index-DI8TPGrZ.js";
1
+ import { a as OperationSchemas } from "./index-CS2SZYLV.js";
2
2
  import { KubbFile } from "@kubb/fabric-core/types";
3
3
  import { KubbNode } from "@kubb/react-fabric/types";
4
4
 
@@ -1,5 +1,5 @@
1
- import { n as ReactGenerator } from "./index-LobIH03Q.cjs";
2
- import { n as PluginMcp } from "./types-rbWW4ifO.cjs";
1
+ import { n as ReactGenerator } from "./index-CXth3-Jh.cjs";
2
+ import { n as PluginMcp } from "./types-ut1IL45-.cjs";
3
3
 
4
4
  //#region src/generators/mcpGenerator.d.ts
5
5
  declare const mcpGenerator: ReactGenerator<PluginMcp>;
@@ -1,5 +1,5 @@
1
- import { n as ReactGenerator } from "./index-DI8TPGrZ.js";
2
- import { n as PluginMcp } from "./types-Du4Y2uo8.js";
1
+ import { n as ReactGenerator } from "./index-CS2SZYLV.js";
2
+ import { n as PluginMcp } from "./types-CeCRegVI.js";
3
3
 
4
4
  //#region src/generators/mcpGenerator.d.ts
5
5
  declare const mcpGenerator: ReactGenerator<PluginMcp>;
@@ -38,13 +38,35 @@ type DebugEvent = {
38
38
  date: Date;
39
39
  logs: string[];
40
40
  fileName?: string;
41
+ /**
42
+ * Category of the debug log, used for GitHub Actions grouping
43
+ * - 'setup': Initial configuration and environment setup
44
+ * - 'plugin': Plugin installation and execution
45
+ * - 'hook': Plugin hook execution details
46
+ * - 'schema': Schema parsing and generation
47
+ * - 'file': File operations (read/write/generate)
48
+ * - 'error': Error details and stack traces
49
+ * - undefined: Generic logs (always inline)
50
+ */
51
+ category?: 'setup' | 'plugin' | 'hook' | 'schema' | 'file' | 'error';
52
+ /**
53
+ * Plugin name for grouping plugin-specific logs together
54
+ */
55
+ pluginName?: string;
56
+ /**
57
+ * Indicates if this is the start or end of a plugin's execution
58
+ * - 'start': Start of plugin execution group
59
+ * - 'end': End of plugin execution group
60
+ */
61
+ pluginGroupMarker?: 'start' | 'end';
41
62
  };
42
63
  type Events$1 = {
43
64
  start: [message: string];
44
65
  success: [message: string];
45
- error: [message: string, cause: Error];
66
+ error: [message: string, error: Error];
46
67
  warning: [message: string];
47
68
  debug: [DebugEvent];
69
+ verbose: [DebugEvent];
48
70
  info: [message: string];
49
71
  progress_start: [{
50
72
  id: string;
@@ -68,7 +90,7 @@ type Logger = {
68
90
  consola?: ConsolaInstance;
69
91
  on: EventEmitter<Events$1>['on'];
70
92
  emit: EventEmitter<Events$1>['emit'];
71
- writeLogs: () => Promise<string[]>;
93
+ writeLogs: () => Promise<void>;
72
94
  };
73
95
  //#endregion
74
96
  //#region ../core/src/utils/types.d.ts
@@ -379,14 +401,35 @@ type Group = {
379
401
  //#region ../core/src/PluginManager.d.ts
380
402
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
381
403
  type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
382
- type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
383
- message: string;
404
+ type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
384
405
  strategy: Strategy;
385
406
  hookName: H;
386
407
  plugin: Plugin;
387
408
  parameters?: unknown[] | undefined;
388
409
  output?: unknown;
389
410
  };
411
+ type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
412
+ duration: number;
413
+ strategy: Strategy;
414
+ hookName: H;
415
+ plugin: Plugin;
416
+ parameters?: unknown[] | undefined;
417
+ output?: unknown;
418
+ };
419
+ type ErrorMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
420
+ hookName: H;
421
+ duration: number;
422
+ strategy: Strategy;
423
+ parameters?: unknown[] | undefined;
424
+ plugin: Plugin;
425
+ };
426
+ type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
427
+ hookName: H;
428
+ plugins: Array<Plugin>;
429
+ };
430
+ type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
431
+ hookName: H;
432
+ };
390
433
  type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
391
434
  type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
392
435
  result: Result;
@@ -401,9 +444,11 @@ type Options$1 = {
401
444
  concurrency?: number;
402
445
  };
403
446
  type Events = {
404
- executing: [executer: Executer];
405
- executed: [executer: Executer];
406
- error: [error: Error];
447
+ progress_start: [meta: ProgressStartMeta];
448
+ progress_stop: [meta: ProgressStopMeta];
449
+ executing: [meta: ExecutingMeta];
450
+ executed: [meta: ExecutedMeta];
451
+ error: [error: Error, meta: ErrorMeta];
407
452
  };
408
453
  type GetFileProps<TOptions = object> = {
409
454
  name: string;
@@ -416,8 +461,6 @@ declare class PluginManager {
416
461
  #private;
417
462
  readonly events: EventEmitter<Events>;
418
463
  readonly config: Config;
419
- readonly executed: Array<Executer>;
420
- readonly logger: Logger;
421
464
  readonly options: Options$1;
422
465
  constructor(config: Config, options: Options$1);
423
466
  getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
@@ -443,13 +486,11 @@ declare class PluginManager {
443
486
  hookForPlugin<H extends PluginLifecycleHooks>({
444
487
  pluginKey,
445
488
  hookName,
446
- parameters,
447
- message
489
+ parameters
448
490
  }: {
449
491
  pluginKey: Plugin['key'];
450
492
  hookName: H;
451
493
  parameters: PluginParameter<H>;
452
- message: string;
453
494
  }): Promise<Array<ReturnType<ParseResult<H>> | null>>;
454
495
  /**
455
496
  * Run a specific hookName for plugin x.
@@ -457,13 +498,11 @@ declare class PluginManager {
457
498
  hookForPluginSync<H extends PluginLifecycleHooks>({
458
499
  pluginKey,
459
500
  hookName,
460
- parameters,
461
- message
501
+ parameters
462
502
  }: {
463
503
  pluginKey: Plugin['key'];
464
504
  hookName: H;
465
505
  parameters: PluginParameter<H>;
466
- message: string;
467
506
  }): Array<ReturnType<ParseResult<H>>> | null;
468
507
  /**
469
508
  * First non-null result stops and will return it's value.
@@ -471,13 +510,11 @@ declare class PluginManager {
471
510
  hookFirst<H extends PluginLifecycleHooks>({
472
511
  hookName,
473
512
  parameters,
474
- skipped,
475
- message
513
+ skipped
476
514
  }: {
477
515
  hookName: H;
478
516
  parameters: PluginParameter<H>;
479
517
  skipped?: ReadonlySet<Plugin> | null;
480
- message: string;
481
518
  }): Promise<SafeParseResult<H>>;
482
519
  /**
483
520
  * First non-null result stops and will return it's value.
@@ -485,37 +522,31 @@ declare class PluginManager {
485
522
  hookFirstSync<H extends PluginLifecycleHooks>({
486
523
  hookName,
487
524
  parameters,
488
- skipped,
489
- message
525
+ skipped
490
526
  }: {
491
527
  hookName: H;
492
528
  parameters: PluginParameter<H>;
493
529
  skipped?: ReadonlySet<Plugin> | null;
494
- message: string;
495
530
  }): SafeParseResult<H>;
496
531
  /**
497
532
  * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
498
533
  */
499
534
  hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
500
535
  hookName,
501
- parameters,
502
- message
536
+ parameters
503
537
  }: {
504
538
  hookName: H;
505
539
  parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
506
- message: string;
507
540
  }): Promise<Awaited<TOuput>[]>;
508
541
  /**
509
542
  * Chains plugins
510
543
  */
511
544
  hookSeq<H extends PluginLifecycleHooks>({
512
545
  hookName,
513
- parameters,
514
- message
546
+ parameters
515
547
  }: {
516
548
  hookName: H;
517
549
  parameters?: PluginParameter<H>;
518
- message: string;
519
550
  }): Promise<void>;
520
551
  getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
521
552
  getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
@@ -667,6 +698,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
667
698
  override: Array<Override<TOptions>> | undefined;
668
699
  contentType: contentType | undefined;
669
700
  pluginManager: PluginManager;
701
+ logger?: Logger;
670
702
  /**
671
703
  * Current plugin
672
704
  */
@@ -910,6 +942,7 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
910
942
  fabric: Fabric;
911
943
  oas: Oas;
912
944
  pluginManager: PluginManager;
945
+ logger?: Logger;
913
946
  /**
914
947
  * Current plugin
915
948
  */
@@ -1006,4 +1039,4 @@ type CoreGenerator<TOptions extends PluginFactoryOptions> = {
1006
1039
  };
1007
1040
  //#endregion
1008
1041
  export { OperationSchemas as a, Oas as c, Output as d, PluginFactoryOptions as f, Include as i, contentType as l, UserPluginWithLifeCycle as m, ReactGenerator as n, Override as o, ResolveNameParams as p, Exclude$1 as r, ResolvePathOptions as s, Generator as t, Group as u };
1009
- //# sourceMappingURL=index-DI8TPGrZ.d.ts.map
1042
+ //# sourceMappingURL=index-CS2SZYLV.d.ts.map
@@ -38,13 +38,35 @@ type DebugEvent = {
38
38
  date: Date;
39
39
  logs: string[];
40
40
  fileName?: string;
41
+ /**
42
+ * Category of the debug log, used for GitHub Actions grouping
43
+ * - 'setup': Initial configuration and environment setup
44
+ * - 'plugin': Plugin installation and execution
45
+ * - 'hook': Plugin hook execution details
46
+ * - 'schema': Schema parsing and generation
47
+ * - 'file': File operations (read/write/generate)
48
+ * - 'error': Error details and stack traces
49
+ * - undefined: Generic logs (always inline)
50
+ */
51
+ category?: 'setup' | 'plugin' | 'hook' | 'schema' | 'file' | 'error';
52
+ /**
53
+ * Plugin name for grouping plugin-specific logs together
54
+ */
55
+ pluginName?: string;
56
+ /**
57
+ * Indicates if this is the start or end of a plugin's execution
58
+ * - 'start': Start of plugin execution group
59
+ * - 'end': End of plugin execution group
60
+ */
61
+ pluginGroupMarker?: 'start' | 'end';
41
62
  };
42
63
  type Events$1 = {
43
64
  start: [message: string];
44
65
  success: [message: string];
45
- error: [message: string, cause: Error];
66
+ error: [message: string, error: Error];
46
67
  warning: [message: string];
47
68
  debug: [DebugEvent];
69
+ verbose: [DebugEvent];
48
70
  info: [message: string];
49
71
  progress_start: [{
50
72
  id: string;
@@ -68,7 +90,7 @@ type Logger = {
68
90
  consola?: ConsolaInstance;
69
91
  on: EventEmitter<Events$1>['on'];
70
92
  emit: EventEmitter<Events$1>['emit'];
71
- writeLogs: () => Promise<string[]>;
93
+ writeLogs: () => Promise<void>;
72
94
  };
73
95
  //#endregion
74
96
  //#region ../core/src/utils/types.d.ts
@@ -379,14 +401,35 @@ type Group = {
379
401
  //#region ../core/src/PluginManager.d.ts
380
402
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
381
403
  type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
382
- type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
383
- message: string;
404
+ type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
384
405
  strategy: Strategy;
385
406
  hookName: H;
386
407
  plugin: Plugin;
387
408
  parameters?: unknown[] | undefined;
388
409
  output?: unknown;
389
410
  };
411
+ type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
412
+ duration: number;
413
+ strategy: Strategy;
414
+ hookName: H;
415
+ plugin: Plugin;
416
+ parameters?: unknown[] | undefined;
417
+ output?: unknown;
418
+ };
419
+ type ErrorMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
420
+ hookName: H;
421
+ duration: number;
422
+ strategy: Strategy;
423
+ parameters?: unknown[] | undefined;
424
+ plugin: Plugin;
425
+ };
426
+ type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
427
+ hookName: H;
428
+ plugins: Array<Plugin>;
429
+ };
430
+ type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
431
+ hookName: H;
432
+ };
390
433
  type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
391
434
  type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
392
435
  result: Result;
@@ -401,9 +444,11 @@ type Options$1 = {
401
444
  concurrency?: number;
402
445
  };
403
446
  type Events = {
404
- executing: [executer: Executer];
405
- executed: [executer: Executer];
406
- error: [error: Error];
447
+ progress_start: [meta: ProgressStartMeta];
448
+ progress_stop: [meta: ProgressStopMeta];
449
+ executing: [meta: ExecutingMeta];
450
+ executed: [meta: ExecutedMeta];
451
+ error: [error: Error, meta: ErrorMeta];
407
452
  };
408
453
  type GetFileProps<TOptions = object> = {
409
454
  name: string;
@@ -416,8 +461,6 @@ declare class PluginManager {
416
461
  #private;
417
462
  readonly events: EventEmitter<Events>;
418
463
  readonly config: Config;
419
- readonly executed: Array<Executer>;
420
- readonly logger: Logger;
421
464
  readonly options: Options$1;
422
465
  constructor(config: Config, options: Options$1);
423
466
  getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
@@ -443,13 +486,11 @@ declare class PluginManager {
443
486
  hookForPlugin<H extends PluginLifecycleHooks>({
444
487
  pluginKey,
445
488
  hookName,
446
- parameters,
447
- message
489
+ parameters
448
490
  }: {
449
491
  pluginKey: Plugin['key'];
450
492
  hookName: H;
451
493
  parameters: PluginParameter<H>;
452
- message: string;
453
494
  }): Promise<Array<ReturnType<ParseResult<H>> | null>>;
454
495
  /**
455
496
  * Run a specific hookName for plugin x.
@@ -457,13 +498,11 @@ declare class PluginManager {
457
498
  hookForPluginSync<H extends PluginLifecycleHooks>({
458
499
  pluginKey,
459
500
  hookName,
460
- parameters,
461
- message
501
+ parameters
462
502
  }: {
463
503
  pluginKey: Plugin['key'];
464
504
  hookName: H;
465
505
  parameters: PluginParameter<H>;
466
- message: string;
467
506
  }): Array<ReturnType<ParseResult<H>>> | null;
468
507
  /**
469
508
  * First non-null result stops and will return it's value.
@@ -471,13 +510,11 @@ declare class PluginManager {
471
510
  hookFirst<H extends PluginLifecycleHooks>({
472
511
  hookName,
473
512
  parameters,
474
- skipped,
475
- message
513
+ skipped
476
514
  }: {
477
515
  hookName: H;
478
516
  parameters: PluginParameter<H>;
479
517
  skipped?: ReadonlySet<Plugin> | null;
480
- message: string;
481
518
  }): Promise<SafeParseResult<H>>;
482
519
  /**
483
520
  * First non-null result stops and will return it's value.
@@ -485,37 +522,31 @@ declare class PluginManager {
485
522
  hookFirstSync<H extends PluginLifecycleHooks>({
486
523
  hookName,
487
524
  parameters,
488
- skipped,
489
- message
525
+ skipped
490
526
  }: {
491
527
  hookName: H;
492
528
  parameters: PluginParameter<H>;
493
529
  skipped?: ReadonlySet<Plugin> | null;
494
- message: string;
495
530
  }): SafeParseResult<H>;
496
531
  /**
497
532
  * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
498
533
  */
499
534
  hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
500
535
  hookName,
501
- parameters,
502
- message
536
+ parameters
503
537
  }: {
504
538
  hookName: H;
505
539
  parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
506
- message: string;
507
540
  }): Promise<Awaited<TOuput>[]>;
508
541
  /**
509
542
  * Chains plugins
510
543
  */
511
544
  hookSeq<H extends PluginLifecycleHooks>({
512
545
  hookName,
513
- parameters,
514
- message
546
+ parameters
515
547
  }: {
516
548
  hookName: H;
517
549
  parameters?: PluginParameter<H>;
518
- message: string;
519
550
  }): Promise<void>;
520
551
  getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
521
552
  getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
@@ -667,6 +698,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
667
698
  override: Array<Override<TOptions>> | undefined;
668
699
  contentType: contentType | undefined;
669
700
  pluginManager: PluginManager;
701
+ logger?: Logger;
670
702
  /**
671
703
  * Current plugin
672
704
  */
@@ -910,6 +942,7 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
910
942
  fabric: Fabric;
911
943
  oas: Oas;
912
944
  pluginManager: PluginManager;
945
+ logger?: Logger;
913
946
  /**
914
947
  * Current plugin
915
948
  */
@@ -1006,4 +1039,4 @@ type CoreGenerator<TOptions extends PluginFactoryOptions> = {
1006
1039
  };
1007
1040
  //#endregion
1008
1041
  export { OperationSchemas as a, Oas as c, Output as d, PluginFactoryOptions as f, Include as i, contentType as l, UserPluginWithLifeCycle as m, ReactGenerator as n, Override as o, ResolveNameParams as p, Exclude$1 as r, ResolvePathOptions as s, Generator as t, Group as u };
1009
- //# sourceMappingURL=index-LobIH03Q.d.cts.map
1042
+ //# sourceMappingURL=index-CXth3-Jh.d.cts.map
package/dist/index.cjs CHANGED
@@ -89,6 +89,7 @@ const pluginMcp = (0, __kubb_core.definePlugin)((options) => {
89
89
  fabric: this.fabric,
90
90
  oas,
91
91
  pluginManager: this.pluginManager,
92
+ logger: this.logger,
92
93
  plugin: this.plugin,
93
94
  contentType,
94
95
  exclude,
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["mcpGenerator","serverGenerator","pluginOasName","pluginTsName","pluginZodName","path","options","groupName: Group['name']","pluginClientName","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { mcpGenerator, serverGenerator } from './generators'\nimport type { PluginMcp } from './types.ts'\n\nexport const pluginMcpName = 'plugin-mcp' satisfies PluginMcp['name']\n\nexport const pluginMcp = definePlugin<PluginMcp>((options) => {\n const {\n output = { path: 'mcp', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n generators = [mcpGenerator, serverGenerator].filter(Boolean),\n contentType,\n client,\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n return {\n name: pluginMcpName,\n options: {\n output,\n group,\n client: {\n client: clientName,\n clientType: client?.clientType ?? 'function',\n importPath: clientImportPath,\n dataReturnType: 'data',\n ...options.client,\n },\n },\n pre: [pluginOasName, pluginTsName, pluginZodName].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Requests`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.pluginManager.getPluginByKey([pluginClientName])\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled fetch\n await this.addFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: resolveModuleSource(\n this.plugin.options.client.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',\n ).source,\n isExportable: true,\n isIndexable: true,\n },\n ],\n })\n }\n\n if (!hasClientPlugin) {\n await this.addFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: resolveModuleSource('@kubb/plugin-client/templates/config').source,\n isExportable: false,\n isIndexable: false,\n },\n ],\n })\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,gBAAgB;AAE7B,MAAa,2CAAqC,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAO,YAAY;EAAS,EAC7C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,aAAa,CAACA,iCAAcC,mCAAgB,CAAC,OAAO,QAAQ,EAC5D,aACA,WACE;CAEJ,MAAM,aAAa,QAAQ,UAAU;CACrC,MAAM,mBAAmB,QAAQ,eAAe,CAAC,QAAQ,SAAS,+BAA+B,eAAe;AAEhH,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA,QAAQ;IACN,QAAQ;IACR,YAAY,QAAQ,cAAc;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B,CAAC;AAE/E,OAAI,KAAK,OAAO,QAAQ,OAAO,UAAU,CAAC,mBAAmB,CAAC,KAAK,OAAO,QAAQ,OAAO,WAEvF,OAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAMH,kBAAK,QAAQ,MAAM,iBAAiB;IAC1C,SAAS,CACP;KACE,MAAM;KACN,kDACE,KAAK,OAAO,QAAQ,OAAO,WAAW,UAAU,gDAAgD,8CACjG,CAAC;KACF,cAAc;KACd,aAAa;KACd,CACF;IACF,CAAC;AAGJ,OAAI,CAAC,gBACH,OAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAMA,kBAAK,QAAQ,MAAM,kBAAkB;IAC3C,SAAS,CACP;KACE,MAAM;KACN,kDAA2B,uCAAuC,CAAC;KACnE,cAAc;KACd,aAAa;KACd,CACF;IACF,CAAC;GAeJ,MAAM,QAAQ,MAZa,IAAII,qCAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,WAAW,GAAG,MAAM;GAE/B,MAAM,cAAc,sCAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
1
+ {"version":3,"file":"index.cjs","names":["mcpGenerator","serverGenerator","pluginOasName","pluginTsName","pluginZodName","path","options","groupName: Group['name']","pluginClientName","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { mcpGenerator, serverGenerator } from './generators'\nimport type { PluginMcp } from './types.ts'\n\nexport const pluginMcpName = 'plugin-mcp' satisfies PluginMcp['name']\n\nexport const pluginMcp = definePlugin<PluginMcp>((options) => {\n const {\n output = { path: 'mcp', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n generators = [mcpGenerator, serverGenerator].filter(Boolean),\n contentType,\n client,\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n return {\n name: pluginMcpName,\n options: {\n output,\n group,\n client: {\n client: clientName,\n clientType: client?.clientType ?? 'function',\n importPath: clientImportPath,\n dataReturnType: 'data',\n ...options.client,\n },\n },\n pre: [pluginOasName, pluginTsName, pluginZodName].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Requests`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.pluginManager.getPluginByKey([pluginClientName])\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled fetch\n await this.addFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: resolveModuleSource(\n this.plugin.options.client.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',\n ).source,\n isExportable: true,\n isIndexable: true,\n },\n ],\n })\n }\n\n if (!hasClientPlugin) {\n await this.addFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: resolveModuleSource('@kubb/plugin-client/templates/config').source,\n isExportable: false,\n isIndexable: false,\n },\n ],\n })\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n logger: this.logger,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,gBAAgB;AAE7B,MAAa,2CAAqC,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAO,YAAY;EAAS,EAC7C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,aAAa,CAACA,iCAAcC,mCAAgB,CAAC,OAAO,QAAQ,EAC5D,aACA,WACE;CAEJ,MAAM,aAAa,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as Options } from "./types-rbWW4ifO.cjs";
1
+ import { m as UserPluginWithLifeCycle } from "./index-CXth3-Jh.cjs";
2
+ import { n as PluginMcp, t as Options } from "./types-ut1IL45-.cjs";
3
3
 
4
4
  //#region src/plugin.d.ts
5
5
  declare const pluginMcpName = "plugin-mcp";
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { m as UserPluginWithLifeCycle } from "./index-DI8TPGrZ.js";
2
- import { n as PluginMcp, t as Options } from "./types-Du4Y2uo8.js";
1
+ import { m as UserPluginWithLifeCycle } from "./index-CS2SZYLV.js";
2
+ import { n as PluginMcp, t as Options } from "./types-CeCRegVI.js";
3
3
 
4
4
  //#region src/plugin.d.ts
5
5
  declare const pluginMcpName = "plugin-mcp";
package/dist/index.js CHANGED
@@ -88,6 +88,7 @@ const pluginMcp = definePlugin((options) => {
88
88
  fabric: this.fabric,
89
89
  oas,
90
90
  pluginManager: this.pluginManager,
91
+ logger: this.logger,
91
92
  plugin: this.plugin,
92
93
  contentType,
93
94
  exclude,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { mcpGenerator, serverGenerator } from './generators'\nimport type { PluginMcp } from './types.ts'\n\nexport const pluginMcpName = 'plugin-mcp' satisfies PluginMcp['name']\n\nexport const pluginMcp = definePlugin<PluginMcp>((options) => {\n const {\n output = { path: 'mcp', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n generators = [mcpGenerator, serverGenerator].filter(Boolean),\n contentType,\n client,\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n return {\n name: pluginMcpName,\n options: {\n output,\n group,\n client: {\n client: clientName,\n clientType: client?.clientType ?? 'function',\n importPath: clientImportPath,\n dataReturnType: 'data',\n ...options.client,\n },\n },\n pre: [pluginOasName, pluginTsName, pluginZodName].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Requests`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.pluginManager.getPluginByKey([pluginClientName])\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled fetch\n await this.addFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: resolveModuleSource(\n this.plugin.options.client.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',\n ).source,\n isExportable: true,\n isIndexable: true,\n },\n ],\n })\n }\n\n if (!hasClientPlugin) {\n await this.addFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: resolveModuleSource('@kubb/plugin-client/templates/config').source,\n isExportable: false,\n isIndexable: false,\n },\n ],\n })\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,gBAAgB;AAE7B,MAAa,YAAY,cAAyB,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAO,YAAY;EAAS,EAC7C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,aAAa,CAAC,cAAc,gBAAgB,CAAC,OAAO,QAAQ,EAC5D,aACA,WACE;CAEJ,MAAM,aAAa,QAAQ,UAAU;CACrC,MAAM,mBAAmB,QAAQ,eAAe,CAAC,QAAQ,SAAS,+BAA+B,eAAe;AAEhH,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA,QAAQ;IACN,QAAQ;IACR,YAAY,QAAQ,cAAc;IAClC,YAAY;IACZ,gBAAgB;IAChB,GAAG,QAAQ;IACZ;GACF;EACD,KAAK;GAAC;GAAe;GAAc;GAAc,CAAC,OAAO,QAAQ;EACjE,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAO,KAAK,QAA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BAAiB;IAC1C,SAAS,CACP;KACE,MAAM;KACN,OAAO,oBACL,KAAK,OAAO,QAAQ,OAAO,WAAW,UAAU,gDAAgD,8CACjG,CAAC;KACF,cAAc;KACd,aAAa;KACd,CACF;IACF,CAAC;AAGJ,OAAI,CAAC,gBACH,OAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAM,KAAK,QAAQ,MAAM,kBAAkB;IAC3C,SAAS,CACP;KACE,MAAM;KACN,OAAO,oBAAoB,uCAAuC,CAAC;KACnE,cAAc;KACd,aAAa;KACd,CACF;IACF,CAAC;GAeJ,MAAM,QAAQ,MAZa,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,WAAW,GAAG,MAAM;GAE/B,MAAM,cAAc,MAAM,eAAe,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
1
+ {"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { mcpGenerator, serverGenerator } from './generators'\nimport type { PluginMcp } from './types.ts'\n\nexport const pluginMcpName = 'plugin-mcp' satisfies PluginMcp['name']\n\nexport const pluginMcp = definePlugin<PluginMcp>((options) => {\n const {\n output = { path: 'mcp', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n generators = [mcpGenerator, serverGenerator].filter(Boolean),\n contentType,\n client,\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n return {\n name: pluginMcpName,\n options: {\n output,\n group,\n client: {\n client: clientName,\n clientType: client?.clientType ?? 'function',\n importPath: clientImportPath,\n dataReturnType: 'data',\n ...options.client,\n },\n },\n pre: [pluginOasName, pluginTsName, pluginZodName].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Requests`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.pluginManager.getPluginByKey([pluginClientName])\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled fetch\n await this.addFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: resolveModuleSource(\n this.plugin.options.client.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',\n ).source,\n isExportable: true,\n isIndexable: true,\n },\n ],\n })\n }\n\n if (!hasClientPlugin) {\n await this.addFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: resolveModuleSource('@kubb/plugin-client/templates/config').source,\n isExportable: false,\n isIndexable: false,\n },\n ],\n })\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n logger: this.logger,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,gBAAgB;AAE7B,MAAa,YAAY,cAAyB,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAO,YAAY;EAAS,EAC7C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,aAAa,CAAC,cAAc,gBAAgB,CAAC,OAAO,QAAQ,EAC5D,aACA,WACE;CAEJ,MAAM,aAAa,QAAQ,UAAU;CACrC,MAAM,mBAAmB,QAAQ,eAAe,CAAC,QAAQ,SAAS,+BAA+B,eAAe;AAEhH,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA,QAAQ;IACN,QAAQ;IACR,YAAY,QAAQ,cAAc;IAClC,YAAY;IACZ,gBAAgB;IAChB,GAAG,QAAQ;IACZ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AU,CAAC,mBAAmB,CAAC,KAAK,OAAO,QAAQ,OAAO,WAEvF,OAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAM,KAAK,QAAQ,MAAM,iBAAiB;IAC1C,SAAS,CACP;KACE,MAAM;KACN,OAAO,oBACL,KAAK,OAAO,QAAQ,OAAO,WAAW,UAAU,gDAAgD,8CACjG,CAAC;KACF,cAAc;KACd,aAAa;KACd,CACF;IACF,CAAC;AAGJ,OAAI,CAAC,gBACH,OAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAM,KAAK,QAAQ,MAAM,kBAAkB;IAC3C,SAAS,CACP;KACE,MAAM;KACN,OAAO,oBAAoB,uCAAuC,CAAC;KACnE,cAAc;KACd,aAAa;KACd,CACF;IACF,CAAC;GAgBJ,MAAM,QAAQ,MAba,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,WAAW,GAAG,MAAM;GAE/B,MAAM,cAAc,MAAM,eAAe,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
@@ -1,4 +1,4 @@
1
- import { c as Oas, d as Output, f as PluginFactoryOptions, i as Include, l as contentType, o as Override, p as ResolveNameParams, r as Exclude, s as ResolvePathOptions, t as Generator, u as Group } from "./index-DI8TPGrZ.js";
1
+ import { c as Oas, d as Output, f as PluginFactoryOptions, i as Include, l as contentType, o as Override, p as ResolveNameParams, r as Exclude, s as ResolvePathOptions, t as Generator, u as Group } from "./index-CS2SZYLV.js";
2
2
 
3
3
  //#region ../plugin-client/src/types.d.ts
4
4
 
@@ -180,4 +180,4 @@ type ResolvedOptions = {
180
180
  type PluginMcp = PluginFactoryOptions<'plugin-mcp', Options, ResolvedOptions, never, ResolvePathOptions>;
181
181
  //#endregion
182
182
  export { PluginMcp as n, Options as t };
183
- //# sourceMappingURL=types-Du4Y2uo8.d.ts.map
183
+ //# sourceMappingURL=types-CeCRegVI.d.ts.map
@@ -1,4 +1,4 @@
1
- import { c as Oas, d as Output, f as PluginFactoryOptions, i as Include, l as contentType, o as Override, p as ResolveNameParams, r as Exclude, s as ResolvePathOptions, t as Generator, u as Group } from "./index-LobIH03Q.cjs";
1
+ import { c as Oas, d as Output, f as PluginFactoryOptions, i as Include, l as contentType, o as Override, p as ResolveNameParams, r as Exclude, s as ResolvePathOptions, t as Generator, u as Group } from "./index-CXth3-Jh.cjs";
2
2
 
3
3
  //#region ../plugin-client/src/types.d.ts
4
4
 
@@ -180,4 +180,4 @@ type ResolvedOptions = {
180
180
  type PluginMcp = PluginFactoryOptions<'plugin-mcp', Options, ResolvedOptions, never, ResolvePathOptions>;
181
181
  //#endregion
182
182
  export { PluginMcp as n, Options as t };
183
- //# sourceMappingURL=types-rbWW4ifO.d.cts.map
183
+ //# sourceMappingURL=types-ut1IL45-.d.cts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-mcp",
3
- "version": "4.11.0",
3
+ "version": "4.11.2",
4
4
  "description": "Generator mcp",
5
5
  "keywords": [
6
6
  "typescript",
@@ -70,12 +70,12 @@
70
70
  ],
71
71
  "dependencies": {
72
72
  "@kubb/react-fabric": "0.5.4",
73
- "@kubb/core": "4.11.0",
74
- "@kubb/oas": "4.11.0",
75
- "@kubb/plugin-client": "4.11.0",
76
- "@kubb/plugin-oas": "4.11.0",
77
- "@kubb/plugin-ts": "4.11.0",
78
- "@kubb/plugin-zod": "4.11.0"
73
+ "@kubb/core": "4.11.2",
74
+ "@kubb/oas": "4.11.2",
75
+ "@kubb/plugin-client": "4.11.2",
76
+ "@kubb/plugin-oas": "4.11.2",
77
+ "@kubb/plugin-ts": "4.11.2",
78
+ "@kubb/plugin-zod": "4.11.2"
79
79
  },
80
80
  "devDependencies": {},
81
81
  "engines": {
package/src/plugin.ts CHANGED
@@ -135,6 +135,7 @@ export const pluginMcp = definePlugin<PluginMcp>((options) => {
135
135
  fabric: this.fabric,
136
136
  oas,
137
137
  pluginManager: this.pluginManager,
138
+ logger: this.logger,
138
139
  plugin: this.plugin,
139
140
  contentType,
140
141
  exclude,