@kubb/plugin-mcp 3.18.3 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,11 +21,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  }) : target, mod));
22
22
 
23
23
  //#endregion
24
- const __kubb_core_transformers = __toESM(require("@kubb/core/transformers"));
25
- const __kubb_plugin_oas_utils = __toESM(require("@kubb/plugin-oas/utils"));
26
- const __kubb_react = __toESM(require("@kubb/react"));
27
- const __kubb_react_jsx_runtime = __toESM(require("@kubb/react/jsx-runtime"));
28
- const __kubb_oas = __toESM(require("@kubb/oas"));
24
+ let __kubb_core_transformers = require("@kubb/core/transformers");
25
+ __kubb_core_transformers = __toESM(__kubb_core_transformers);
26
+ let __kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
27
+ __kubb_plugin_oas_utils = __toESM(__kubb_plugin_oas_utils);
28
+ let __kubb_react = require("@kubb/react");
29
+ __kubb_react = __toESM(__kubb_react);
30
+ let __kubb_react_jsx_runtime = require("@kubb/react/jsx-runtime");
31
+ __kubb_react_jsx_runtime = __toESM(__kubb_react_jsx_runtime);
32
+ let __kubb_oas = require("@kubb/oas");
33
+ __kubb_oas = __toESM(__kubb_oas);
29
34
 
30
35
  //#region src/components/Server.tsx
31
36
  function getParams({ schemas }) {
@@ -121,4 +126,4 @@ Object.defineProperty(exports, '__toESM', {
121
126
  return __toESM;
122
127
  }
123
128
  });
