@kubb/mcp 3.10.1 → 3.10.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.
@@ -16,7 +16,7 @@ var process2__default = /*#__PURE__*/_interopDefault(process2);
16
16
  // src/index.ts
17
17
 
18
18
  // package.json
19
- var version = "3.10.1";
19
+ var version = "3.10.2";
20
20
  var generateSchema = zod.z.object({
21
21
  openApi: zod.z.string().default("https://petstore.swagger.io/v2/swagger.json").describe("OpenAPI/Swagger spec"),
22
22
  plugin: zod.z.enum(["typescript", "react-query"]).describe("Plugin to use"),
@@ -74,6 +74,10 @@ async function generate({ plugin, openApi, operationId }) {
74
74
  isError: true
75
75
  };
76
76
  }
77
+ const promises = files.map(async (file) => {
78
+ return await core.getSource(file, { extname: ".ts" });
79
+ });
80
+ const sources = await Promise.all(promises);
77
81
  return {
78
82
  content: [
79
83
  // {
@@ -86,11 +90,7 @@ async function generate({ plugin, openApi, operationId }) {
86
90
  },
87
91
  {
88
92
  type: "text",
89
- text: `Files: ${JSON.stringify(
90
- files.flatMap((file) => file.sources).map((source) => source.value).join("\n\n"),
91
- null,
92
- 2
93
- )}`
93
+ text: `Files: ${JSON.stringify(sources, null, 2)}`
94
94
  }
95
95
  ]
96
96
  };
@@ -126,5 +126,5 @@ async function startServer() {
126
126
 
127
127
  exports.server = server;
128
128
  exports.startServer = startServer;
129
- //# sourceMappingURL=chunk-A4QFMFDL.cjs.map
130
- //# sourceMappingURL=chunk-A4QFMFDL.cjs.map
129
+ //# sourceMappingURL=chunk-VK5RZRTZ.cjs.map
130
+ //# sourceMappingURL=chunk-VK5RZRTZ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../package.json","../src/schemas/generateSchema.ts","../src/tools/generate.ts","../src/index.ts"],"names":["z","pluginOas","pluginTs","pluginReactQuery","safeBuild","getSource","McpServer","StdioServerTransport","process"],"mappings":";;;;;;;;;;;;;;;;;;AAEE,IAAW,OAAA,GAAA,QAA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AAM,KAAM,CAAA;AAAA;AACd,OACF;AAAA,MACA,OAAS,EAAA;AAAA,KACX;AAAA;AAEJ;;;AC7Fa,IAAA,MAAA,GAAS,IAAIC,gBAAU,CAAA;AAAA,EAClC,IAAM,EAAA,MAAA;AAAA,EACN;AACF,CAAC;AAED,MAAA,CAAO,IAAK,CAAA,UAAA,EAAY,4CAA8C,EAAA,cAAA,CAAe,OAAO,QAAQ,CAAA;AAEpG,eAAsB,WAAc,GAAA;AAClC,EAAI,IAAA;AACF,IAAM,MAAA,SAAA,GAAY,IAAIC,6BAAqB,EAAA;AAC3C,IAAM,MAAA,MAAA,CAAO,QAAQ,SAAS,CAAA;AAAA,WACvB,KAAO,EAAA;AACd,IAAQ,OAAA,CAAA,KAAA,CAAM,2BAA2B,KAAK,CAAA;AAC9C,IAAAC,yBAAAA,CAAQ,KAAK,CAAC,CAAA;AAAA;AAElB","file":"chunk-VK5RZRTZ.cjs","sourcesContent":["{\n \"name\": \"@kubb/mcp\",\n \"version\": \"3.10.2\",\n \"description\": \"Generator MCP\",\n \"keywords\": [\n \"typescript\",\n \"plugins\",\n \"kubb\",\n \"codegen\",\n \"MCP\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/kubb-labs/kubb.git\",\n \"directory\": \"packages/mcp\"\n },\n \"license\": \"MIT\",\n \"author\": \"stijnvanhulle\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.cjs\"\n },\n \"./server\": {\n \"import\": \"./dist/server.js\",\n \"require\": \"./dist/server.cjs\",\n \"default\": \"./dist/server.cjs\"\n }\n },\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"server\": [\n \"./dist/server.d.ts\"\n ]\n }\n },\n \"files\": [\n \"src\",\n \"dist\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"start:mcp\": \"bun --watch ./src/server.ts\",\n \"debug:mcp\": \"npx -y @modelcontextprotocol/inspector node ./dist/server.js\",\n \"clean\": \"npx rimraf ./dist\",\n \"lint\": \"bun biome lint .\",\n \"lint:fix\": \"bun biome lint --apply-unsafe .\",\n \"release\": \"pnpm publish --no-git-check\",\n \"release:canary\": \"bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check\",\n \"start\": \"tsup --watch\",\n \"test\": \"vitest --passWithNoTests\",\n \"typecheck\": \"tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false\"\n },\n \"dependencies\": {\n \"@kubb/core\": \"workspace:*\",\n \"@kubb/plugin-client\": \"workspace:*\",\n \"@kubb/plugin-cypress\": \"workspace:*\",\n \"@kubb/plugin-faker\": \"workspace:*\",\n \"@kubb/plugin-mcp\": \"workspace:*\",\n \"@kubb/plugin-msw\": \"workspace:*\",\n \"@kubb/plugin-oas\": \"workspace:*\",\n \"@kubb/plugin-react-query\": \"workspace:*\",\n \"@kubb/plugin-redoc\": \"workspace:*\",\n \"@kubb/plugin-swr\": \"workspace:*\",\n \"@kubb/plugin-ts\": \"workspace:*\",\n \"@kubb/plugin-zod\": \"workspace:*\",\n \"@kubb/react\": \"workspace:*\",\n \"@modelcontextprotocol/sdk\": \"^1.10.2\",\n \"zod\": \"^3.24.3\"\n },\n \"devDependencies\": {\n \"@kubb/config-ts\": \"workspace:*\",\n \"@kubb/config-tsup\": \"workspace:*\",\n \"@kubb/plugin-oas\": \"workspace:*\",\n \"@types/node\": \"catalog:\",\n \"@types/react\": \"catalog:\",\n \"tsup\": \"catalog:\",\n \"typescript\": \"catalog:\"\n },\n \"engines\": {\n \"node\": \">=20\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org/\"\n }\n}\n","import { z } from 'zod'\n\nexport const generateSchema = z.object({\n openApi: z.string().default('https://petstore.swagger.io/v2/swagger.json').describe('OpenAPI/Swagger spec'),\n plugin: z.enum(['typescript', 'react-query']).describe('Plugin to use'),\n operationId: z.string().nullable().optional().describe('Which operationId should be used'),\n // schemaName: z.string().nullable().optional().describe('Which schema should be used'),\n})\n","import { pluginTs } from '@kubb/plugin-ts'\nimport { type Include, pluginOas } from '@kubb/plugin-oas'\nimport { pluginReactQuery } from '@kubb/plugin-react-query'\n\nimport { type Config, safeBuild, type Plugin, getSource } from '@kubb/core'\nimport type { generateSchema } from '../schemas/generateSchema.ts'\nimport type { z } from 'zod'\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.d.ts'\n\nexport async function generate({ plugin, openApi, operationId }: z.infer<typeof generateSchema>): Promise<CallToolResult> {\n try {\n const include = [\n operationId\n ? {\n type: 'operationId',\n pattern: operationId,\n }\n : undefined,\n ].filter(Boolean) as Include[]\n\n const plugins = [\n pluginOas({ validate: false, generators: [] }),\n pluginTs({\n output: {\n path: 'typescript.ts',\n },\n generators: plugin === 'typescript' ? undefined : [],\n include,\n }),\n pluginReactQuery({\n output: {\n path: 'react-query.ts',\n },\n generators: plugin === 'react-query' ? undefined : [],\n include,\n }),\n ].filter(Boolean) as Plugin[]\n\n const definedConfig: Config = {\n root: process.cwd(),\n input: {\n data: openApi,\n },\n output: {\n path: './',\n write: false,\n barrelType: 'named',\n },\n plugins,\n }\n\n const { files, error } = await safeBuild({\n config: definedConfig,\n })\n\n if (error) {\n return {\n content: [\n {\n type: 'text',\n text: error.message,\n },\n ],\n isError: true,\n }\n }\n\n const promises = files.map(async (file) => {\n return await getSource(file, { extname: '.ts' })\n })\n\n const sources = await Promise.all(promises)\n\n return {\n content: [\n // {\n // type: 'resource',\n // resource: {}\n // },\n {\n type: 'text',\n text: `Config: ${JSON.stringify(definedConfig, null, 2)}`,\n },\n {\n type: 'text',\n text: `Files: ${JSON.stringify(sources, null, 2)}`,\n },\n ],\n }\n } catch (e) {\n const error = e as Error\n\n return {\n content: [\n {\n type: 'text',\n text: error.message,\n },\n ],\n isError: true,\n }\n }\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\n\nimport { version } from '../package.json'\n\nimport process from 'node:process'\nimport { generateSchema } from './schemas/generateSchema.ts'\nimport { generate } from './tools/generate.ts'\n\nexport const server = new McpServer({\n name: 'Kubb',\n version,\n})\n\nserver.tool('generate', 'generate an openAPI spec to a code snippet', generateSchema.shape, generate)\n\nexport async function startServer() {\n try {\n const transport = new StdioServerTransport()\n await server.connect(transport)\n } catch (error) {\n console.error('Failed to start server:', error)\n process.exit(1)\n }\n}\n"]}
@@ -5,12 +5,12 @@ import { z } from 'zod';
5
5
  import { pluginTs } from '@kubb/plugin-ts';
6
6
  import { pluginOas } from '@kubb/plugin-oas';
7
7
  import { pluginReactQuery } from '@kubb/plugin-react-query';
8
- import { safeBuild } from '@kubb/core';
8
+ import { safeBuild, getSource } from '@kubb/core';
9
9
 
10
10
  // src/index.ts
11
11
 
12
12
  // package.json
13
- var version = "3.10.1";
13
+ var version = "3.10.2";
14
14
  var generateSchema = z.object({
15
15
  openApi: z.string().default("https://petstore.swagger.io/v2/swagger.json").describe("OpenAPI/Swagger spec"),
16
16
  plugin: z.enum(["typescript", "react-query"]).describe("Plugin to use"),
@@ -68,6 +68,10 @@ async function generate({ plugin, openApi, operationId }) {
68
68
  isError: true
69
69
  };
70
70
  }
71
+ const promises = files.map(async (file) => {
72
+ return await getSource(file, { extname: ".ts" });
73
+ });
74
+ const sources = await Promise.all(promises);
71
75
  return {
72
76
  content: [
73
77
  // {
@@ -80,11 +84,7 @@ async function generate({ plugin, openApi, operationId }) {
80
84
  },
81
85
  {
82
86
  type: "text",
83
- text: `Files: ${JSON.stringify(
84
- files.flatMap((file) => file.sources).map((source) => source.value).join("\n\n"),
85
- null,
86
- 2
87
- )}`
87
+ text: `Files: ${JSON.stringify(sources, null, 2)}`
88
88
  }
89
89
  ]
90
90
  };
@@ -119,5 +119,5 @@ async function startServer() {
119
119
  }
120
120
 
121
121
  export { server, startServer };
122
- //# sourceMappingURL=chunk-3EYAJYBE.js.map
123
- //# sourceMappingURL=chunk-3EYAJYBE.js.map
122
+ //# sourceMappingURL=chunk-ZKYTPRRB.js.map
123
+ //# sourceMappingURL=chunk-ZKYTPRRB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../package.json","../src/schemas/generateSchema.ts","../src/tools/generate.ts","../src/index.ts"],"names":["process"],"mappings":";;;;;;;;;;;;AAEE,IAAW,OAAA,GAAA,QAAA;ACAN,IAAM,cAAA,GAAiB,EAAE,MAAO,CAAA;AAAA,EACrC,OAAA,EAAS,EAAE,MAAO,EAAA,CAAE,QAAQ,6CAA6C,CAAA,CAAE,SAAS,sBAAsB,CAAA;AAAA,EAC1G,MAAA,EAAQ,EAAE,IAAK,CAAA,CAAC,cAAc,aAAa,CAAC,CAAE,CAAA,QAAA,CAAS,eAAe,CAAA;AAAA,EACtE,WAAA,EAAa,EAAE,MAAO,EAAA,CAAE,UAAW,CAAA,QAAA,EAAW,CAAA,QAAA,CAAS,kCAAkC;AAAA;AAE3F,CAAC,CAAA;ACED,eAAsB,QAAS,CAAA,EAAE,MAAQ,EAAA,OAAA,EAAS,aAAwE,EAAA;AACxH,EAAI,IAAA;AACF,IAAA,MAAM,OAAU,GAAA;AAAA,MACd,WACI,GAAA;AAAA,QACE,IAAM,EAAA,aAAA;AAAA,QACN,OAAS,EAAA;AAAA,OAEX,GAAA,KAAA;AAAA,KACN,CAAE,OAAO,OAAO,CAAA;AAEhB,IAAA,MAAM,OAAU,GAAA;AAAA,MACd,UAAU,EAAE,QAAA,EAAU,OAAO,UAAY,EAAA,IAAI,CAAA;AAAA,MAC7C,QAAS,CAAA;AAAA,QACP,MAAQ,EAAA;AAAA,UACN,IAAM,EAAA;AAAA,SACR;AAAA,QACA,UAAY,EAAA,MAAA,KAAW,YAAe,GAAA,KAAA,CAAA,GAAY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Ae,EAAA,IAAA,EAAM,CAAC,CAAC,CAAA;AAAA,SACzD;AAAA,QACA;AAAA,UACE,IAAM,EAAA,MAAA;AAAA,UACN,MAAM,CAAU,OAAA,EAAA,IAAA,CAAK,UAAU,OAAS,EAAA,IAAA,EAAM,CAAC,CAAC,CAAA;AAAA;AAClD;AACF,KACF;AAAA,WACO,CAAG,EAAA;AACV,IAAA,MAAM,KAAQ,GAAA,CAAA;AAEd,IAAO,OAAA;AAAA,MACL,OAAS,EAAA;AAAA,QACP;AAAA,UACE,IAAM,EAAA,MAAA;AAAA,UACN,MAAM,KAAM,CAAA;AAAA;AACd,OACF;AAAA,MACA,OAAS,EAAA;AAAA,KACX;AAAA;AAEJ;;;AC7Fa,IAAA,MAAA,GAAS,IAAI,SAAU,CAAA;AAAA,EAClC,IAAM,EAAA,MAAA;AAAA,EACN;AACF,CAAC;AAED,MAAA,CAAO,IAAK,CAAA,UAAA,EAAY,4CAA8C,EAAA,cAAA,CAAe,OAAO,QAAQ,CAAA;AAEpG,eAAsB,WAAc,GAAA;AAClC,EAAI,IAAA;AACF,IAAM,MAAA,SAAA,GAAY,IAAI,oBAAqB,EAAA;AAC3C,IAAM,MAAA,MAAA,CAAO,QAAQ,SAAS,CAAA;AAAA,WACvB,KAAO,EAAA;AACd,IAAQ,OAAA,CAAA,KAAA,CAAM,2BAA2B,KAAK,CAAA;AAC9C,IAAAA,QAAAA,CAAQ,KAAK,CAAC,CAAA;AAAA;AAElB","file":"chunk-ZKYTPRRB.js","sourcesContent":["{\n \"name\": \"@kubb/mcp\",\n \"version\": \"3.10.2\",\n \"description\": \"Generator MCP\",\n \"keywords\": [\n \"typescript\",\n \"plugins\",\n \"kubb\",\n \"codegen\",\n \"MCP\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/kubb-labs/kubb.git\",\n \"directory\": \"packages/mcp\"\n },\n \"license\": \"MIT\",\n \"author\": \"stijnvanhulle\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.cjs\"\n },\n \"./server\": {\n \"import\": \"./dist/server.js\",\n \"require\": \"./dist/server.cjs\",\n \"default\": \"./dist/server.cjs\"\n }\n },\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"server\": [\n \"./dist/server.d.ts\"\n ]\n }\n },\n \"files\": [\n \"src\",\n \"dist\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"start:mcp\": \"bun --watch ./src/server.ts\",\n \"debug:mcp\": \"npx -y @modelcontextprotocol/inspector node ./dist/server.js\",\n \"clean\": \"npx rimraf ./dist\",\n \"lint\": \"bun biome lint .\",\n \"lint:fix\": \"bun biome lint --apply-unsafe .\",\n \"release\": \"pnpm publish --no-git-check\",\n \"release:canary\": \"bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check\",\n \"start\": \"tsup --watch\",\n \"test\": \"vitest --passWithNoTests\",\n \"typecheck\": \"tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false\"\n },\n \"dependencies\": {\n \"@kubb/core\": \"workspace:*\",\n \"@kubb/plugin-client\": \"workspace:*\",\n \"@kubb/plugin-cypress\": \"workspace:*\",\n \"@kubb/plugin-faker\": \"workspace:*\",\n \"@kubb/plugin-mcp\": \"workspace:*\",\n \"@kubb/plugin-msw\": \"workspace:*\",\n \"@kubb/plugin-oas\": \"workspace:*\",\n \"@kubb/plugin-react-query\": \"workspace:*\",\n \"@kubb/plugin-redoc\": \"workspace:*\",\n \"@kubb/plugin-swr\": \"workspace:*\",\n \"@kubb/plugin-ts\": \"workspace:*\",\n \"@kubb/plugin-zod\": \"workspace:*\",\n \"@kubb/react\": \"workspace:*\",\n \"@modelcontextprotocol/sdk\": \"^1.10.2\",\n \"zod\": \"^3.24.3\"\n },\n \"devDependencies\": {\n \"@kubb/config-ts\": \"workspace:*\",\n \"@kubb/config-tsup\": \"workspace:*\",\n \"@kubb/plugin-oas\": \"workspace:*\",\n \"@types/node\": \"catalog:\",\n \"@types/react\": \"catalog:\",\n \"tsup\": \"catalog:\",\n \"typescript\": \"catalog:\"\n },\n \"engines\": {\n \"node\": \">=20\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org/\"\n }\n}\n","import { z } from 'zod'\n\nexport const generateSchema = z.object({\n openApi: z.string().default('https://petstore.swagger.io/v2/swagger.json').describe('OpenAPI/Swagger spec'),\n plugin: z.enum(['typescript', 'react-query']).describe('Plugin to use'),\n operationId: z.string().nullable().optional().describe('Which operationId should be used'),\n // schemaName: z.string().nullable().optional().describe('Which schema should be used'),\n})\n","import { pluginTs } from '@kubb/plugin-ts'\nimport { type Include, pluginOas } from '@kubb/plugin-oas'\nimport { pluginReactQuery } from '@kubb/plugin-react-query'\n\nimport { type Config, safeBuild, type Plugin, getSource } from '@kubb/core'\nimport type { generateSchema } from '../schemas/generateSchema.ts'\nimport type { z } from 'zod'\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.d.ts'\n\nexport async function generate({ plugin, openApi, operationId }: z.infer<typeof generateSchema>): Promise<CallToolResult> {\n try {\n const include = [\n operationId\n ? {\n type: 'operationId',\n pattern: operationId,\n }\n : undefined,\n ].filter(Boolean) as Include[]\n\n const plugins = [\n pluginOas({ validate: false, generators: [] }),\n pluginTs({\n output: {\n path: 'typescript.ts',\n },\n generators: plugin === 'typescript' ? undefined : [],\n include,\n }),\n pluginReactQuery({\n output: {\n path: 'react-query.ts',\n },\n generators: plugin === 'react-query' ? undefined : [],\n include,\n }),\n ].filter(Boolean) as Plugin[]\n\n const definedConfig: Config = {\n root: process.cwd(),\n input: {\n data: openApi,\n },\n output: {\n path: './',\n write: false,\n barrelType: 'named',\n },\n plugins,\n }\n\n const { files, error } = await safeBuild({\n config: definedConfig,\n })\n\n if (error) {\n return {\n content: [\n {\n type: 'text',\n text: error.message,\n },\n ],\n isError: true,\n }\n }\n\n const promises = files.map(async (file) => {\n return await getSource(file, { extname: '.ts' })\n })\n\n const sources = await Promise.all(promises)\n\n return {\n content: [\n // {\n // type: 'resource',\n // resource: {}\n // },\n {\n type: 'text',\n text: `Config: ${JSON.stringify(definedConfig, null, 2)}`,\n },\n {\n type: 'text',\n text: `Files: ${JSON.stringify(sources, null, 2)}`,\n },\n ],\n }\n } catch (e) {\n const error = e as Error\n\n return {\n content: [\n {\n type: 'text',\n text: error.message,\n },\n ],\n isError: true,\n }\n }\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\n\nimport { version } from '../package.json'\n\nimport process from 'node:process'\nimport { generateSchema } from './schemas/generateSchema.ts'\nimport { generate } from './tools/generate.ts'\n\nexport const server = new McpServer({\n name: 'Kubb',\n version,\n})\n\nserver.tool('generate', 'generate an openAPI spec to a code snippet', generateSchema.shape, generate)\n\nexport async function startServer() {\n try {\n const transport = new StdioServerTransport()\n await server.connect(transport)\n } catch (error) {\n console.error('Failed to start server:', error)\n process.exit(1)\n }\n}\n"]}
package/dist/index.cjs CHANGED
@@ -1,16 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var chunkA4QFMFDL_cjs = require('./chunk-A4QFMFDL.cjs');
3
+ var chunkVK5RZRTZ_cjs = require('./chunk-VK5RZRTZ.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "server", {
8
8
  enumerable: true,
9
- get: function () { return chunkA4QFMFDL_cjs.server; }
9
+ get: function () { return chunkVK5RZRTZ_cjs.server; }
10
10
  });
11
11
  Object.defineProperty(exports, "startServer", {
12
12
  enumerable: true,
13
- get: function () { return chunkA4QFMFDL_cjs.startServer; }
13
+ get: function () { return chunkVK5RZRTZ_cjs.startServer; }
14
14
  });
15
15
  //# sourceMappingURL=index.cjs.map
16
16
  //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { server, startServer } from './chunk-3EYAJYBE.js';
1
+ export { server, startServer } from './chunk-ZKYTPRRB.js';
2
2
  //# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map
package/dist/server.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkA4QFMFDL_cjs = require('./chunk-A4QFMFDL.cjs');
3
+ var chunkVK5RZRTZ_cjs = require('./chunk-VK5RZRTZ.cjs');
4
4
 
5
5
  // src/server.ts
6
- chunkA4QFMFDL_cjs.startServer();
6
+ chunkVK5RZRTZ_cjs.startServer();
7
7
  //# sourceMappingURL=server.cjs.map
8
8
  //# sourceMappingURL=server.cjs.map
package/dist/server.js CHANGED
@@ -1,4 +1,4 @@
1
- import { startServer } from './chunk-3EYAJYBE.js';
1
+ import { startServer } from './chunk-ZKYTPRRB.js';
2
2
 
3
3
  // src/server.ts
4
4
  startServer();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/mcp",
3
- "version": "3.10.1",
3
+ "version": "3.10.2",
4
4
  "description": "Generator MCP",
5
5
  "keywords": [
6
6
  "typescript",
@@ -49,28 +49,28 @@
49
49
  "dependencies": {
50
50
  "@modelcontextprotocol/sdk": "^1.10.2",
51
51
  "zod": "^3.24.3",
52
- "@kubb/core": "3.10.1",
53
- "@kubb/plugin-client": "3.10.1",
54
- "@kubb/plugin-cypress": "3.10.1",
55
- "@kubb/plugin-faker": "3.10.1",
56
- "@kubb/plugin-mcp": "3.10.1",
57
- "@kubb/plugin-msw": "3.10.1",
58
- "@kubb/plugin-oas": "3.10.1",
59
- "@kubb/plugin-react-query": "3.10.1",
60
- "@kubb/plugin-redoc": "3.10.1",
61
- "@kubb/plugin-swr": "3.10.1",
62
- "@kubb/plugin-ts": "3.10.1",
63
- "@kubb/plugin-zod": "3.10.1",
64
- "@kubb/react": "3.10.1"
52
+ "@kubb/core": "3.10.2",
53
+ "@kubb/plugin-client": "3.10.2",
54
+ "@kubb/plugin-cypress": "3.10.2",
55
+ "@kubb/plugin-faker": "3.10.2",
56
+ "@kubb/plugin-mcp": "3.10.2",
57
+ "@kubb/plugin-msw": "3.10.2",
58
+ "@kubb/plugin-oas": "3.10.2",
59
+ "@kubb/plugin-react-query": "3.10.2",
60
+ "@kubb/plugin-redoc": "3.10.2",
61
+ "@kubb/plugin-swr": "3.10.2",
62
+ "@kubb/plugin-ts": "3.10.2",
63
+ "@kubb/plugin-zod": "3.10.2",
64
+ "@kubb/react": "3.10.2"
65
65
  },
66
66
  "devDependencies": {
67
- "@types/node": "^20.17.30",
67
+ "@types/node": "^20.17.31",
68
68
  "@types/react": "^18.3.20",
69
69
  "tsup": "^8.4.0",
70
70
  "typescript": "^5.8.3",
71
- "@kubb/config-ts": "3.10.1",
72
- "@kubb/config-tsup": "3.10.1",
73
- "@kubb/plugin-oas": "3.10.1"
71
+ "@kubb/config-ts": "3.10.2",
72
+ "@kubb/config-tsup": "3.10.2",
73
+ "@kubb/plugin-oas": "3.10.2"
74
74
  },
75
75
  "engines": {
76
76
  "node": ">=20"
@@ -2,7 +2,7 @@ import { pluginTs } from '@kubb/plugin-ts'
2
2
  import { type Include, pluginOas } from '@kubb/plugin-oas'
3
3
  import { pluginReactQuery } from '@kubb/plugin-react-query'
4
4
 
5
- import { type Config, safeBuild, type Plugin } from '@kubb/core'
5
+ import { type Config, safeBuild, type Plugin, getSource } from '@kubb/core'
6
6
  import type { generateSchema } from '../schemas/generateSchema.ts'
7
7
  import type { z } from 'zod'
8
8
  import type { CallToolResult } from '@modelcontextprotocol/sdk/types.d.ts'
@@ -65,6 +65,12 @@ export async function generate({ plugin, openApi, operationId }: z.infer<typeof
65
65
  }
66
66
  }
67
67
 
68
+ const promises = files.map(async (file) => {
69
+ return await getSource(file, { extname: '.ts' })
70
+ })
71
+
72
+ const sources = await Promise.all(promises)
73
+
68
74
  return {
69
75
  content: [
70
76
  // {
@@ -77,14 +83,7 @@ export async function generate({ plugin, openApi, operationId }: z.infer<typeof
77
83
  },
78
84
  {
79
85
  type: 'text',
80
- text: `Files: ${JSON.stringify(
81
- files
82
- .flatMap((file) => file.sources)
83
- .map((source) => source.value)
84
- .join('\n\n'),
85
- null,
86
- 2,
87
- )}`,
86
+ text: `Files: ${JSON.stringify(sources, null, 2)}`,
88
87
  },
89
88
  ],
90
89
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../package.json","../src/schemas/generateSchema.ts","../src/tools/generate.ts","../src/index.ts"],"names":["process"],"mappings":";;;;;;;;;;;;AAEE,IAAW,OAAA,GAAA,QAAA;ACAN,IAAM,cAAA,GAAiB,EAAE,MAAO,CAAA;AAAA,EACrC,OAAA,EAAS,EAAE,MAAO,EAAA,CAAE,QAAQ,6CAA6C,CAAA,CAAE,SAAS,sBAAsB,CAAA;AAAA,EAC1G,MAAA,EAAQ,EAAE,IAAK,CAAA,CAAC,cAAc,aAAa,CAAC,CAAE,CAAA,QAAA,CAAS,eAAe,CAAA;AAAA,EACtE,WAAA,EAAa,EAAE,MAAO,EAAA,CAAE,UAAW,CAAA,QAAA,EAAW,CAAA,QAAA,CAAS,kCAAkC;AAAA;AAE3F,CAAC,CAAA;ACED,eAAsB,QAAS,CAAA,EAAE,MAAQ,EAAA,OAAA,EAAS,aAAwE,EAAA;AACxH,EAAI,IAAA;AACF,IAAA,MAAM,OAAU,GAAA;AAAA,MACd,WACI,GAAA;AAAA,QACE,IAAM,EAAA,aAAA;AAAA,QACN,OAAS,EAAA;AAAA,OAEX,GAAA,KAAA;AAAA,KACN,CAAE,OAAO,OAAO,CAAA;AAEhB,IAAA,MAAM,OAAU,GAAA;AAAA,MACd,UAAU,EAAE,QAAA,EAAU,OAAO,UAAY,EAAA,IAAI,CAAA;AAAA,MAC7C,QAAS,CAAA;AAAA,QACP,MAAQ,EAAA;AAAA,UACN,IAAM,EAAA;AAAA,SACR;A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IAAA,KAAS,KAAK,OAAO,CAAA,CAC9B,GAAI,CAAA,CAAC,MAAW,KAAA,MAAA,CAAO,KAAK,CAAA,CAC5B,KAAK,MAAM,CAAA;AAAA,YACd,IAAA;AAAA,YACA;AAAA,WACD,CAAA;AAAA;AACH;AACF,KACF;AAAA,WACO,CAAG,EAAA;AACV,IAAA,MAAM,KAAQ,GAAA,CAAA;AAEd,IAAO,OAAA;AAAA,MACL,OAAS,EAAA;AAAA,QACP;AAAA,UACE,IAAM,EAAA,MAAA;AAAA,UACN,MAAM,KAAM,CAAA;AAAA;AACd,OACF;AAAA,MACA,OAAS,EAAA;AAAA,KACX;AAAA;AAEJ;;;AC9Fa,IAAA,MAAA,GAAS,IAAI,SAAU,CAAA;AAAA,EAClC,IAAM,EAAA,MAAA;AAAA,EACN;AACF,CAAC;AAED,MAAA,CAAO,IAAK,CAAA,UAAA,EAAY,4CAA8C,EAAA,cAAA,CAAe,OAAO,QAAQ,CAAA;AAEpG,eAAsB,WAAc,GAAA;AAClC,EAAI,IAAA;AACF,IAAM,MAAA,SAAA,GAAY,IAAI,oBAAqB,EAAA;AAC3C,IAAM,MAAA,MAAA,CAAO,QAAQ,SAAS,CAAA;AAAA,WACvB,KAAO,EAAA;AACd,IAAQ,OAAA,CAAA,KAAA,CAAM,2BAA2B,KAAK,CAAA;AAC9C,IAAAA,QAAAA,CAAQ,KAAK,CAAC,CAAA;AAAA;AAElB","file":"chunk-3EYAJYBE.js","sourcesContent":["{\n \"name\": \"@kubb/mcp\",\n \"version\": \"3.10.1\",\n \"description\": \"Generator MCP\",\n \"keywords\": [\n \"typescript\",\n \"plugins\",\n \"kubb\",\n \"codegen\",\n \"MCP\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/kubb-labs/kubb.git\",\n \"directory\": \"packages/mcp\"\n },\n \"license\": \"MIT\",\n \"author\": \"stijnvanhulle\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.cjs\"\n },\n \"./server\": {\n \"import\": \"./dist/server.js\",\n \"require\": \"./dist/server.cjs\",\n \"default\": \"./dist/server.cjs\"\n }\n },\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"server\": [\n \"./dist/server.d.ts\"\n ]\n }\n },\n \"files\": [\n \"src\",\n \"dist\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"start:mcp\": \"bun --watch ./src/server.ts\",\n \"debug:mcp\": \"npx -y @modelcontextprotocol/inspector node ./dist/server.js\",\n \"clean\": \"npx rimraf ./dist\",\n \"lint\": \"bun biome lint .\",\n \"lint:fix\": \"bun biome lint --apply-unsafe .\",\n \"release\": \"pnpm publish --no-git-check\",\n \"release:canary\": \"bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check\",\n \"start\": \"tsup --watch\",\n \"test\": \"vitest --passWithNoTests\",\n \"typecheck\": \"tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false\"\n },\n \"dependencies\": {\n \"@kubb/core\": \"workspace:*\",\n \"@kubb/plugin-client\": \"workspace:*\",\n \"@kubb/plugin-cypress\": \"workspace:*\",\n \"@kubb/plugin-faker\": \"workspace:*\",\n \"@kubb/plugin-mcp\": \"workspace:*\",\n \"@kubb/plugin-msw\": \"workspace:*\",\n \"@kubb/plugin-oas\": \"workspace:*\",\n \"@kubb/plugin-react-query\": \"workspace:*\",\n \"@kubb/plugin-redoc\": \"workspace:*\",\n \"@kubb/plugin-swr\": \"workspace:*\",\n \"@kubb/plugin-ts\": \"workspace:*\",\n \"@kubb/plugin-zod\": \"workspace:*\",\n \"@kubb/react\": \"workspace:*\",\n \"@modelcontextprotocol/sdk\": \"^1.10.2\",\n \"zod\": \"^3.24.3\"\n },\n \"devDependencies\": {\n \"@kubb/config-ts\": \"workspace:*\",\n \"@kubb/config-tsup\": \"workspace:*\",\n \"@kubb/plugin-oas\": \"workspace:*\",\n \"@types/node\": \"catalog:\",\n \"@types/react\": \"catalog:\",\n \"tsup\": \"catalog:\",\n \"typescript\": \"catalog:\"\n },\n \"engines\": {\n \"node\": \">=20\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org/\"\n }\n}\n","import { z } from 'zod'\n\nexport const generateSchema = z.object({\n openApi: z.string().default('https://petstore.swagger.io/v2/swagger.json').describe('OpenAPI/Swagger spec'),\n plugin: z.enum(['typescript', 'react-query']).describe('Plugin to use'),\n operationId: z.string().nullable().optional().describe('Which operationId should be used'),\n // schemaName: z.string().nullable().optional().describe('Which schema should be used'),\n})\n","import { pluginTs } from '@kubb/plugin-ts'\nimport { type Include, pluginOas } from '@kubb/plugin-oas'\nimport { pluginReactQuery } from '@kubb/plugin-react-query'\n\nimport { type Config, safeBuild, type Plugin } from '@kubb/core'\nimport type { generateSchema } from '../schemas/generateSchema.ts'\nimport type { z } from 'zod'\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.d.ts'\n\nexport async function generate({ plugin, openApi, operationId }: z.infer<typeof generateSchema>): Promise<CallToolResult> {\n try {\n const include = [\n operationId\n ? {\n type: 'operationId',\n pattern: operationId,\n }\n : undefined,\n ].filter(Boolean) as Include[]\n\n const plugins = [\n pluginOas({ validate: false, generators: [] }),\n pluginTs({\n output: {\n path: 'typescript.ts',\n },\n generators: plugin === 'typescript' ? undefined : [],\n include,\n }),\n pluginReactQuery({\n output: {\n path: 'react-query.ts',\n },\n generators: plugin === 'react-query' ? undefined : [],\n include,\n }),\n ].filter(Boolean) as Plugin[]\n\n const definedConfig: Config = {\n root: process.cwd(),\n input: {\n data: openApi,\n },\n output: {\n path: './',\n write: false,\n barrelType: 'named',\n },\n plugins,\n }\n\n const { files, error } = await safeBuild({\n config: definedConfig,\n })\n\n if (error) {\n return {\n content: [\n {\n type: 'text',\n text: error.message,\n },\n ],\n isError: true,\n }\n }\n\n return {\n content: [\n // {\n // type: 'resource',\n // resource: {}\n // },\n {\n type: 'text',\n text: `Config: ${JSON.stringify(definedConfig, null, 2)}`,\n },\n {\n type: 'text',\n text: `Files: ${JSON.stringify(\n files\n .flatMap((file) => file.sources)\n .map((source) => source.value)\n .join('\\n\\n'),\n null,\n 2,\n )}`,\n },\n ],\n }\n } catch (e) {\n const error = e as Error\n\n return {\n content: [\n {\n type: 'text',\n text: error.message,\n },\n ],\n isError: true,\n }\n }\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\n\nimport { version } from '../package.json'\n\nimport process from 'node:process'\nimport { generateSchema } from './schemas/generateSchema.ts'\nimport { generate } from './tools/generate.ts'\n\nexport const server = new McpServer({\n name: 'Kubb',\n version,\n})\n\nserver.tool('generate', 'generate an openAPI spec to a code snippet', generateSchema.shape, generate)\n\nexport async function startServer() {\n try {\n const transport = new StdioServerTransport()\n await server.connect(transport)\n } catch (error) {\n console.error('Failed to start server:', error)\n process.exit(1)\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../package.json","../src/schemas/generateSchema.ts","../src/tools/generate.ts","../src/index.ts"],"names":["z","pluginOas","pluginTs","pluginReactQuery","safeBuild","McpServer","StdioServerTransport","process"],"mappings":";;;;;;;;;;;;;;;;;;AAEE,IAAW,OAAA,GAAA,QAAA;ACAN,IAAM,cAAA,GAAiBA,MAAE,MAAO,CAAA;AAAA,EACrC,OAAA,EAASA,MAAE,MAAO,EAAA,CAAE,QAAQ,6CAA6C,CAAA,CAAE,SAAS,sBAAsB,CAAA;AAAA,EAC1G,MAAA,EAAQA,MAAE,IAAK,CAAA,CAAC,cAAc,aAAa,CAAC,CAAE,CAAA,QAAA,CAAS,eAAe,CAAA;AAAA,EACtE,WAAA,EAAaA,MAAE,MAAO,EAAA,CAAE,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CAAO,QAAQ,SAAS,CAAA;AAAA,WACvB,KAAO,EAAA;AACd,IAAQ,OAAA,CAAA,KAAA,CAAM,2BAA2B,KAAK,CAAA;AAC9C,IAAAC,yBAAAA,CAAQ,KAAK,CAAC,CAAA;AAAA;AAElB","file":"chunk-A4QFMFDL.cjs","sourcesContent":["{\n \"name\": \"@kubb/mcp\",\n \"version\": \"3.10.1\",\n \"description\": \"Generator MCP\",\n \"keywords\": [\n \"typescript\",\n \"plugins\",\n \"kubb\",\n \"codegen\",\n \"MCP\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/kubb-labs/kubb.git\",\n \"directory\": \"packages/mcp\"\n },\n \"license\": \"MIT\",\n \"author\": \"stijnvanhulle\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.cjs\"\n },\n \"./server\": {\n \"import\": \"./dist/server.js\",\n \"require\": \"./dist/server.cjs\",\n \"default\": \"./dist/server.cjs\"\n }\n },\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"server\": [\n \"./dist/server.d.ts\"\n ]\n }\n },\n \"files\": [\n \"src\",\n \"dist\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"start:mcp\": \"bun --watch ./src/server.ts\",\n \"debug:mcp\": \"npx -y @modelcontextprotocol/inspector node ./dist/server.js\",\n \"clean\": \"npx rimraf ./dist\",\n \"lint\": \"bun biome lint .\",\n \"lint:fix\": \"bun biome lint --apply-unsafe .\",\n \"release\": \"pnpm publish --no-git-check\",\n \"release:canary\": \"bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check\",\n \"start\": \"tsup --watch\",\n \"test\": \"vitest --passWithNoTests\",\n \"typecheck\": \"tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false\"\n },\n \"dependencies\": {\n \"@kubb/core\": \"workspace:*\",\n \"@kubb/plugin-client\": \"workspace:*\",\n \"@kubb/plugin-cypress\": \"workspace:*\",\n \"@kubb/plugin-faker\": \"workspace:*\",\n \"@kubb/plugin-mcp\": \"workspace:*\",\n \"@kubb/plugin-msw\": \"workspace:*\",\n \"@kubb/plugin-oas\": \"workspace:*\",\n \"@kubb/plugin-react-query\": \"workspace:*\",\n \"@kubb/plugin-redoc\": \"workspace:*\",\n \"@kubb/plugin-swr\": \"workspace:*\",\n \"@kubb/plugin-ts\": \"workspace:*\",\n \"@kubb/plugin-zod\": \"workspace:*\",\n \"@kubb/react\": \"workspace:*\",\n \"@modelcontextprotocol/sdk\": \"^1.10.2\",\n \"zod\": \"^3.24.3\"\n },\n \"devDependencies\": {\n \"@kubb/config-ts\": \"workspace:*\",\n \"@kubb/config-tsup\": \"workspace:*\",\n \"@kubb/plugin-oas\": \"workspace:*\",\n \"@types/node\": \"catalog:\",\n \"@types/react\": \"catalog:\",\n \"tsup\": \"catalog:\",\n \"typescript\": \"catalog:\"\n },\n \"engines\": {\n \"node\": \">=20\"\n },\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org/\"\n }\n}\n","import { z } from 'zod'\n\nexport const generateSchema = z.object({\n openApi: z.string().default('https://petstore.swagger.io/v2/swagger.json').describe('OpenAPI/Swagger spec'),\n plugin: z.enum(['typescript', 'react-query']).describe('Plugin to use'),\n operationId: z.string().nullable().optional().describe('Which operationId should be used'),\n // schemaName: z.string().nullable().optional().describe('Which schema should be used'),\n})\n","import { pluginTs } from '@kubb/plugin-ts'\nimport { type Include, pluginOas } from '@kubb/plugin-oas'\nimport { pluginReactQuery } from '@kubb/plugin-react-query'\n\nimport { type Config, safeBuild, type Plugin } from '@kubb/core'\nimport type { generateSchema } from '../schemas/generateSchema.ts'\nimport type { z } from 'zod'\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.d.ts'\n\nexport async function generate({ plugin, openApi, operationId }: z.infer<typeof generateSchema>): Promise<CallToolResult> {\n try {\n const include = [\n operationId\n ? {\n type: 'operationId',\n pattern: operationId,\n }\n : undefined,\n ].filter(Boolean) as Include[]\n\n const plugins = [\n pluginOas({ validate: false, generators: [] }),\n pluginTs({\n output: {\n path: 'typescript.ts',\n },\n generators: plugin === 'typescript' ? undefined : [],\n include,\n }),\n pluginReactQuery({\n output: {\n path: 'react-query.ts',\n },\n generators: plugin === 'react-query' ? undefined : [],\n include,\n }),\n ].filter(Boolean) as Plugin[]\n\n const definedConfig: Config = {\n root: process.cwd(),\n input: {\n data: openApi,\n },\n output: {\n path: './',\n write: false,\n barrelType: 'named',\n },\n plugins,\n }\n\n const { files, error } = await safeBuild({\n config: definedConfig,\n })\n\n if (error) {\n return {\n content: [\n {\n type: 'text',\n text: error.message,\n },\n ],\n isError: true,\n }\n }\n\n return {\n content: [\n // {\n // type: 'resource',\n // resource: {}\n // },\n {\n type: 'text',\n text: `Config: ${JSON.stringify(definedConfig, null, 2)}`,\n },\n {\n type: 'text',\n text: `Files: ${JSON.stringify(\n files\n .flatMap((file) => file.sources)\n .map((source) => source.value)\n .join('\\n\\n'),\n null,\n 2,\n )}`,\n },\n ],\n }\n } catch (e) {\n const error = e as Error\n\n return {\n content: [\n {\n type: 'text',\n text: error.message,\n },\n ],\n isError: true,\n }\n }\n}\n","import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\n\nimport { version } from '../package.json'\n\nimport process from 'node:process'\nimport { generateSchema } from './schemas/generateSchema.ts'\nimport { generate } from './tools/generate.ts'\n\nexport const server = new McpServer({\n name: 'Kubb',\n version,\n})\n\nserver.tool('generate', 'generate an openAPI spec to a code snippet', generateSchema.shape, generate)\n\nexport async function startServer() {\n try {\n const transport = new StdioServerTransport()\n await server.connect(transport)\n } catch (error) {\n console.error('Failed to start server:', error)\n process.exit(1)\n }\n}\n"]}