@kubb/plugin-mcp 4.2.0 → 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{OperationGenerator-4XcPTEmW.d.ts → OperationGenerator-c8MWYsSI.d.ts} +13 -57
- package/dist/{OperationGenerator-BEQNw2o0.d.cts → OperationGenerator-unRLjMpQ.d.cts} +13 -57
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/{generators-CPxZOD9U.cjs → generators-naBCKi9F.cjs} +3 -3
- package/dist/{generators-CPxZOD9U.cjs.map → generators-naBCKi9F.cjs.map} +1 -1
- package/dist/{generators-Cvzin4vm.js → generators-zuKj-GtG.js} +2 -2
- package/dist/{generators-Cvzin4vm.js.map → generators-zuKj-GtG.js.map} +1 -1
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.cts +2 -2
- package/dist/generators.d.ts +2 -2
- package/dist/generators.js +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/{types-D1ZAplJE.d.ts → types-7AZo3Q-6.d.ts} +2 -2
- package/dist/{types-xkoLaTAL.d.cts → types-DI32TxX9.d.cts} +2 -2
- package/package.json +8 -8
- package/src/plugin.ts +6 -9
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
2
|
+
import { FileManager } from "@kubb/fabric-core";
|
|
2
3
|
import * as OasTypes from "oas/types";
|
|
3
4
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
4
5
|
import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
@@ -185,8 +186,6 @@ type Logger = {
|
|
|
185
186
|
//#endregion
|
|
186
187
|
//#region ../core/src/utils/types.d.ts
|
|
187
188
|
type PossiblePromise<T$1> = Promise<T$1> | T$1;
|
|
188
|
-
type ArrayWithLength<T$1 extends number, U extends any[] = []> = U['length'] extends T$1 ? U : ArrayWithLength<T$1, [true, ...U]>;
|
|
189
|
-
type GreaterThan<T$1 extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T$1>, ...infer _] ? false : true;
|
|
190
189
|
//#endregion
|
|
191
190
|
//#region ../core/src/types.d.ts
|
|
192
191
|
type InputPath = {
|
|
@@ -429,6 +428,9 @@ type ResolveNameParams = {
|
|
|
429
428
|
};
|
|
430
429
|
type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
431
430
|
config: Config;
|
|
431
|
+
/**
|
|
432
|
+
* @deprecated
|
|
433
|
+
*/
|
|
432
434
|
fileManager: FileManager;
|
|
433
435
|
pluginManager: PluginManager;
|
|
434
436
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
@@ -480,60 +482,6 @@ type Group = {
|
|
|
480
482
|
name?: (context: GroupContext) => string;
|
|
481
483
|
};
|
|
482
484
|
//#endregion
|
|
483
|
-
//#region ../core/src/FileManager.d.ts
|
|
484
|
-
type FileMetaBase = {
|
|
485
|
-
pluginKey?: Plugin['key'];
|
|
486
|
-
};
|
|
487
|
-
type AddResult<T$1 extends Array<File>> = Promise<Awaited<GreaterThan<T$1['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
488
|
-
type AddIndexesProps = {
|
|
489
|
-
type: BarrelType | false | undefined;
|
|
490
|
-
/**
|
|
491
|
-
* Root based on root and output.path specified in the config
|
|
492
|
-
*/
|
|
493
|
-
root: string;
|
|
494
|
-
/**
|
|
495
|
-
* Output for plugin
|
|
496
|
-
*/
|
|
497
|
-
output: {
|
|
498
|
-
path: string;
|
|
499
|
-
};
|
|
500
|
-
group?: {
|
|
501
|
-
output: string;
|
|
502
|
-
exportAs: string;
|
|
503
|
-
};
|
|
504
|
-
logger?: Logger;
|
|
505
|
-
meta?: FileMetaBase;
|
|
506
|
-
};
|
|
507
|
-
type WriteFilesProps = {
|
|
508
|
-
root: Config['root'];
|
|
509
|
-
extension?: Record<Extname, Extname | ''>;
|
|
510
|
-
logger?: Logger;
|
|
511
|
-
dryRun?: boolean;
|
|
512
|
-
};
|
|
513
|
-
declare class FileManager {
|
|
514
|
-
#private;
|
|
515
|
-
constructor();
|
|
516
|
-
add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
|
|
517
|
-
getByPath(path: Path): Promise<ResolvedFile | null>;
|
|
518
|
-
deleteByPath(path: Path): Promise<void>;
|
|
519
|
-
clear(): Promise<void>;
|
|
520
|
-
getFiles(): Promise<Array<ResolvedFile>>;
|
|
521
|
-
processFiles({
|
|
522
|
-
dryRun,
|
|
523
|
-
root,
|
|
524
|
-
extension,
|
|
525
|
-
logger
|
|
526
|
-
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
527
|
-
getBarrelFiles({
|
|
528
|
-
type,
|
|
529
|
-
meta,
|
|
530
|
-
root,
|
|
531
|
-
output,
|
|
532
|
-
logger
|
|
533
|
-
}: AddIndexesProps): Promise<File[]>;
|
|
534
|
-
static getMode(path: string | undefined | null): Mode;
|
|
535
|
-
}
|
|
536
|
-
//#endregion
|
|
537
485
|
//#region ../core/src/PluginManager.d.ts
|
|
538
486
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
539
487
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
@@ -572,6 +520,9 @@ type GetFileProps<TOptions$1 = object> = {
|
|
|
572
520
|
declare class PluginManager {
|
|
573
521
|
#private;
|
|
574
522
|
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
523
|
+
/**
|
|
524
|
+
* @deprecated do not use from pluginManager
|
|
525
|
+
*/
|
|
575
526
|
readonly fileManager: FileManager;
|
|
576
527
|
readonly events: EventEmitter<Events>;
|
|
577
528
|
readonly config: Config;
|
|
@@ -680,6 +631,11 @@ declare class PluginManager {
|
|
|
680
631
|
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
681
632
|
}
|
|
682
633
|
//#endregion
|
|
634
|
+
//#region ../core/src/FileManager.d.ts
|
|
635
|
+
type FileMetaBase = {
|
|
636
|
+
pluginKey?: Plugin['key'];
|
|
637
|
+
};
|
|
638
|
+
//#endregion
|
|
683
639
|
//#region ../oas/src/types.d.ts
|
|
684
640
|
type contentType = 'application/json' | (string & {});
|
|
685
641
|
type SchemaObject$1 = OasTypes.SchemaObject & {
|
|
@@ -1129,4 +1085,4 @@ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = P
|
|
|
1129
1085
|
}
|
|
1130
1086
|
//#endregion
|
|
1131
1087
|
export { Override as a, contentType as c, PluginFactoryOptions as d, ResolveNameParams as f, OperationSchemas as i, Group as l, File as m, Exclude$1 as n, ResolvePathOptions as o, UserPluginWithLifeCycle as p, Include as r, Oas as s, Generator as t, Output as u };
|
|
1132
|
-
//# sourceMappingURL=OperationGenerator-
|
|
1088
|
+
//# sourceMappingURL=OperationGenerator-c8MWYsSI.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
2
|
+
import { FileManager } from "@kubb/fabric-core";
|
|
2
3
|
import * as OasTypes from "oas/types";
|
|
3
4
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
4
5
|
import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
@@ -185,8 +186,6 @@ type Logger = {
|
|
|
185
186
|
//#endregion
|
|
186
187
|
//#region ../core/src/utils/types.d.ts
|
|
187
188
|
type PossiblePromise<T$1> = Promise<T$1> | T$1;
|
|
188
|
-
type ArrayWithLength<T$1 extends number, U extends any[] = []> = U['length'] extends T$1 ? U : ArrayWithLength<T$1, [true, ...U]>;
|
|
189
|
-
type GreaterThan<T$1 extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T$1>, ...infer _] ? false : true;
|
|
190
189
|
//#endregion
|
|
191
190
|
//#region ../core/src/types.d.ts
|
|
192
191
|
type InputPath = {
|
|
@@ -429,6 +428,9 @@ type ResolveNameParams = {
|
|
|
429
428
|
};
|
|
430
429
|
type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
431
430
|
config: Config;
|
|
431
|
+
/**
|
|
432
|
+
* @deprecated
|
|
433
|
+
*/
|
|
432
434
|
fileManager: FileManager;
|
|
433
435
|
pluginManager: PluginManager;
|
|
434
436
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
@@ -480,60 +482,6 @@ type Group = {
|
|
|
480
482
|
name?: (context: GroupContext) => string;
|
|
481
483
|
};
|
|
482
484
|
//#endregion
|
|
483
|
-
//#region ../core/src/FileManager.d.ts
|
|
484
|
-
type FileMetaBase = {
|
|
485
|
-
pluginKey?: Plugin['key'];
|
|
486
|
-
};
|
|
487
|
-
type AddResult<T$1 extends Array<File>> = Promise<Awaited<GreaterThan<T$1['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
488
|
-
type AddIndexesProps = {
|
|
489
|
-
type: BarrelType | false | undefined;
|
|
490
|
-
/**
|
|
491
|
-
* Root based on root and output.path specified in the config
|
|
492
|
-
*/
|
|
493
|
-
root: string;
|
|
494
|
-
/**
|
|
495
|
-
* Output for plugin
|
|
496
|
-
*/
|
|
497
|
-
output: {
|
|
498
|
-
path: string;
|
|
499
|
-
};
|
|
500
|
-
group?: {
|
|
501
|
-
output: string;
|
|
502
|
-
exportAs: string;
|
|
503
|
-
};
|
|
504
|
-
logger?: Logger;
|
|
505
|
-
meta?: FileMetaBase;
|
|
506
|
-
};
|
|
507
|
-
type WriteFilesProps = {
|
|
508
|
-
root: Config['root'];
|
|
509
|
-
extension?: Record<Extname, Extname | ''>;
|
|
510
|
-
logger?: Logger;
|
|
511
|
-
dryRun?: boolean;
|
|
512
|
-
};
|
|
513
|
-
declare class FileManager {
|
|
514
|
-
#private;
|
|
515
|
-
constructor();
|
|
516
|
-
add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
|
|
517
|
-
getByPath(path: Path): Promise<ResolvedFile | null>;
|
|
518
|
-
deleteByPath(path: Path): Promise<void>;
|
|
519
|
-
clear(): Promise<void>;
|
|
520
|
-
getFiles(): Promise<Array<ResolvedFile>>;
|
|
521
|
-
processFiles({
|
|
522
|
-
dryRun,
|
|
523
|
-
root,
|
|
524
|
-
extension,
|
|
525
|
-
logger
|
|
526
|
-
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
527
|
-
getBarrelFiles({
|
|
528
|
-
type,
|
|
529
|
-
meta,
|
|
530
|
-
root,
|
|
531
|
-
output,
|
|
532
|
-
logger
|
|
533
|
-
}: AddIndexesProps): Promise<File[]>;
|
|
534
|
-
static getMode(path: string | undefined | null): Mode;
|
|
535
|
-
}
|
|
536
|
-
//#endregion
|
|
537
485
|
//#region ../core/src/PluginManager.d.ts
|
|
538
486
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
539
487
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
@@ -572,6 +520,9 @@ type GetFileProps<TOptions$1 = object> = {
|
|
|
572
520
|
declare class PluginManager {
|
|
573
521
|
#private;
|
|
574
522
|
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
523
|
+
/**
|
|
524
|
+
* @deprecated do not use from pluginManager
|
|
525
|
+
*/
|
|
575
526
|
readonly fileManager: FileManager;
|
|
576
527
|
readonly events: EventEmitter<Events>;
|
|
577
528
|
readonly config: Config;
|
|
@@ -680,6 +631,11 @@ declare class PluginManager {
|
|
|
680
631
|
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
681
632
|
}
|
|
682
633
|
//#endregion
|
|
634
|
+
//#region ../core/src/FileManager.d.ts
|
|
635
|
+
type FileMetaBase = {
|
|
636
|
+
pluginKey?: Plugin['key'];
|
|
637
|
+
};
|
|
638
|
+
//#endregion
|
|
683
639
|
//#region ../oas/src/types.d.ts
|
|
684
640
|
type contentType = 'application/json' | (string & {});
|
|
685
641
|
type SchemaObject$1 = OasTypes.SchemaObject & {
|
|
@@ -1129,4 +1085,4 @@ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = P
|
|
|
1129
1085
|
}
|
|
1130
1086
|
//#endregion
|
|
1131
1087
|
export { Override as a, contentType as c, PluginFactoryOptions as d, ResolveNameParams as f, OperationSchemas as i, Group as l, File as m, Exclude$1 as n, ResolvePathOptions as o, UserPluginWithLifeCycle as p, Include as r, Oas as s, Generator as t, Output as u };
|
|
1132
|
-
//# sourceMappingURL=OperationGenerator-
|
|
1088
|
+
//# sourceMappingURL=OperationGenerator-unRLjMpQ.d.cts.map
|
package/dist/components.d.cts
CHANGED
package/dist/components.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ let __kubb_plugin_oas = require("@kubb/plugin-oas");
|
|
|
3
3
|
__kubb_plugin_oas = require_Server.__toESM(__kubb_plugin_oas);
|
|
4
4
|
let __kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
5
5
|
__kubb_plugin_ts = require_Server.__toESM(__kubb_plugin_ts);
|
|
6
|
+
let __kubb_plugin_zod = require("@kubb/plugin-zod");
|
|
7
|
+
__kubb_plugin_zod = require_Server.__toESM(__kubb_plugin_zod);
|
|
6
8
|
let __kubb_core_hooks = require("@kubb/core/hooks");
|
|
7
9
|
__kubb_core_hooks = require_Server.__toESM(__kubb_core_hooks);
|
|
8
10
|
let __kubb_plugin_client_components = require("@kubb/plugin-client/components");
|
|
@@ -15,8 +17,6 @@ let __kubb_react = require("@kubb/react");
|
|
|
15
17
|
__kubb_react = require_Server.__toESM(__kubb_react);
|
|
16
18
|
let __kubb_react_jsx_runtime = require("@kubb/react/jsx-runtime");
|
|
17
19
|
__kubb_react_jsx_runtime = require_Server.__toESM(__kubb_react_jsx_runtime);
|
|
18
|
-
let __kubb_plugin_zod = require("@kubb/plugin-zod");
|
|
19
|
-
__kubb_plugin_zod = require_Server.__toESM(__kubb_plugin_zod);
|
|
20
20
|
|
|
21
21
|
//#region src/generators/mcpGenerator.tsx
|
|
22
22
|
const mcpGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
@@ -244,4 +244,4 @@ Object.defineProperty(exports, 'serverGenerator', {
|
|
|
244
244
|
return serverGenerator;
|
|
245
245
|
}
|
|
246
246
|
});
|
|
247
|
-
//# sourceMappingURL=generators-
|
|
247
|
+
//# sourceMappingURL=generators-naBCKi9F.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generators-
|
|
1
|
+
{"version":3,"file":"generators-naBCKi9F.cjs","names":["pluginTsName","File","Client","pluginZodName","pluginTsName","File","Server"],"sources":["../src/generators/mcpGenerator.tsx","../src/generators/serverGenerator.tsx"],"sourcesContent":["import { usePlugin } from '@kubb/core/hooks'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/react'\nimport type { PluginMcp } from '../types'\n\nexport const mcpGenerator = createReactGenerator<PluginMcp>({\n name: 'mcp',\n Operation({ operation }) {\n const { options } = usePlugin<PluginMcp>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const mcp = {\n name: getName(operation, { type: 'function', suffix: 'handler' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n return (\n <File\n baseName={mcp.file.baseName}\n path={mcp.file.path}\n meta={mcp.file.meta}\n banner={getBanner({ oas, output: options.output })}\n footer={getFooter({ oas, output: options.output })}\n >\n <File.Import name={['CallToolResult']} path={'@modelcontextprotocol/sdk/types'} isTypeOnly />\n <File.Import name={'fetch'} path={options.client.importPath} />\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={mcp.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <Client\n name={mcp.name}\n isConfigurable={false}\n returnType={'Promise<CallToolResult>'}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={undefined}\n dataReturnType={options.client.dataReturnType}\n paramsType={'object'}\n paramsCasing={'camelcase'}\n pathParamsType={'object'}\n parser={'client'}\n >\n {options.client.dataReturnType === 'data' &&\n `return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(res.data)\n }\n ]\n }`}\n {options.client.dataReturnType === 'full' &&\n `return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(res)\n }\n ]\n }`}\n </Client>\n </File>\n )\n },\n})\n","import { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File } from '@kubb/react'\nimport { Server } from '../components/Server'\nimport type { PluginMcp } from '../types'\n\nexport const serverGenerator = createReactGenerator<PluginMcp>({\n name: 'operations',\n Operations({ operations, options }) {\n const plugin = usePlugin<PluginMcp>()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getFile, getName, getSchemas } = useOperationManager()\n\n const name = 'server'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey: plugin.key })\n\n const jsonFile = pluginManager.getFile({ name: '.mcp', extname: '.json', pluginKey: plugin.key })\n\n const operationsMapped = operations.map((operation) => {\n return {\n tool: {\n name: operation.getOperationId() || operation.getSummary() || `${operation.method.toUpperCase()} ${operation.path}`,\n description: operation.getDescription() || `Make a ${operation.method.toUpperCase()} request to ${operation.path}`,\n },\n mcp: {\n name: getName(operation, {\n type: 'function',\n suffix: 'handler',\n }),\n file: getFile(operation),\n },\n zod: {\n name: getName(operation, {\n type: 'function',\n pluginKey: [pluginZodName],\n }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n },\n type: {\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n },\n }\n })\n\n const imports = operationsMapped.flatMap(({ mcp, zod }) => {\n return [\n <File.Import key={mcp.name} name={[mcp.name]} root={file.path} path={mcp.file.path} />,\n <File.Import\n key={zod.name}\n name={[zod.schemas.request?.name, zod.schemas.pathParams?.name, zod.schemas.queryParams?.name, zod.schemas.headerParams?.name].filter(Boolean)}\n root={file.path}\n path={zod.file.path}\n />,\n ]\n })\n\n return (\n <>\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: options.output })}\n >\n <File.Import name={['McpServer']} path={'@modelcontextprotocol/sdk/server/mcp'} />\n <File.Import name={['StdioServerTransport']} path={'@modelcontextprotocol/sdk/server/stdio'} />\n\n {imports}\n <Server name={name} serverName={oas.api.info?.title} serverVersion={oas.getVersion()} operations={operationsMapped} />\n </File>\n\n <File baseName={jsonFile.baseName} path={jsonFile.path} meta={jsonFile.meta}>\n <File.Source name={name}>\n {`\n {\n \"mcpServers\": {\n \"${oas.api.info?.title || 'server'}\": {\n \"type\": \"stdio\",\n \"command\": \"npx\",\n \"args\": [\"tsx\", \"${file.path}\"]\n }\n }\n }\n `}\n </File.Source>\n </File>\n </>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;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E;IACF;IACD;EAEF,MAAM,UAAU,iBAAiB,SAAS,EAAE,KAAK,UAAU;AACzD,UAAO,CACL,kDAACC,kBAAK;IAAsB,MAAM,CAAC,IAAI,KAAK;IAAE,MAAM,KAAK;IAAM,MAAM,IAAI,KAAK;MAA5D,IAAI,KAAgE,EACtF,kDAACA,kBAAK;IAEJ,MAAM;KAAC,IAAI,QAAQ,SAAS;KAAM,IAAI,QAAQ,YAAY;KAAM,IAAI,QAAQ,aAAa;KAAM,IAAI,QAAQ,cAAc;KAAK,CAAC,OAAO,QAAQ;IAC9I,MAAM,KAAK;IACX,MAAM,IAAI,KAAK;MAHV,IAAI,KAIT,CACH;IACD;AAEF,SACE,mGACE,mDAACA;GACC,UAAU,KAAK;GACf,MAAM,KAAK;GACX,MAAM,KAAK;GACX,+CAAkB;IAAE;IAAK,QAAQ,QAAQ;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChF,+CAAkB;IAAE;IAAK,QAAQ,QAAQ;IAAQ,CAAC;;IAElD,kDAACA,kBAAK;KAAO,MAAM,CAAC,YAAY;KAAE,MAAM;MAA0C;IAClF,kDAACA,kBAAK;KAAO,MAAM,CAAC,uBAAuB;KAAE,MAAM;MAA4C;IAE9F;IACD,kDAACC;KAAa;KAAM,YAAY,IAAI,IAAI,MAAM;KAAO,eAAe,IAAI,YAAY;KAAE,YAAY;MAAoB;;IACjH,EAEP,kDAACD;GAAK,UAAU,SAAS;GAAU,MAAM,SAAS;GAAM,MAAM,SAAS;aACrE,kDAACA,kBAAK;IAAa;cAChB;;;iBAGI,IAAI,IAAI,MAAM,SAAS,SAAS;;;mCAGd,KAAK,KAAK;;;;;KAKrB;IACT,IACN;;CAGR,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as Server } from "./Server-CKHk0vlR.js";
|
|
2
2
|
import { createReactGenerator } from "@kubb/plugin-oas";
|
|
3
3
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
4
|
+
import { pluginZodName } from "@kubb/plugin-zod";
|
|
4
5
|
import { usePlugin, usePluginManager } from "@kubb/core/hooks";
|
|
5
6
|
import { Client } from "@kubb/plugin-client/components";
|
|
6
7
|
import { useOas, useOperationManager } from "@kubb/plugin-oas/hooks";
|
|
7
8
|
import { getBanner, getFooter } from "@kubb/plugin-oas/utils";
|
|
8
9
|
import { File } from "@kubb/react";
|
|
9
10
|
import { Fragment, jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
10
|
-
import { pluginZodName } from "@kubb/plugin-zod";
|
|
11
11
|
|
|
12
12
|
//#region src/generators/mcpGenerator.tsx
|
|
13
13
|
const mcpGenerator = createReactGenerator({
|
|
@@ -224,4 +224,4 @@ const serverGenerator = createReactGenerator({
|
|
|
224
224
|
|
|
225
225
|
//#endregion
|
|
226
226
|
export { mcpGenerator as n, serverGenerator as t };
|
|
227
|
-
//# sourceMappingURL=generators-
|
|
227
|
+
//# sourceMappingURL=generators-zuKj-GtG.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generators-
|
|
1
|
+
{"version":3,"file":"generators-zuKj-GtG.js","names":[],"sources":["../src/generators/mcpGenerator.tsx","../src/generators/serverGenerator.tsx"],"sourcesContent":["import { usePlugin } from '@kubb/core/hooks'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/react'\nimport type { PluginMcp } from '../types'\n\nexport const mcpGenerator = createReactGenerator<PluginMcp>({\n name: 'mcp',\n Operation({ operation }) {\n const { options } = usePlugin<PluginMcp>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const mcp = {\n name: getName(operation, { type: 'function', suffix: 'handler' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n return (\n <File\n baseName={mcp.file.baseName}\n path={mcp.file.path}\n meta={mcp.file.meta}\n banner={getBanner({ oas, output: options.output })}\n footer={getFooter({ oas, output: options.output })}\n >\n <File.Import name={['CallToolResult']} path={'@modelcontextprotocol/sdk/types'} isTypeOnly />\n <File.Import name={'fetch'} path={options.client.importPath} />\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={mcp.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <Client\n name={mcp.name}\n isConfigurable={false}\n returnType={'Promise<CallToolResult>'}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={undefined}\n dataReturnType={options.client.dataReturnType}\n paramsType={'object'}\n paramsCasing={'camelcase'}\n pathParamsType={'object'}\n parser={'client'}\n >\n {options.client.dataReturnType === 'data' &&\n `return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(res.data)\n }\n ]\n }`}\n {options.client.dataReturnType === 'full' &&\n `return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(res)\n }\n ]\n }`}\n </Client>\n </File>\n )\n },\n})\n","import { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File } from '@kubb/react'\nimport { Server } from '../components/Server'\nimport type { PluginMcp } from '../types'\n\nexport const serverGenerator = createReactGenerator<PluginMcp>({\n name: 'operations',\n Operations({ operations, options }) {\n const plugin = usePlugin<PluginMcp>()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getFile, getName, getSchemas } = useOperationManager()\n\n const name = 'server'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey: plugin.key })\n\n const jsonFile = pluginManager.getFile({ name: '.mcp', extname: '.json', pluginKey: plugin.key })\n\n const operationsMapped = operations.map((operation) => {\n return {\n tool: {\n name: operation.getOperationId() || operation.getSummary() || `${operation.method.toUpperCase()} ${operation.path}`,\n description: operation.getDescription() || `Make a ${operation.method.toUpperCase()} request to ${operation.path}`,\n },\n mcp: {\n name: getName(operation, {\n type: 'function',\n suffix: 'handler',\n }),\n file: getFile(operation),\n },\n zod: {\n name: getName(operation, {\n type: 'function',\n pluginKey: [pluginZodName],\n }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n },\n type: {\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n },\n }\n })\n\n const imports = operationsMapped.flatMap(({ mcp, zod }) => {\n return [\n <File.Import key={mcp.name} name={[mcp.name]} root={file.path} path={mcp.file.path} />,\n <File.Import\n key={zod.name}\n name={[zod.schemas.request?.name, zod.schemas.pathParams?.name, zod.schemas.queryParams?.name, zod.schemas.headerParams?.name].filter(Boolean)}\n root={file.path}\n path={zod.file.path}\n />,\n ]\n })\n\n return (\n <>\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: options.output })}\n >\n <File.Import name={['McpServer']} path={'@modelcontextprotocol/sdk/server/mcp'} />\n <File.Import name={['StdioServerTransport']} path={'@modelcontextprotocol/sdk/server/stdio'} />\n\n {imports}\n <Server name={name} serverName={oas.api.info?.title} serverVersion={oas.getVersion()} operations={operationsMapped} />\n </File>\n\n <File baseName={jsonFile.baseName} path={jsonFile.path} meta={jsonFile.meta}>\n <File.Source name={name}>\n {`\n {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mCAGd,KAAK,KAAK;;;;;KAKrB;IACT,IACN;;CAGR,CAAC"}
|
package/dist/generators.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require('./Server-AWXKgK_d.cjs');
|
|
2
|
-
const require_generators = require('./generators-
|
|
2
|
+
const require_generators = require('./generators-naBCKi9F.cjs');
|
|
3
3
|
|
|
4
4
|
exports.mcpGenerator = require_generators.mcpGenerator;
|
|
5
5
|
exports.serverGenerator = require_generators.serverGenerator;
|
package/dist/generators.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as Generator } from "./OperationGenerator-
|
|
2
|
-
import { n as PluginMcp } from "./types-
|
|
1
|
+
import { t as Generator } from "./OperationGenerator-unRLjMpQ.cjs";
|
|
2
|
+
import { n as PluginMcp } from "./types-DI32TxX9.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/generators/mcpGenerator.d.ts
|
|
5
5
|
declare const mcpGenerator: Generator<PluginMcp>;
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as Generator } from "./OperationGenerator-
|
|
2
|
-
import { n as PluginMcp } from "./types-
|
|
1
|
+
import { t as Generator } from "./OperationGenerator-c8MWYsSI.js";
|
|
2
|
+
import { n as PluginMcp } from "./types-7AZo3Q-6.js";
|
|
3
3
|
|
|
4
4
|
//#region src/generators/mcpGenerator.d.ts
|
|
5
5
|
declare const mcpGenerator: Generator<PluginMcp>;
|
package/dist/generators.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_Server = require('./Server-AWXKgK_d.cjs');
|
|
2
|
-
const require_generators = require('./generators-
|
|
2
|
+
const require_generators = require('./generators-naBCKi9F.cjs');
|
|
3
3
|
let node_path = require("node:path");
|
|
4
4
|
node_path = require_Server.__toESM(node_path);
|
|
5
5
|
let __kubb_core = require("@kubb/core");
|
|
@@ -38,7 +38,7 @@ const pluginMcp = (0, __kubb_core.createPlugin)((options) => {
|
|
|
38
38
|
].filter(Boolean),
|
|
39
39
|
resolvePath(baseName, pathMode, options$1) {
|
|
40
40
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
41
|
-
if ((pathMode ?? __kubb_core.
|
|
41
|
+
if ((pathMode ?? (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path))) === "single")
|
|
42
42
|
/**
|
|
43
43
|
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
44
44
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
@@ -62,7 +62,7 @@ const pluginMcp = (0, __kubb_core.createPlugin)((options) => {
|
|
|
62
62
|
const [swaggerPlugin] = __kubb_core.PluginManager.getDependedPlugins(this.plugins, [__kubb_plugin_oas.pluginOasName]);
|
|
63
63
|
const oas = await swaggerPlugin.context.getOas();
|
|
64
64
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
65
|
-
const mode = __kubb_core.
|
|
65
|
+
const mode = (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path));
|
|
66
66
|
const files = await new __kubb_plugin_oas.OperationGenerator(this.plugin.options, {
|
|
67
67
|
oas,
|
|
68
68
|
pluginManager: this.pluginManager,
|
|
@@ -74,7 +74,7 @@ const pluginMcp = (0, __kubb_core.createPlugin)((options) => {
|
|
|
74
74
|
mode
|
|
75
75
|
}).build(...generators);
|
|
76
76
|
await this.addFile(...files);
|
|
77
|
-
const barrelFiles = await this.fileManager.
|
|
77
|
+
const barrelFiles = await (0, __kubb_core.getBarrelFiles)(this.fileManager.files, {
|
|
78
78
|
type: output.barrelType ?? "named",
|
|
79
79
|
root,
|
|
80
80
|
output,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["mcpGenerator","serverGenerator","pluginOasName","pluginTsName","pluginZodName","path","
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["mcpGenerator","serverGenerator","pluginOasName","pluginTsName","pluginZodName","path","options","groupName: Group['name']","PluginManager","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\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 = createPlugin<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 } = options\n\n return {\n name: pluginMcpName,\n options: {\n output,\n group,\n client: {\n importPath: '@kubb/plugin-client/clients/axios',\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 buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\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.addFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fileManager.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.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAUA,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,gBACE;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA,QAAQ;IACN,YAAY;IACZ,gBAAgB;IAChB,GAAG,QAAQ;IACZ;GACF;EACD,KAAK;GAACC;GAAeC;GAAcC;GAAc,CAAC,OAAO,QAAQ;EACjE,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAOC,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,qCAAoBA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEpD;;;;;AAKX,UAAOA,kBAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC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/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { p as UserPluginWithLifeCycle } from "./OperationGenerator-
|
|
2
|
-
import { n as PluginMcp, t as Options } from "./types-
|
|
1
|
+
import { p as UserPluginWithLifeCycle } from "./OperationGenerator-unRLjMpQ.cjs";
|
|
2
|
+
import { n as PluginMcp, t as Options } from "./types-DI32TxX9.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 { p as UserPluginWithLifeCycle } from "./OperationGenerator-
|
|
2
|
-
import { n as PluginMcp, t as Options } from "./types-
|
|
1
|
+
import { p as UserPluginWithLifeCycle } from "./OperationGenerator-c8MWYsSI.js";
|
|
2
|
+
import { n as PluginMcp, t as Options } from "./types-7AZo3Q-6.js";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin.d.ts
|
|
5
5
|
declare const pluginMcpName = "plugin-mcp";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as mcpGenerator, t as serverGenerator } from "./generators-
|
|
1
|
+
import { n as mcpGenerator, t as serverGenerator } from "./generators-zuKj-GtG.js";
|
|
2
2
|
import "./Server-CKHk0vlR.js";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { PluginManager, createPlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
5
5
|
import { camelCase } from "@kubb/core/transformers";
|
|
6
6
|
import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
7
7
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
@@ -32,7 +32,7 @@ const pluginMcp = createPlugin((options) => {
|
|
|
32
32
|
].filter(Boolean),
|
|
33
33
|
resolvePath(baseName, pathMode, options$1) {
|
|
34
34
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
35
|
-
if ((pathMode ??
|
|
35
|
+
if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
|
|
36
36
|
/**
|
|
37
37
|
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
38
38
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
@@ -56,7 +56,7 @@ const pluginMcp = createPlugin((options) => {
|
|
|
56
56
|
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
57
57
|
const oas = await swaggerPlugin.context.getOas();
|
|
58
58
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
59
|
-
const mode =
|
|
59
|
+
const mode = getMode(path.resolve(root, output.path));
|
|
60
60
|
const files = await new OperationGenerator(this.plugin.options, {
|
|
61
61
|
oas,
|
|
62
62
|
pluginManager: this.pluginManager,
|
|
@@ -68,7 +68,7 @@ const pluginMcp = createPlugin((options) => {
|
|
|
68
68
|
mode
|
|
69
69
|
}).build(...generators);
|
|
70
70
|
await this.addFile(...files);
|
|
71
|
-
const barrelFiles = await this.fileManager.
|
|
71
|
+
const barrelFiles = await getBarrelFiles(this.fileManager.files, {
|
|
72
72
|
type: output.barrelType ?? "named",
|
|
73
73
|
root,
|
|
74
74
|
output,
|
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'\
|
|
1
|
+
{"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\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 = createPlugin<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 } = options\n\n return {\n name: pluginMcpName,\n options: {\n output,\n group,\n client: {\n importPath: '@kubb/plugin-client/clients/axios',\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 buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\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.addFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fileManager.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.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;AAUA,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,gBACE;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA,QAAQ;IACN,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,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,YAAY,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEpD;;;;;AAKX,UAAO,KAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC,OAAI,UAAUA,WAAS,OAAO,QAAQA,WAAS,OAAO,MAAM;IAC1D,MAAMC,YAA2B,OAAO,OACpC,MAAM,QACL,QAAQ;AACP,SAAI,OAAO,SAAS,OAClB,QAAO,GAAG,IAAI,MAAM,MAAM,IAAI,CAAC;AAEjC,YAAO,GAAG,UAAU,IAAI,MAAM,CAAC;;AAGrC,WAAO,KAAK,QACV,MACA,OAAO,MACP,UAAU,EACR,OAAO,MAAM,SAAS,SAASD,UAAQ,MAAM,OAAQA,UAAQ,MAAM,KACpE,CAAC,EACF,SACD;;AAGH,UAAO,KAAK,QAAQ,MAAM,OAAO,MAAM,SAAS;;EAElD,YAAY,MAAM,MAAM;GACtB,MAAM,eAAe,UAAU,MAAM,EACnC,QAAQ,SAAS,QAClB,CAAC;AAEF,OAAI,KACF,QAAO,cAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;;EAET,MAAM,aAAa;GACjB,MAAM,CAAC,iBAAiD,cAAc,mBAAyC,KAAK,SAAS,CAAC,cAAc,CAAC;GAE7I,MAAM,MAAM,MAAM,cAAc,QAAQ,QAAQ;GAChD,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,OAAO,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GAarD,MAAM,QAAQ,MAXa,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,QAAQ,GAAG,MAAM;GAE5B,MAAM,cAAc,MAAM,eAAe,KAAK,YAAY,OAAO;IAC/D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as Override, c as contentType, d as PluginFactoryOptions, f as ResolveNameParams, l as Group, n as Exclude, o as ResolvePathOptions, r as Include, s as Oas, t as Generator, u as Output } from "./OperationGenerator-
|
|
1
|
+
import { a as Override, c as contentType, d as PluginFactoryOptions, f as ResolveNameParams, l as Group, n as Exclude, o as ResolvePathOptions, r as Include, s as Oas, t as Generator, u as Output } from "./OperationGenerator-c8MWYsSI.js";
|
|
2
2
|
|
|
3
3
|
//#region ../plugin-client/src/types.d.ts
|
|
4
4
|
type Options$1 = {
|
|
@@ -165,4 +165,4 @@ type ResolvedOptions = {
|
|
|
165
165
|
type PluginMcp = PluginFactoryOptions<'plugin-mcp', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
166
166
|
//#endregion
|
|
167
167
|
export { PluginMcp as n, Options as t };
|
|
168
|
-
//# sourceMappingURL=types-
|
|
168
|
+
//# sourceMappingURL=types-7AZo3Q-6.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as Override, c as contentType, d as PluginFactoryOptions, f as ResolveNameParams, l as Group, n as Exclude, o as ResolvePathOptions, r as Include, s as Oas, t as Generator, u as Output } from "./OperationGenerator-
|
|
1
|
+
import { a as Override, c as contentType, d as PluginFactoryOptions, f as ResolveNameParams, l as Group, n as Exclude, o as ResolvePathOptions, r as Include, s as Oas, t as Generator, u as Output } from "./OperationGenerator-unRLjMpQ.cjs";
|
|
2
2
|
|
|
3
3
|
//#region ../plugin-client/src/types.d.ts
|
|
4
4
|
type Options$1 = {
|
|
@@ -165,4 +165,4 @@ type ResolvedOptions = {
|
|
|
165
165
|
type PluginMcp = PluginFactoryOptions<'plugin-mcp', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
166
166
|
//#endregion
|
|
167
167
|
export { PluginMcp as n, Options as t };
|
|
168
|
-
//# sourceMappingURL=types-
|
|
168
|
+
//# sourceMappingURL=types-DI32TxX9.d.cts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-mcp",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"description": "Generator mcp",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
"!/**/__tests__/**"
|
|
63
63
|
],
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@kubb/core": "4.2.
|
|
66
|
-
"@kubb/oas": "4.2.
|
|
67
|
-
"@kubb/plugin-client": "4.2.
|
|
68
|
-
"@kubb/plugin-oas": "4.2.
|
|
69
|
-
"@kubb/plugin-ts": "4.2.
|
|
70
|
-
"@kubb/plugin-zod": "4.2.
|
|
71
|
-
"@kubb/react": "4.2.
|
|
65
|
+
"@kubb/core": "4.2.2",
|
|
66
|
+
"@kubb/oas": "4.2.2",
|
|
67
|
+
"@kubb/plugin-client": "4.2.2",
|
|
68
|
+
"@kubb/plugin-oas": "4.2.2",
|
|
69
|
+
"@kubb/plugin-ts": "4.2.2",
|
|
70
|
+
"@kubb/plugin-zod": "4.2.2",
|
|
71
|
+
"@kubb/react": "4.2.2"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"tsdown": "^0.15.9",
|
package/src/plugin.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
|
|
3
|
-
import { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'
|
|
2
|
+
import { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'
|
|
4
3
|
import { camelCase } from '@kubb/core/transformers'
|
|
4
|
+
import type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'
|
|
5
5
|
import { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'
|
|
6
6
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
7
|
-
|
|
8
|
-
import type { Plugin } from '@kubb/core'
|
|
9
|
-
import type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'
|
|
7
|
+
import { pluginZodName } from '@kubb/plugin-zod'
|
|
10
8
|
import { mcpGenerator, serverGenerator } from './generators'
|
|
11
9
|
import type { PluginMcp } from './types.ts'
|
|
12
|
-
import { pluginZodName } from '@kubb/plugin-zod'
|
|
13
10
|
|
|
14
11
|
export const pluginMcpName = 'plugin-mcp' satisfies PluginMcp['name']
|
|
15
12
|
|
|
@@ -39,7 +36,7 @@ export const pluginMcp = createPlugin<PluginMcp>((options) => {
|
|
|
39
36
|
pre: [pluginOasName, pluginTsName, pluginZodName].filter(Boolean),
|
|
40
37
|
resolvePath(baseName, pathMode, options) {
|
|
41
38
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
42
|
-
const mode = pathMode ??
|
|
39
|
+
const mode = pathMode ?? getMode(path.resolve(root, output.path))
|
|
43
40
|
|
|
44
41
|
if (mode === 'single') {
|
|
45
42
|
/**
|
|
@@ -87,7 +84,7 @@ export const pluginMcp = createPlugin<PluginMcp>((options) => {
|
|
|
87
84
|
|
|
88
85
|
const oas = await swaggerPlugin.context.getOas()
|
|
89
86
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
90
|
-
const mode =
|
|
87
|
+
const mode = getMode(path.resolve(root, output.path))
|
|
91
88
|
|
|
92
89
|
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
93
90
|
oas,
|
|
@@ -103,7 +100,7 @@ export const pluginMcp = createPlugin<PluginMcp>((options) => {
|
|
|
103
100
|
const files = await operationGenerator.build(...generators)
|
|
104
101
|
await this.addFile(...files)
|
|
105
102
|
|
|
106
|
-
const barrelFiles = await this.fileManager.
|
|
103
|
+
const barrelFiles = await getBarrelFiles(this.fileManager.files, {
|
|
107
104
|
type: output.barrelType ?? 'named',
|
|
108
105
|
root,
|
|
109
106
|
output,
|