124
- //# sourceMappingURL=Server-Bh-nULhJ.cjs.map
129
+ //# sourceMappingURL=Server-AWXKgK_d.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Server-Bh-nULhJ.cjs","names":["FunctionParams","File","Const"],"sources":["../src/components/Server.tsx"],"sourcesContent":["import type { KubbFile } from '@kubb/core/fs'\n\nimport { Const, File, FunctionParams } from '@kubb/react'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams, isOptional } from '@kubb/plugin-oas/utils'\nimport { isNullable, isReference } from '@kubb/oas'\nimport { camelCase } from '@kubb/core/transformers'\n\ntype Props = {\n name: string\n serverName: string\n serverVersion: string\n operations: Array<{\n tool: {\n name: string\n description: string\n }\n mcp: {\n name: string\n file: KubbFile.File\n }\n zod: {\n name: string\n file: KubbFile.File\n schemas: OperationSchemas\n }\n type: {\n schemas: OperationSchemas\n }\n }>\n}\n\ntype GetParamsProps = {\n schemas: OperationSchemas\n}\n\nfunction getParams({ schemas }: GetParamsProps) {\n const pathParams = getPathParams(schemas.pathParams, {\n typed: false,\n })\n\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...Object.entries(pathParams).reduce((acc, [key, param]) => {\n if (param && schemas.pathParams?.name) {\n let suffix = '.shape'\n\n if (isNullable(schemas.pathParams.schema)) {\n if (isReference(schemas.pathParams)) {\n suffix = '.unwrap().schema.unwrap().shape'\n } else {\n suffix = '.unwrap().shape'\n }\n } else {\n if (isReference(schemas.pathParams)) {\n suffix = '.schema.shape'\n }\n }\n\n param.value = `${schemas.pathParams?.name}${suffix}['${key}']`\n }\n\n return {\n ...acc,\n [camelCase(key)]: param,\n }\n }, {}),\n data: schemas.request?.name\n ? {\n value: schemas.request?.name,\n optional: isOptional(schemas.request?.schema),\n }\n : undefined,\n params: schemas.queryParams?.name\n ? {\n value: schemas.queryParams?.name,\n optional: isOptional(schemas.queryParams?.schema),\n }\n : undefined,\n headers: schemas.headerParams?.name\n ? {\n value: schemas.headerParams?.name,\n optional: isOptional(schemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n })\n}\n\nexport function Server({ name, serverName, serverVersion, operations }: Props) {\n return (\n <File.Source name={name} isExportable isIndexable>\n <Const name={'server'} export>\n {`\n new McpServer({\n name: '${serverName}',\n version: '${serverVersion}',\n})\n `}\n </Const>\n\n {operations\n .map(({ tool, mcp, zod }) => {\n const paramsClient = getParams({ schemas: zod.schemas })\n\n if (zod.schemas.request?.name || zod.schemas.headerParams?.name || zod.schemas.queryParams?.name || zod.schemas.pathParams?.name) {\n return `\nserver.tool(${JSON.stringify(tool.name)}, ${JSON.stringify(tool.description)}, ${paramsClient.toObjectValue()}, async (${paramsClient.toObject()}) => {\n return ${mcp.name}(${paramsClient.toObject()})\n})\n `\n }\n\n return `\nserver.tool(${JSON.stringify(tool.name)}, ${JSON.stringify(tool.description)}, async () => {\n return ${mcp.name}(${paramsClient.toObject()})\n})\n `\n })\n .filter(Boolean)}\n\n {`\nasync function startServer() {\n try {\n const transport = new StdioServerTransport()\n await server.connect(transport)\n\n } catch (error) {\n console.error('Failed to start server:', error)\n process.exit(1)\n }\n}\n\nstartServer()\n`}\n </File.Source>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAS,UAAU,EAAE,WAA2B;CAC9C,MAAM,wDAA2B,QAAQ,YAAY,EACnD,OAAO;AAGT,QAAOA,4BAAe,QAAQ,EAC5B,MAAM;EACJ,MAAM;EACN,UAAU;GACR,GAAG,OAAO,QAAQ,YAAY,QAAQ,KAAK,CAAC,KAAK,WAAW;AAC1D,QAAI,SAAS,QAAQ,YAAY,MAAM;KACrC,IAAI,SAAS;AAEb,oCAAe,QAAQ,WAAW,QAChC,iCAAgB,QAAQ,YACtB,UAAS;SAET,UAAS;0CAGK,QAAQ,YACtB,UAAS;AAIb,WAAM,QAAQ,GAAG,QAAQ,YAAY,OAAO,OAAO,IAAI,IAAI;;AAG7D,WAAO;KACL,GAAG;8CACQ,OAAO;;MAEnB;GACH,MAAM,QAAQ,SAAS,OACnB;IACE,OAAO,QAAQ,SAAS;IACxB,kDAAqB,QAAQ,SAAS;OAExC;GACJ,QAAQ,QAAQ,aAAa,OACzB;IACE,OAAO,QAAQ,aAAa;IAC5B,kDAAqB,QAAQ,aAAa;OAE5C;GACJ,SAAS,QAAQ,cAAc,OAC3B;IACE,OAAO,QAAQ,cAAc;IAC7B,kDAAqB,QAAQ,cAAc;OAE7C;;;;AAMZ,SAAgB,OAAO,EAAE,MAAM,YAAY,eAAe,cAAqB;AAC7E,QACE,mDAACC,kBAAK;EAAa;EAAM;EAAa;;GACpC,kDAACC;IAAM,MAAM;IAAU;cACpB;;WAEE,WAAW;cACR,cAAc;;;;GAKrB,WACE,KAAK,EAAE,MAAM,KAAK,UAAU;IAC3B,MAAM,eAAe,UAAU,EAAE,SAAS,IAAI;AAE9C,QAAI,IAAI,QAAQ,SAAS,QAAQ,IAAI,QAAQ,cAAc,QAAQ,IAAI,QAAQ,aAAa,QAAQ,IAAI,QAAQ,YAAY,KAC1H,QAAO;cACL,KAAK,UAAU,KAAK,MAAM,IAAI,KAAK,UAAU,KAAK,aAAa,IAAI,aAAa,gBAAgB,WAAW,aAAa,WAAW;WACtI,IAAI,KAAK,GAAG,aAAa,WAAW;;;AAKrC,WAAO;cACH,KAAK,UAAU,KAAK,MAAM,IAAI,KAAK,UAAU,KAAK,aAAa;WAClE,IAAI,KAAK,GAAG,aAAa,WAAW;;;MAItC,OAAO;GAET"}
1
+ {"version":3,"file":"Server-AWXKgK_d.cjs","names":["FunctionParams","File","Const"],"sources":["../src/components/Server.tsx"],"sourcesContent":["import type { KubbFile } from '@kubb/core/fs'\n\nimport { Const, File, FunctionParams } from '@kubb/react'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams, isOptional } from '@kubb/plugin-oas/utils'\nimport { isNullable, isReference } from '@kubb/oas'\nimport { camelCase } from '@kubb/core/transformers'\n\ntype Props = {\n name: string\n serverName: string\n serverVersion: string\n operations: Array<{\n tool: {\n name: string\n description: string\n }\n mcp: {\n name: string\n file: KubbFile.File\n }\n zod: {\n name: string\n file: KubbFile.File\n schemas: OperationSchemas\n }\n type: {\n schemas: OperationSchemas\n }\n }>\n}\n\ntype GetParamsProps = {\n schemas: OperationSchemas\n}\n\nfunction getParams({ schemas }: GetParamsProps) {\n const pathParams = getPathParams(schemas.pathParams, {\n typed: false,\n })\n\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...Object.entries(pathParams).reduce((acc, [key, param]) => {\n if (param && schemas.pathParams?.name) {\n let suffix = '.shape'\n\n if (isNullable(schemas.pathParams.schema)) {\n if (isReference(schemas.pathParams)) {\n suffix = '.unwrap().schema.unwrap().shape'\n } else {\n suffix = '.unwrap().shape'\n }\n } else {\n if (isReference(schemas.pathParams)) {\n suffix = '.schema.shape'\n }\n }\n\n param.value = `${schemas.pathParams?.name}${suffix}['${key}']`\n }\n\n return {\n ...acc,\n [camelCase(key)]: param,\n }\n }, {}),\n data: schemas.request?.name\n ? {\n value: schemas.request?.name,\n optional: isOptional(schemas.request?.schema),\n }\n : undefined,\n params: schemas.queryParams?.name\n ? {\n value: schemas.queryParams?.name,\n optional: isOptional(schemas.queryParams?.schema),\n }\n : undefined,\n headers: schemas.headerParams?.name\n ? {\n value: schemas.headerParams?.name,\n optional: isOptional(schemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n })\n}\n\nexport function Server({ name, serverName, serverVersion, operations }: Props) {\n return (\n <File.Source name={name} isExportable isIndexable>\n <Const name={'server'} export>\n {`\n new McpServer({\n name: '${serverName}',\n version: '${serverVersion}',\n})\n `}\n </Const>\n\n {operations\n .map(({ tool, mcp, zod }) => {\n const paramsClient = getParams({ schemas: zod.schemas })\n\n if (zod.schemas.request?.name || zod.schemas.headerParams?.name || zod.schemas.queryParams?.name || zod.schemas.pathParams?.name) {\n return `\nserver.tool(${JSON.stringify(tool.name)}, ${JSON.stringify(tool.description)}, ${paramsClient.toObjectValue()}, async (${paramsClient.toObject()}) => {\n return ${mcp.name}(${paramsClient.toObject()})\n})\n `\n }\n\n return `\nserver.tool(${JSON.stringify(tool.name)}, ${JSON.stringify(tool.description)}, async () => {\n return ${mcp.name}(${paramsClient.toObject()})\n})\n `\n })\n .filter(Boolean)}\n\n {`\nasync function startServer() {\n try {\n const transport = new StdioServerTransport()\n await server.connect(transport)\n\n } catch (error) {\n console.error('Failed to start server:', error)\n process.exit(1)\n }\n}\n\nstartServer()\n`}\n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cAAc,QAAQ,IAAI,QAAQ,aAAa,QAAQ,IAAI,QAAQ,YAAY,KAC1H,QAAO;cACL,KAAK,UAAU,KAAK,KAAK,CAAC,IAAI,KAAK,UAAU,KAAK,YAAY,CAAC,IAAI,aAAa,eAAe,CAAC,WAAW,aAAa,UAAU,CAAC;WACtI,IAAI,KAAK,GAAG,aAAa,UAAU,CAAC;;;AAKrC,WAAO;cACH,KAAK,UAAU,KAAK,KAAK,CAAC,IAAI,KAAK,UAAU,KAAK,YAAY,CAAC;WAClE,IAAI,KAAK,GAAG,aAAa,UAAU,CAAC;;;KAGrC,CACD,OAAO,QAAQ;GAEjB;;;;;;;;;;;;;;;GAcW"}
@@ -1 +1 @@
1
- {"version":3,"file":"Server-BX80OVzu.js","names":[],"sources":["../src/components/Server.tsx"],"sourcesContent":["import type { KubbFile } from '@kubb/core/fs'\n\nimport { Const, File, FunctionParams } from '@kubb/react'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams, isOptional } from '@kubb/plugin-oas/utils'\nimport { isNullable, isReference } from '@kubb/oas'\nimport { camelCase } from '@kubb/core/transformers'\n\ntype Props = {\n name: string\n serverName: string\n serverVersion: string\n operations: Array<{\n tool: {\n name: string\n description: string\n }\n mcp: {\n name: string\n file: KubbFile.File\n }\n zod: {\n name: string\n file: KubbFile.File\n schemas: OperationSchemas\n }\n type: {\n schemas: OperationSchemas\n }\n }>\n}\n\ntype GetParamsProps = {\n schemas: OperationSchemas\n}\n\nfunction getParams({ schemas }: GetParamsProps) {\n const pathParams = getPathParams(schemas.pathParams, {\n typed: false,\n })\n\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...Object.entries(pathParams).reduce((acc, [key, param]) => {\n if (param && schemas.pathParams?.name) {\n let suffix = '.shape'\n\n if (isNullable(schemas.pathParams.schema)) {\n if (isReference(schemas.pathParams)) {\n suffix = '.unwrap().schema.unwrap().shape'\n } else {\n suffix = '.unwrap().shape'\n }\n } else {\n if (isReference(schemas.pathParams)) {\n suffix = '.schema.shape'\n }\n }\n\n param.value = `${schemas.pathParams?.name}${suffix}['${key}']`\n }\n\n return {\n ...acc,\n [camelCase(key)]: param,\n }\n }, {}),\n data: schemas.request?.name\n ? {\n value: schemas.request?.name,\n optional: isOptional(schemas.request?.schema),\n }\n : undefined,\n params: schemas.queryParams?.name\n ? {\n value: schemas.queryParams?.name,\n optional: isOptional(schemas.queryParams?.schema),\n }\n : undefined,\n headers: schemas.headerParams?.name\n ? {\n value: schemas.headerParams?.name,\n optional: isOptional(schemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n })\n}\n\nexport function Server({ name, serverName, serverVersion, operations }: Props) {\n return (\n <File.Source name={name} isExportable isIndexable>\n <Const name={'server'} export>\n {`\n new McpServer({\n name: '${serverName}',\n version: '${serverVersion}',\n})\n `}\n </Const>\n\n {operations\n .map(({ tool, mcp, zod }) => {\n const paramsClient = getParams({ schemas: zod.schemas })\n\n if (zod.schemas.request?.name || zod.schemas.headerParams?.name || zod.schemas.queryParams?.name || zod.schemas.pathParams?.name) {\n return `\nserver.tool(${JSON.stringify(tool.name)}, ${JSON.stringify(tool.description)}, ${paramsClient.toObjectValue()}, async (${paramsClient.toObject()}) => {\n return ${mcp.name}(${paramsClient.toObject()})\n})\n `\n }\n\n return `\nserver.tool(${JSON.stringify(tool.name)}, ${JSON.stringify(tool.description)}, async () => {\n return ${mcp.name}(${paramsClient.toObject()})\n})\n `\n })\n .filter(Boolean)}\n\n {`\nasync function startServer() {\n try {\n const transport = new StdioServerTransport()\n await server.connect(transport)\n\n } catch (error) {\n console.error('Failed to start server:', error)\n process.exit(1)\n }\n}\n\nstartServer()\n`}\n </File.Source>\n )\n}\n"],"mappings":";;;;;;;AAoCA,SAAS,UAAU,EAAE,WAA2B;CAC9C,MAAM,aAAa,cAAc,QAAQ,YAAY,EACnD,OAAO;AAGT,QAAO,eAAe,QAAQ,EAC5B,MAAM;EACJ,MAAM;EACN,UAAU;GACR,GAAG,OAAO,QAAQ,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AO;GAET"}
1
+ {"version":3,"file":"Server-BX80OVzu.js","names":[],"sources":["../src/components/Server.tsx"],"sourcesContent":["import type { KubbFile } from '@kubb/core/fs'\n\nimport { Const, File, FunctionParams } from '@kubb/react'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams, isOptional } from '@kubb/plugin-oas/utils'\nimport { isNullable, isReference } from '@kubb/oas'\nimport { camelCase } from '@kubb/core/transformers'\n\ntype Props = {\n name: string\n serverName: string\n serverVersion: string\n operations: Array<{\n tool: {\n name: string\n description: string\n }\n mcp: {\n name: string\n file: KubbFile.File\n }\n zod: {\n name: string\n file: KubbFile.File\n schemas: OperationSchemas\n }\n type: {\n schemas: OperationSchemas\n }\n }>\n}\n\ntype GetParamsProps = {\n schemas: OperationSchemas\n}\n\nfunction getParams({ schemas }: GetParamsProps) {\n const pathParams = getPathParams(schemas.pathParams, {\n typed: false,\n })\n\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...Object.entries(pathParams).reduce((acc, [key, param]) => {\n if (param && schemas.pathParams?.name) {\n let suffix = '.shape'\n\n if (isNullable(schemas.pathParams.schema)) {\n if (isReference(schemas.pathParams)) {\n suffix = '.unwrap().schema.unwrap().shape'\n } else {\n suffix = '.unwrap().shape'\n }\n } else {\n if (isReference(schemas.pathParams)) {\n suffix = '.schema.shape'\n }\n }\n\n param.value = `${schemas.pathParams?.name}${suffix}['${key}']`\n }\n\n return {\n ...acc,\n [camelCase(key)]: param,\n }\n }, {}),\n data: schemas.request?.name\n ? {\n value: schemas.request?.name,\n optional: isOptional(schemas.request?.schema),\n }\n : undefined,\n params: schemas.queryParams?.name\n ? {\n value: schemas.queryParams?.name,\n optional: isOptional(schemas.queryParams?.schema),\n }\n : undefined,\n headers: schemas.headerParams?.name\n ? {\n value: schemas.headerParams?.name,\n optional: isOptional(schemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n })\n}\n\nexport function Server({ name, serverName, serverVersion, operations }: Props) {\n return (\n <File.Source name={name} isExportable isIndexable>\n <Const name={'server'} export>\n {`\n new McpServer({\n name: '${serverName}',\n version: '${serverVersion}',\n})\n `}\n </Const>\n\n {operations\n .map(({ tool, mcp, zod }) => {\n const paramsClient = getParams({ schemas: zod.schemas })\n\n if (zod.schemas.request?.name || zod.schemas.headerParams?.name || zod.schemas.queryParams?.name || zod.schemas.pathParams?.name) {\n return `\nserver.tool(${JSON.stringify(tool.name)}, ${JSON.stringify(tool.description)}, ${paramsClient.toObjectValue()}, async (${paramsClient.toObject()}) => {\n return ${mcp.name}(${paramsClient.toObject()})\n})\n `\n }\n\n return `\nserver.tool(${JSON.stringify(tool.name)}, ${JSON.stringify(tool.description)}, async () => {\n return ${mcp.name}(${paramsClient.toObject()})\n})\n `\n })\n .filter(Boolean)}\n\n {`\nasync function startServer() {\n try {\n const transport = new StdioServerTransport()\n await server.connect(transport)\n\n } catch (error) {\n console.error('Failed to start server:', error)\n process.exit(1)\n }\n}\n\nstartServer()\n`}\n </File.Source>\n )\n}\n"],"mappings":";;;;;;;AAoCA,SAAS,UAAU,EAAE,WAA2B;CAC9C,MAAM,aAAa,cAAc,QAAQ,YAAY,EACnD,OAAO,OACR,CAAC;AAEF,QAAO,eAAe,QAAQ,EAC5B,MAAM;EACJ,MAAM;EACN,UAAU;GACR,GAAG,OAAO,QAAQ,WAAW,CAAC,QAAQ,KAAK,CAAC,KAAK,WAAW;AAC1D,QAAI,SAAS,QAAQ,YAAY,MAAM;KACrC,IAAI,SAAS;AAEb,SAAI,WAAW,QAAQ,WAAW,OAAO,CACvC,KAAI,YAAY,QAAQ,WAAW,CACjC,UAAS;SAET,UAAS;cAGP,YAAY,QAAQ,WAAW,CACjC,UAAS;AAIb,WAAM,QAAQ,GAAG,QAAQ,YAAY,OAAO,OAAO,IAAI,IAAI;;AAG7D,WAAO;KACL,GAAG;MACF,UAAU,IAAI,GAAG;KACnB;MACA,EAAE,CAAC;GACN,MAAM,QAAQ,SAAS,OACnB;IACE,OAAO,QAAQ,SAAS;IACxB,UAAU,WAAW,QAAQ,SAAS,OAAO;IAC9C,GACD;GACJ,QAAQ,QAAQ,aAAa,OACzB;IACE,OAAO,QAAQ,aAAa;IAC5B,UAAU,WAAW,QAAQ,aAAa,OAAO;IAClD,GACD;GACJ,SAAS,QAAQ,cAAc,OAC3B;IACE,OAAO,QAAQ,cAAc;IAC7B,UAAU,WAAW,QAAQ,cAAc,OAAO;IACnD,GACD;GACL;EACF,EACF,CAAC;;AAGJ,SAAgB,OAAO,EAAE,MAAM,YAAY,eAAe,cAAqB;AAC7E,QACE,qBAAC,KAAK;EAAa;EAAM;EAAa;;GACpC,oBAAC;IAAM,MAAM;IAAU;cACpB;;WAEE,WAAW;cACR,cAAc;;;KAGd;GAEP,WACE,KAAK,EAAE,MAAM,KAAK,UAAU;IAC3B,MAAM,eAAe,UAAU,EAAE,SAAS,IAAI,SAAS,CAAC;AAExD,QAAI,IAAI,QAAQ,SAAS,QAAQ,IAAI,QAAQ,cAAc,QAAQ,IAAI,QAAQ,aAAa,QAAQ,IAAI,QAAQ,YAAY,KAC1H,QAAO;cACL,KAAK,UAAU,KAAK,KAAK,CAAC,IAAI,KAAK,UAAU,KAAK,YAAY,CAAC,IAAI,aAAa,eAAe,CAAC,WAAW,aAAa,UAAU,CAAC;WACtI,IAAI,KAAK,GAAG,aAAa,UAAU,CAAC;;;AAKrC,WAAO;cACH,KAAK,UAAU,KAAK,KAAK,CAAC,IAAI,KAAK,UAAU,KAAK,YAAY,CAAC;WAClE,IAAI,KAAK,GAAG,aAAa,UAAU,CAAC;;;KAGrC,CACD,OAAO,QAAQ;GAEjB;;;;;;;;;;;;;;;GAcW"}
@@ -1,3 +1,3 @@
1
- const require_Server = require('./Server-Bh-nULhJ.cjs');
1
+ const require_Server = require('./Server-AWXKgK_d.cjs');
2
2
 
3
3
  exports.Server = require_Server.Server;
@@ -1,12 +1,20 @@
1
- const require_Server = require('./Server-Bh-nULhJ.cjs');
2
- const __kubb_plugin_oas = require_Server.__toESM(require("@kubb/plugin-oas"));
3
- const __kubb_plugin_ts = require_Server.__toESM(require("@kubb/plugin-ts"));
4
- const __kubb_plugin_oas_hooks = require_Server.__toESM(require("@kubb/plugin-oas/hooks"));
5
- const __kubb_plugin_oas_utils = require_Server.__toESM(require("@kubb/plugin-oas/utils"));
6
- const __kubb_react = require_Server.__toESM(require("@kubb/react"));
7
- const __kubb_plugin_client_components = require_Server.__toESM(require("@kubb/plugin-client/components"));
8
- const __kubb_react_jsx_runtime = require_Server.__toESM(require("@kubb/react/jsx-runtime"));
9
- const __kubb_plugin_zod = require_Server.__toESM(require("@kubb/plugin-zod"));
1
+ const require_Server = require('./Server-AWXKgK_d.cjs');
2
+ let __kubb_plugin_oas = require("@kubb/plugin-oas");
3
+ __kubb_plugin_oas = require_Server.__toESM(__kubb_plugin_oas);
4
+ let __kubb_plugin_ts = require("@kubb/plugin-ts");
5
+ __kubb_plugin_ts = require_Server.__toESM(__kubb_plugin_ts);
6
+ let __kubb_plugin_oas_hooks = require("@kubb/plugin-oas/hooks");
7
+ __kubb_plugin_oas_hooks = require_Server.__toESM(__kubb_plugin_oas_hooks);
8
+ let __kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
9
+ __kubb_plugin_oas_utils = require_Server.__toESM(__kubb_plugin_oas_utils);
10
+ let __kubb_react = require("@kubb/react");
11
+ __kubb_react = require_Server.__toESM(__kubb_react);
12
+ let __kubb_plugin_client_components = require("@kubb/plugin-client/components");
13
+ __kubb_plugin_client_components = require_Server.__toESM(__kubb_plugin_client_components);
14
+ let __kubb_react_jsx_runtime = require("@kubb/react/jsx-runtime");
15
+ __kubb_react_jsx_runtime = require_Server.__toESM(__kubb_react_jsx_runtime);
16
+ let __kubb_plugin_zod = require("@kubb/plugin-zod");
17
+ __kubb_plugin_zod = require_Server.__toESM(__kubb_plugin_zod);
10
18
 
11
19
  //#region src/generators/mcpGenerator.tsx
12
20
  const mcpGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
@@ -233,4 +241,4 @@ Object.defineProperty(exports, 'serverGenerator', {
233
241
  return serverGenerator;
234
242
  }
235
243
  });
236
- //# sourceMappingURL=generators-UZiEnnoX.cjs.map
244
+ //# sourceMappingURL=generators-C6GGdP_U.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"generators-UZiEnnoX.cjs","names":["pluginTsName","File","Client","pluginZodName","pluginTsName","File","Server"],"sources":["../src/generators/mcpGenerator.tsx","../src/generators/serverGenerator.tsx"],"sourcesContent":["import { 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, useApp } from '@kubb/react'\nimport type { PluginMcp } from '../types'\nimport { Client } from '@kubb/plugin-client/components'\n\nexport const mcpGenerator = createReactGenerator<PluginMcp>({\n name: 'mcp',\n Operation({ operation }) {\n const {\n plugin: { options },\n } = useApp<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 { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, useApp } from '@kubb/react'\nimport { Server } from '../components/Server'\nimport type { PluginMcp } from '../types'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nexport const serverGenerator = createReactGenerator<PluginMcp>({\n name: 'operations',\n Operations({ operations, options }) {\n const { pluginManager, plugin } = useApp<PluginMcp>()\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":";;;;;;;;;;;AAQA,MAAa,2DAA+C;CAC1D,MAAM;CACN,UAAU,EAAE,aAAa;EACvB,MAAM,EACJ,QAAQ,EAAE;EAEZ,MAAM;EACN,MAAM,EAAE,YAAY,SAAS;EAE7B,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;;GACrD,MAAM,QAAQ;;EAGhB,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAACA;GACvC,SAAS,WAAW,WAAW;IAAE,WAAW,CAACA;IAAe,MAAM;;;A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AAM;KAAO,eAAe,IAAI;KAAc,YAAY;;;MAGpG,kDAACD;GAAK,UAAU,SAAS;GAAU,MAAM,SAAS;GAAM,MAAM,SAAS;aACrE,kDAACA,kBAAK;IAAa;cAChB;;;iBAGI,IAAI,IAAI,MAAM,SAAS,SAAS;;;mCAGd,KAAK,KAAK"}
1
+ {"version":3,"file":"generators-C6GGdP_U.cjs","names":["pluginTsName","File","Client","pluginZodName","pluginTsName","File","Server"],"sources":["../src/generators/mcpGenerator.tsx","../src/generators/serverGenerator.tsx"],"sourcesContent":["import { 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, useApp } from '@kubb/react'\nimport type { PluginMcp } from '../types'\nimport { Client } from '@kubb/plugin-client/components'\n\nexport const mcpGenerator = createReactGenerator<PluginMcp>({\n name: 'mcp',\n Operation({ operation }) {\n const {\n plugin: { options },\n } = useApp<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 { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, useApp } from '@kubb/react'\nimport { Server } from '../components/Server'\nimport type { PluginMcp } from '../types'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nexport const serverGenerator = createReactGenerator<PluginMcp>({\n name: 'operations',\n Operations({ operations, options }) {\n const { pluginManager, plugin } = useApp<PluginMcp>()\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":";;;;;;;;;;;;;;;;;;;AAQA,MAAa,2DAA+C;CAC1D,MAAM;CACN,UAAU,EAAE,aAAa;EACvB,MAAM,EACJ,QAAQ,EAAE,wCACW;EACvB,MAAM,2CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,8DAAiC;EAE9D,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;IAAW,CAAC;GACjE,MAAM,QAAQ,UAAU;GACzB;EAED,MAAM,OAAO;GACX,M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AAQ,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 +1 @@
1
- {"version":3,"file":"generators-CFdUB1k-.js","names":[],"sources":["../src/generators/mcpGenerator.tsx","../src/generators/serverGenerator.tsx"],"sourcesContent":["import { 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, useApp } from '@kubb/react'\nimport type { PluginMcp } from '../types'\nimport { Client } from '@kubb/plugin-client/components'\n\nexport const mcpGenerator = createReactGenerator<PluginMcp>({\n name: 'mcp',\n Operation({ operation }) {\n const {\n plugin: { options },\n } = useApp<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 { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, useApp } from '@kubb/react'\nimport { Server } from '../components/Server'\nimport type { PluginMcp } from '../types'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nexport const serverGenerator = createReactGenerator<PluginMcp>({\n name: 'operations',\n Operations({ operations, options }) {\n const { pluginManager, plugin } = useApp<PluginMcp>()\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":";;;;;;;;;;;AAQA,MAAa,eAAe,qBAAgC;CAC1D,MAAM;CACN,UAAU,EAAE,aAAa;EACvB,MAAM,EACJ,QAAQ,EAAE,cACR;EACJ,MAAM,MAAM;EACZ,MAAM,EAAE,YAAY,SAAS,YAAY;EAEzC,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;;GACrD,MAAM,QAAQ;;EAGhB,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAAC;GACvC,SAAS,WAAW,WAAW;IAAE,WAAW,CAAC;IAAe,MAAM;;;AAGpE,SACE,qBAAC;GACC,UAAU,IAAI,KAAK;GACnB,MAAM,IAAI,KAAK;GACf,MAAM,IAAI,KAAK;GACf,QAAQ,UAAU;IAAE;IAAK,QAAQ,QAAQ;;GACzC,QAAQ,UAAU;IAAE;IAAK,QAAQ,QAAQ;;;IAEzC,oBAAC,KAAK;KAAO,MAAM,CAAC;KAAmB,MAAM;KAAmC;;IAChF,oBAAC,KAAK;KAAO,MAAM;KAAS,MAAM,QAAQ,OAAO;;IACjD,oBAAC,KAAK;KAAO,MAAM,CAAC,iBAAiB;KAAwB,MAAM,QAAQ,OAAO;KAAY;;IAC9F,oBAAC,KAAK;KACJ,MAAM;MACJ,KAAK,QAAQ,SAAS;MACtB,KAAK,QAAQ,SAAS;MACtB,KAAK,QAAQ,YAAY;MACzB,KAAK,QAAQ,aAAa;MAC1B,KAAK,QAAQ,cAAc;MAC3B,GAAI,KAAK,QAAQ,aAAa,KAAK,SAAS,KAAK,SAAS;OAC1D,OAAO;KACT,MAAM,IAAI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AAO,CACL,oBAAC,KAAK;IAAsB,MAAM,CAAC,IAAI;IAAO,MAAM,KAAK;IAAM,MAAM,IAAI,KAAK;MAA5D,IAAI,OACtB,oBAAC,KAAK;IAEJ,MAAM;KAAC,IAAI,QAAQ,SAAS;KAAM,IAAI,QAAQ,YAAY;KAAM,IAAI,QAAQ,aAAa;KAAM,IAAI,QAAQ,cAAc;MAAM,OAAO;IACtI,MAAM,KAAK;IACX,MAAM,IAAI,KAAK;MAHV,IAAI;;AAQf,SACE,4CACE,qBAAC;GACC,UAAU,KAAK;GACf,MAAM,KAAK;GACX,MAAM,KAAK;GACX,QAAQ,UAAU;IAAE;IAAK,QAAQ,QAAQ;IAAQ,QAAQ,cAAc;;GACvE,QAAQ,UAAU;IAAE;IAAK,QAAQ,QAAQ;;;IAEzC,oBAAC,KAAK;KAAO,MAAM,CAAC;KAAc,MAAM;;IACxC,oBAAC,KAAK;KAAO,MAAM,CAAC;KAAyB,MAAM;;IAElD;IACD,oBAAC;KAAa;KAAM,YAAY,IAAI,IAAI,MAAM;KAAO,eAAe,IAAI;KAAc,YAAY;;;MAGpG,oBAAC;GAAK,UAAU,SAAS;GAAU,MAAM,SAAS;GAAM,MAAM,SAAS;aACrE,oBAAC,KAAK;IAAa;cAChB;;;iBAGI,IAAI,IAAI,MAAM,SAAS,SAAS;;;mCAGd,KAAK,KAAK"}
1
+ {"version":3,"file":"generators-CFdUB1k-.js","names":[],"sources":["../src/generators/mcpGenerator.tsx","../src/generators/serverGenerator.tsx"],"sourcesContent":["import { 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, useApp } from '@kubb/react'\nimport type { PluginMcp } from '../types'\nimport { Client } from '@kubb/plugin-client/components'\n\nexport const mcpGenerator = createReactGenerator<PluginMcp>({\n name: 'mcp',\n Operation({ operation }) {\n const {\n plugin: { options },\n } = useApp<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 { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, useApp } from '@kubb/react'\nimport { Server } from '../components/Server'\nimport type { PluginMcp } from '../types'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nexport const serverGenerator = createReactGenerator<PluginMcp>({\n name: 'operations',\n Operations({ operations, options }) {\n const { pluginManager, plugin } = useApp<PluginMcp>()\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":";;;;;;;;;;;AAQA,MAAa,eAAe,qBAAgC;CAC1D,MAAM;CACN,UAAU,EAAE,aAAa;EACvB,MAAM,EACJ,QAAQ,EAAE,cACR,QAAmB;EACvB,MAAM,MAAM,QAAQ;EACpB,MAAM,EAAE,YAAY,SAAS,YAAY,qBAAqB;EAE9D,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;IAAW,CAAC;GACjE,MAAM,QAAQ,UAAU;GACzB;EAED,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAAC,aAAa,EAAE,CAAC;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAAC,aAAa;IAAE,MAAM;IAAQ,CAAC;GAC5E;AAED,SACE,qBAAC;GACC,UAAU,IAAI,KAAK;GACnB,MAAM,IAAI,KAAK;GACf,MAAM,IAAI,KAAK;GACf,QAAQ,UAAU;IAAE;IAAK,QAAQ,QAAQ;IAAQ,CAAC;GAClD,QAAQ,UAAU;IAAE;IAAK,QAAQ,QAAQ;IAAQ,CAAC;;IAElD,oBAAC,KAAK;KAAO,MAAM,CAAC,iBAAiB;KAAE,MAAM;KAAmC;MAAa;IAC7F,oBAAC,KAAK;KAAO,MAAM;KAAS,MAAM,QAAQ,OAAO;MAAc;IAC/D,oBAAC,KAAK;KAAO,MAAM,CAAC,iBAAiB,sBAAsB;KAAE,MAAM,QAAQ,OAAO;KAAY;MAAa;IAC3G,oBAAC,KAAK;KACJ,MAAM;MACJ,KAAK,QA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AAK,UAAU,SAAS;GAAU,MAAM,SAAS;GAAM,MAAM,SAAS;aACrE,oBAAC,KAAK;IAAa;cAChB;;;iBAGI,IAAI,IAAI,MAAM,SAAS,SAAS;;;mCAGd,KAAK,KAAK;;;;;KAKrB;IACT,IACN;;CAGR,CAAC"}
@@ -1,5 +1,5 @@
1
- require('./Server-Bh-nULhJ.cjs');
2
- const require_generators = require('./generators-UZiEnnoX.cjs');
1
+ require('./Server-AWXKgK_d.cjs');
2
+ const require_generators = require('./generators-C6GGdP_U.cjs');
3
3
 
4
4
  exports.mcpGenerator = require_generators.mcpGenerator;
5
5
  exports.serverGenerator = require_generators.serverGenerator;
package/dist/index.cjs CHANGED
@@ -1,11 +1,17 @@
1
- const require_Server = require('./Server-Bh-nULhJ.cjs');
2
- const require_generators = require('./generators-UZiEnnoX.cjs');
3
- const node_path = require_Server.__toESM(require("node:path"));
4
- const __kubb_core = require_Server.__toESM(require("@kubb/core"));
5
- const __kubb_core_transformers = require_Server.__toESM(require("@kubb/core/transformers"));
6
- const __kubb_plugin_oas = require_Server.__toESM(require("@kubb/plugin-oas"));
7
- const __kubb_plugin_ts = require_Server.__toESM(require("@kubb/plugin-ts"));
8
- const __kubb_plugin_zod = require_Server.__toESM(require("@kubb/plugin-zod"));
1
+ const require_Server = require('./Server-AWXKgK_d.cjs');
2
+ const require_generators = require('./generators-C6GGdP_U.cjs');
3
+ let node_path = require("node:path");
4
+ node_path = require_Server.__toESM(node_path);
5
+ let __kubb_core = require("@kubb/core");
6
+ __kubb_core = require_Server.__toESM(__kubb_core);
7
+ let __kubb_core_transformers = require("@kubb/core/transformers");
8
+ __kubb_core_transformers = require_Server.__toESM(__kubb_core_transformers);
9
+ let __kubb_plugin_oas = require("@kubb/plugin-oas");
10
+ __kubb_plugin_oas = require_Server.__toESM(__kubb_plugin_oas);
11
+ let __kubb_plugin_ts = require("@kubb/plugin-ts");
12
+ __kubb_plugin_ts = require_Server.__toESM(__kubb_plugin_ts);
13
+ let __kubb_plugin_zod = require("@kubb/plugin-zod");
14
+ __kubb_plugin_zod = require_Server.__toESM(__kubb_plugin_zod);
9
15
 
10
16
  //#region src/plugin.ts
11
17
  const pluginMcpName = "plugin-mcp";
@@ -32,8 +38,7 @@ const pluginMcp = (0, __kubb_core.createPlugin)((options) => {
32
38
  ].filter(Boolean),
33
39
  resolvePath(baseName, pathMode, options$1) {
34
40
  const root = node_path.default.resolve(this.config.root, this.config.output.path);
35
- const mode = pathMode ?? __kubb_core.FileManager.getMode(node_path.default.resolve(root, output.path));
36
- if (mode === "single")
41
+ if ((pathMode ?? __kubb_core.FileManager.getMode(node_path.default.resolve(root, output.path))) === "single")
37
42
  /**
38
43
  * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
39
44
  * Other plugins then need to call addOrAppend instead of just add from the fileManager class
@@ -58,7 +63,7 @@ const pluginMcp = (0, __kubb_core.createPlugin)((options) => {
58
63
  const oas = await swaggerPlugin.context.getOas();
59
64
  const root = node_path.default.resolve(this.config.root, this.config.output.path);
60
65
  const mode = __kubb_core.FileManager.getMode(node_path.default.resolve(root, output.path));
61
- const operationGenerator = new __kubb_plugin_oas.OperationGenerator(this.plugin.options, {
66
+ const files = await new __kubb_plugin_oas.OperationGenerator(this.plugin.options, {
62
67
  oas,
63
68
  pluginManager: this.pluginManager,
64
69
  plugin: this.plugin,
@@ -67,8 +72,7 @@ const pluginMcp = (0, __kubb_core.createPlugin)((options) => {
67
72
  include,
68
73
  override,
69
74
  mode
70
- });
71
- const files = await operationGenerator.build(...generators);
75
+ }).build(...generators);
72
76
  await this.addFile(...files);
73
77
  const barrelFiles = await this.fileManager.getBarrelFiles({
74
78
  type: output.barrelType ?? "named",
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["mcpGenerator","serverGenerator","pluginOasName","pluginTsName","pluginZodName","path","FileManager","options","groupName: Group['name']","PluginManager","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { mcpGenerator, serverGenerator } from './generators'\nimport type { PluginMcp } from './types.ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\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 ?? FileManager.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 = FileManager.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 this.fileManager.getBarrelFiles({\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":";;;;;;;;;;AAaA,MAAa,gBAAgB;AAE7B,MAAa,2CAAqC,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAO,YAAY;IACpC,OACA,UAAU,IACV,SACA,WAAW,IACX,eAAe,IACf,aAAa,CAACA,iCAAcC,oCAAiB,OAAO,UACpD,gBACE;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA,QAAQ;IACN,YAAY;IACZ,gBAAgB;IAChB,GAAG,QAAQ;;;EAGf,KAAK;GAACC;GAAeC;GAAcC;IAAe,OAAO;EACzD,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAOC,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO;GAC/D,MAAM,OAAO,YAAYC,wBAAY,QAAQD,kBAAK,QAAQ,MAAM,OAAO;AAEvE,OAAI,SAAS;;;;;AAKX,UAAOA,kBAAK,QAAQ,MAAM,OAAO;AAGnC,OAAI,UAAUE,WAAS,OAAO,QAAQA,WAAS,OAAO,MAAM;IAC1D,MAAMC,YAA2B,OAAO,OACpC,MAAM,QACL,QAAQ;AACP,SAAI,OAAO,SAAS,OAClB,QAAO,GAAG,IAAI,MAAM,MAAM,KAAK;AAEjC,YAAO,2CAAa,IAAI,OAAO;;AAGrC,WAAOH,kBAAK,QACV,MACA,OAAO,MACP,UAAU,EACR,OAAO,MAAM,SAAS,SAASE,UAAQ,MAAM,OAAQA,UAAQ,MAAM,QAErE;;AAIJ,UAAOF,kBAAK,QAAQ,MAAM,OAAO,MAAM;;EAEzC,YAAY,MAAM,MAAM;GACtB,MAAM,uDAAyB,MAAM,EACnC,QAAQ,SAAS;AAGnB,OAAI,KACF,QAAO,cAAc,OAAO,cAAc,SAAS;AAGrD,UAAO;;EAET,MAAM,aAAa;GACjB,MAAM,CAAC,iBAAiDI,0BAAc,mBAAyC,KAAK,SAAS,CAACP;GAE9H,MAAM,MAAM,MAAM,cAAc,QAAQ;GACxC,MAAM,OAAOG,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO;GAC/D,MAAM,OAAOC,wBAAY,QAAQD,kBAAK,QAAQ,MAAM,OAAO;GAE3D,MAAM,qBAAqB,IAAIK,qCAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;;GAGF,MAAM,QAAQ,MAAM,mBAAmB,MAAM,GAAG;AAChD,SAAM,KAAK,QAAQ,GAAG;GAEtB,MAAM,cAAc,MAAM,KAAK,YAAY,eAAe;IACxD,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO;IAEzB,QAAQ,KAAK;;AAGf,SAAM,KAAK,QAAQ,GAAG"}
1
+ {"version":3,"file":"index.cjs","names":["mcpGenerator","serverGenerator","pluginOasName","pluginTsName","pluginZodName","path","FileManager","options","groupName: Group['name']","PluginManager","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { mcpGenerator, serverGenerator } from './generators'\nimport type { PluginMcp } from './types.ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\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 ?? FileManager.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 = FileManager.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 this.fileManager.getBarrelFiles({\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":";;;;;;;;;;;;;;;;AAaA,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,YAAYC,wBAAY,QAAQD,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEhE;;;;;AAKX,UAAOA,kBAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC,OAAI,UAAUE,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,2CAAa,IAAI,MAAM,CAAC;;AAGrC,WAAOH,kBAAK,QACV,MACA,OAAO,MACP,UAAU,EACR,OAAO,MAAM,SAAS,SAASE,UAAQ,MAAM,OAAQA,UAAQ,MAAM,KACpE,CAAC,EACF,SACD;;AAGH,UAAOF,kBAAK,QAAQ,MAAM,OAAO,MAAM,SAAS;;EAElD,YAAY,MAAM,MAAM;GACtB,MAAM,uDAAyB,MAAM,EACnC,QAAQ,SAAS,QAClB,CAAC;AAEF,OAAI,KACF,QAAO,cAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;;EAET,MAAM,aAAa;GACjB,MAAM,CAAC,iBAAiDI,0BAAc,mBAAyC,KAAK,SAAS,CAACP,gCAAc,CAAC;GAE7I,MAAM,MAAM,MAAM,cAAc,QAAQ,QAAQ;GAChD,MAAM,OAAOG,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,OAAOC,wBAAY,QAAQD,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GAajE,MAAM,QAAQ,MAXa,IAAIK,qCAAmB,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,KAAK,YAAY,eAAe;IACxD,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"}
package/dist/index.js CHANGED
@@ -32,8 +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
- const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
36
- if (mode === "single")
35
+ if ((pathMode ?? FileManager.getMode(path.resolve(root, output.path))) === "single")
37
36
  /**
38
37
  * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
39
38
  * Other plugins then need to call addOrAppend instead of just add from the fileManager class
@@ -58,7 +57,7 @@ const pluginMcp = createPlugin((options) => {
58
57
  const oas = await swaggerPlugin.context.getOas();
59
58
  const root = path.resolve(this.config.root, this.config.output.path);
60
59
  const mode = FileManager.getMode(path.resolve(root, output.path));
61
- const operationGenerator = new OperationGenerator(this.plugin.options, {
60
+ const files = await new OperationGenerator(this.plugin.options, {
62
61
  oas,
63
62
  pluginManager: this.pluginManager,
64
63
  plugin: this.plugin,
@@ -67,8 +66,7 @@ const pluginMcp = createPlugin((options) => {
67
66
  include,
68
67
  override,
69
68
  mode
70
- });
71
- const files = await operationGenerator.build(...generators);
69
+ }).build(...generators);
72
70
  await this.addFile(...files);
73
71
  const barrelFiles = await this.fileManager.getBarrelFiles({
74
72
  type: output.barrelType ?? "named",
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'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { mcpGenerator, serverGenerator } from './generators'\nimport type { PluginMcp } from './types.ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\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 ?? FileManager.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 = FileManager.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 this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })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cAAc,QAAQ;GACxC,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO;GAC/D,MAAM,OAAO,YAAY,QAAQ,KAAK,QAAQ,MAAM,OAAO;GAE3D,MAAM,qBAAqB,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;;GAGF,MAAM,QAAQ,MAAM,mBAAmB,MAAM,GAAG;AAChD,SAAM,KAAK,QAAQ,GAAG;GAEtB,MAAM,cAAc,MAAM,KAAK,YAAY,eAAe;IACxD,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO;IAEzB,QAAQ,KAAK;;AAGf,SAAM,KAAK,QAAQ,GAAG"}
1
+ {"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { mcpGenerator, serverGenerator } from './generators'\nimport type { PluginMcp } from './types.ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\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 ?? FileManager.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 = FileManager.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 this.fileManager.getBarrelFiles({\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":";;;;;;;;;;AAaA,MAAa,gBAAgB;AAE7B,MAAa,YAAY,cAAyB,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAO,YAAY;EAAS,EAC7C,OACA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AQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,OAAO,YAAY,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GAajE,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,KAAK,YAAY,eAAe;IACxD,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-mcp",
3
- "version": "3.18.3",
3
+ "version": "4.0.0",
4
4
  "description": "Generator mcp",
5
5
  "keywords": [
6
6
  "typescript",
@@ -62,23 +62,23 @@
62
62
  "!/**/__tests__/**"
63
63
  ],
64
64
  "dependencies": {
65
- "@kubb/core": "3.18.3",
66
- "@kubb/oas": "3.18.3",
67
- "@kubb/plugin-client": "3.18.3",
68
- "@kubb/plugin-oas": "3.18.3",
69
- "@kubb/plugin-ts": "3.18.3",
70
- "@kubb/plugin-zod": "3.18.3",
71
- "@kubb/react": "3.18.3"
65
+ "@kubb/core": "4.0.0",
66
+ "@kubb/oas": "4.0.0",
67
+ "@kubb/plugin-client": "4.0.0",
68
+ "@kubb/plugin-oas": "4.0.0",
69
+ "@kubb/plugin-ts": "4.0.0",
70
+ "@kubb/plugin-zod": "4.0.0",
71
+ "@kubb/react": "4.0.0"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@types/react": "^18.3.24",
75
75
  "react": "^18.3.1",
76
76
  "tsdown": "^0.14.2",
77
77
  "typescript": "^5.9.2",
78
- "@kubb/config-ts": "3.18.3"
78
+ "@kubb/config-ts": "4.0.0"
79
79
  },
80
80
  "peerDependencies": {
81
- "@kubb/react": "^3.0.0"
81
+ "@kubb/react": "^4.0.0"
82
82
  },
83
83
  "engines": {
84
84
  "node": ">=20"