@kubb/mcp 0.0.0-canary-20250424221503

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Stijn Van Hulle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,130 @@
1
+ 'use strict';
2
+
3
+ var mcp_js = require('@modelcontextprotocol/sdk/server/mcp.js');
4
+ var stdio_js = require('@modelcontextprotocol/sdk/server/stdio.js');
5
+ var process2 = require('process');
6
+ var zod = require('zod');
7
+ var pluginTs = require('@kubb/plugin-ts');
8
+ var pluginOas = require('@kubb/plugin-oas');
9
+ var pluginReactQuery = require('@kubb/plugin-react-query');
10
+ var core = require('@kubb/core');
11
+
12
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
+
14
+ var process2__default = /*#__PURE__*/_interopDefault(process2);
15
+
16
+ // src/index.ts
17
+
18
+ // package.json
19
+ var version = "3.10.0";
20
+ var generateSchema = zod.z.object({
21
+ openApi: zod.z.string().default("https://petstore.swagger.io/v2/swagger.json").describe("OpenAPI/Swagger spec"),
22
+ plugin: zod.z.enum(["typescript", "react-query"]).describe("Plugin to use"),
23
+ operationId: zod.z.string().nullable().optional().describe("Which operationId should be used")
24
+ // schemaName: z.string().nullable().optional().describe('Which schema should be used'),
25
+ });
26
+ async function generate({ plugin, openApi, operationId }) {
27
+ try {
28
+ const include = [
29
+ operationId ? {
30
+ type: "operationId",
31
+ pattern: operationId
32
+ } : void 0
33
+ ].filter(Boolean);
34
+ const plugins = [
35
+ pluginOas.pluginOas({ validate: false, generators: [] }),
36
+ pluginTs.pluginTs({
37
+ output: {
38
+ path: "typescript.ts"
39
+ },
40
+ generators: plugin === "typescript" ? void 0 : [],
41
+ include
42
+ }),
43
+ pluginReactQuery.pluginReactQuery({
44
+ output: {
45
+ path: "react-query.ts"
46
+ },
47
+ generators: plugin === "react-query" ? void 0 : [],
48
+ include
49
+ })
50
+ ].filter(Boolean);
51
+ const definedConfig = {
52
+ root: process.cwd(),
53
+ input: {
54
+ data: openApi
55
+ },
56
+ output: {
57
+ path: "./",
58
+ write: false,
59
+ barrelType: "named"
60
+ },
61
+ plugins
62
+ };
63
+ const { files, error } = await core.safeBuild({
64
+ config: definedConfig
65
+ });
66
+ if (error) {
67
+ return {
68
+ content: [
69
+ {
70
+ type: "text",
71
+ text: error.message
72
+ }
73
+ ],
74
+ isError: true
75
+ };
76
+ }
77
+ return {
78
+ content: [
79
+ // {
80
+ // type: 'resource',
81
+ // resource: {}
82
+ // },
83
+ {
84
+ type: "text",
85
+ text: `Config: ${JSON.stringify(definedConfig, null, 2)}`
86
+ },
87
+ {
88
+ 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
+ )}`
94
+ }
95
+ ]
96
+ };
97
+ } catch (e) {
98
+ const error = e;
99
+ return {
100
+ content: [
101
+ {
102
+ type: "text",
103
+ text: error.message
104
+ }
105
+ ],
106
+ isError: true
107
+ };
108
+ }
109
+ }
110
+
111
+ // src/index.ts
112
+ var server = new mcp_js.McpServer({
113
+ name: "Kubb",
114
+ version
115
+ });
116
+ server.tool("generate", "generate an openAPI spec to a code snippet", generateSchema.shape, generate);
117
+ async function startServer() {
118
+ try {
119
+ const transport = new stdio_js.StdioServerTransport();
120
+ await server.connect(transport);
121
+ } catch (error) {
122
+ console.error("Failed to start server:", error);
123
+ process2__default.default.exit(1);
124
+ }
125
+ }
126
+
127
+ exports.server = server;
128
+ exports.startServer = startServer;
129
+ //# sourceMappingURL=chunk-H4Y47FEX.cjs.map
130
+ //# sourceMappingURL=chunk-H4Y47FEX.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","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,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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",\n \"version\": \"3.10.0\",\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"]}
@@ -0,0 +1,123 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import process2 from 'node:process';
4
+ import { z } from 'zod';
5
+ import { pluginTs } from '@kubb/plugin-ts';
6
+ import { pluginOas } from '@kubb/plugin-oas';
7
+ import { pluginReactQuery } from '@kubb/plugin-react-query';
8
+ import { safeBuild } from '@kubb/core';
9
+
10
+ // src/index.ts
11
+
12
+ // package.json
13
+ var version = "3.10.0";
14
+ var generateSchema = z.object({
15
+ openApi: z.string().default("https://petstore.swagger.io/v2/swagger.json").describe("OpenAPI/Swagger spec"),
16
+ plugin: z.enum(["typescript", "react-query"]).describe("Plugin to use"),
17
+ operationId: z.string().nullable().optional().describe("Which operationId should be used")
18
+ // schemaName: z.string().nullable().optional().describe('Which schema should be used'),
19
+ });
20
+ async function generate({ plugin, openApi, operationId }) {
21
+ try {
22
+ const include = [
23
+ operationId ? {
24
+ type: "operationId",
25
+ pattern: operationId
26
+ } : void 0
27
+ ].filter(Boolean);
28
+ const plugins = [
29
+ pluginOas({ validate: false, generators: [] }),
30
+ pluginTs({
31
+ output: {
32
+ path: "typescript.ts"
33
+ },
34
+ generators: plugin === "typescript" ? void 0 : [],
35
+ include
36
+ }),
37
+ pluginReactQuery({
38
+ output: {
39
+ path: "react-query.ts"
40
+ },
41
+ generators: plugin === "react-query" ? void 0 : [],
42
+ include
43
+ })
44
+ ].filter(Boolean);
45
+ const definedConfig = {
46
+ root: process.cwd(),
47
+ input: {
48
+ data: openApi
49
+ },
50
+ output: {
51
+ path: "./",
52
+ write: false,
53
+ barrelType: "named"
54
+ },
55
+ plugins
56
+ };
57
+ const { files, error } = await safeBuild({
58
+ config: definedConfig
59
+ });
60
+ if (error) {
61
+ return {
62
+ content: [
63
+ {
64
+ type: "text",
65
+ text: error.message
66
+ }
67
+ ],
68
+ isError: true
69
+ };
70
+ }
71
+ return {
72
+ content: [
73
+ // {
74
+ // type: 'resource',
75
+ // resource: {}
76
+ // },
77
+ {
78
+ type: "text",
79
+ text: `Config: ${JSON.stringify(definedConfig, null, 2)}`
80
+ },
81
+ {
82
+ 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
+ )}`
88
+ }
89
+ ]
90
+ };
91
+ } catch (e) {
92
+ const error = e;
93
+ return {
94
+ content: [
95
+ {
96
+ type: "text",
97
+ text: error.message
98
+ }
99
+ ],
100
+ isError: true
101
+ };
102
+ }
103
+ }
104
+
105
+ // src/index.ts
106
+ var server = new McpServer({
107
+ name: "Kubb",
108
+ version
109
+ });
110
+ server.tool("generate", "generate an openAPI spec to a code snippet", generateSchema.shape, generate);
111
+ async function startServer() {
112
+ try {
113
+ const transport = new StdioServerTransport();
114
+ await server.connect(transport);
115
+ } catch (error) {
116
+ console.error("Failed to start server:", error);
117
+ process2.exit(1);
118
+ }
119
+ }
120
+
121
+ export { server, startServer };
122
+ //# sourceMappingURL=chunk-QUYRG3VE.js.map
123
+ //# sourceMappingURL=chunk-QUYRG3VE.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;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W,QAAA,EAAA,IAAA,CAAK,UAAU,aAAe,EAAA,IAAA,EAAM,CAAC,CAAC,CAAA;AAAA,SACzD;AAAA,QACA;AAAA,UACE,IAAM,EAAA,MAAA;AAAA,UACN,IAAA,EAAM,UAAU,IAAK,CAAA,SAAA;AAAA,YACnB,KACG,CAAA,OAAA,CAAQ,CAAC,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-QUYRG3VE.js","sourcesContent":["{\n \"name\": \"@kubb/mcp\",\n \"version\": \"3.10.0\",\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"]}
package/dist/index.cjs ADDED
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var chunkH4Y47FEX_cjs = require('./chunk-H4Y47FEX.cjs');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "server", {
8
+ enumerable: true,
9
+ get: function () { return chunkH4Y47FEX_cjs.server; }
10
+ });
11
+ Object.defineProperty(exports, "startServer", {
12
+ enumerable: true,
13
+ get: function () { return chunkH4Y47FEX_cjs.startServer; }
14
+ });
15
+ //# sourceMappingURL=index.cjs.map
16
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
@@ -0,0 +1,6 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+
3
+ declare const server: McpServer;
4
+ declare function startServer(): Promise<void>;
5
+
6
+ export { server, startServer };
@@ -0,0 +1,6 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+
3
+ declare const server: McpServer;
4
+ declare function startServer(): Promise<void>;
5
+
6
+ export { server, startServer };
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { server, startServer } from './chunk-QUYRG3VE.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var chunkH4Y47FEX_cjs = require('./chunk-H4Y47FEX.cjs');
4
+
5
+ // src/server.ts
6
+ chunkH4Y47FEX_cjs.startServer();
7
+ //# sourceMappingURL=server.cjs.map
8
+ //# sourceMappingURL=server.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server.ts"],"names":["startServer"],"mappings":";;;;;AAEAA,6BAAY,EAAA","file":"server.cjs","sourcesContent":["import { startServer } from './index.ts'\n\nstartServer()\n"]}
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/dist/server.js ADDED
@@ -0,0 +1,6 @@
1
+ import { startServer } from './chunk-QUYRG3VE.js';
2
+
3
+ // src/server.ts
4
+ startServer();
5
+ //# sourceMappingURL=server.js.map
6
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server.ts"],"names":[],"mappings":";;;AAEA,WAAY,EAAA","file":"server.js","sourcesContent":["import { startServer } from './index.ts'\n\nstartServer()\n"]}
package/package.json ADDED
@@ -0,0 +1,95 @@
1
+ {
2
+ "name": "@kubb/mcp",
3
+ "version": "0.0.0-canary-20250424221503",
4
+ "description": "Generator MCP",
5
+ "keywords": [
6
+ "typescript",
7
+ "plugins",
8
+ "kubb",
9
+ "codegen",
10
+ "MCP"
11
+ ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/kubb-labs/kubb.git",
15
+ "directory": "packages/mcp"
16
+ },
17
+ "license": "MIT",
18
+ "author": "stijnvanhulle",
19
+ "sideEffects": false,
20
+ "type": "module",
21
+ "exports": {
22
+ ".": {
23
+ "import": "./dist/index.js",
24
+ "require": "./dist/index.cjs",
25
+ "default": "./dist/index.cjs"
26
+ },
27
+ "./server": {
28
+ "import": "./dist/server.js",
29
+ "require": "./dist/server.cjs",
30
+ "default": "./dist/server.cjs"
31
+ }
32
+ },
33
+ "main": "dist/index.cjs",
34
+ "module": "dist/index.js",
35
+ "types": "./dist/index.d.ts",
36
+ "typesVersions": {
37
+ "*": {
38
+ "server": [
39
+ "./dist/server.d.ts"
40
+ ]
41
+ }
42
+ },
43
+ "files": [
44
+ "src",
45
+ "dist",
46
+ "!/**/**.test.**",
47
+ "!/**/__tests__/**"
48
+ ],
49
+ "dependencies": {
50
+ "@modelcontextprotocol/sdk": "^1.10.2",
51
+ "zod": "^3.24.3",
52
+ "@kubb/core": "0.0.0-canary-20250424221503",
53
+ "@kubb/plugin-client": "0.0.0-canary-20250424221503",
54
+ "@kubb/plugin-cypress": "0.0.0-canary-20250424221503",
55
+ "@kubb/plugin-faker": "0.0.0-canary-20250424221503",
56
+ "@kubb/plugin-mcp": "0.0.0-canary-20250424221503",
57
+ "@kubb/plugin-msw": "0.0.0-canary-20250424221503",
58
+ "@kubb/plugin-oas": "0.0.0-canary-20250424221503",
59
+ "@kubb/plugin-react-query": "0.0.0-canary-20250424221503",
60
+ "@kubb/plugin-redoc": "0.0.0-canary-20250424221503",
61
+ "@kubb/plugin-swr": "0.0.0-canary-20250424221503",
62
+ "@kubb/plugin-ts": "0.0.0-canary-20250424221503",
63
+ "@kubb/plugin-zod": "0.0.0-canary-20250424221503",
64
+ "@kubb/react": "0.0.0-canary-20250424221503"
65
+ },
66
+ "devDependencies": {
67
+ "@types/node": "^20.17.30",
68
+ "@types/react": "^18.3.20",
69
+ "tsup": "^8.4.0",
70
+ "typescript": "^5.8.3",
71
+ "@kubb/config-ts": "0.0.0-canary-20250424221503",
72
+ "@kubb/config-tsup": "0.0.0-canary-20250424221503",
73
+ "@kubb/plugin-oas": "0.0.0-canary-20250424221503"
74
+ },
75
+ "engines": {
76
+ "node": ">=20"
77
+ },
78
+ "publishConfig": {
79
+ "access": "public",
80
+ "registry": "https://registry.npmjs.org/"
81
+ },
82
+ "scripts": {
83
+ "build": "tsup",
84
+ "start:mcp": "bun --watch ./src/server.ts",
85
+ "debug:mcp": "npx -y @modelcontextprotocol/inspector node ./dist/server.js",
86
+ "clean": "npx rimraf ./dist",
87
+ "lint": "bun biome lint .",
88
+ "lint:fix": "bun biome lint --apply-unsafe .",
89
+ "release": "pnpm publish --no-git-check",
90
+ "release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
91
+ "start": "tsup --watch",
92
+ "test": "vitest --passWithNoTests",
93
+ "typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
94
+ }
95
+ }
package/src/index.ts ADDED
@@ -0,0 +1,25 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
3
+
4
+ import { version } from '../package.json'
5
+
6
+ import process from 'node:process'
7
+ import { generateSchema } from './schemas/generateSchema.ts'
8
+ import { generate } from './tools/generate.ts'
9
+
10
+ export const server = new McpServer({
11
+ name: 'Kubb',
12
+ version,
13
+ })
14
+
15
+ server.tool('generate', 'generate an openAPI spec to a code snippet', generateSchema.shape, generate)
16
+
17
+ export async function startServer() {
18
+ try {
19
+ const transport = new StdioServerTransport()
20
+ await server.connect(transport)
21
+ } catch (error) {
22
+ console.error('Failed to start server:', error)
23
+ process.exit(1)
24
+ }
25
+ }
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod'
2
+
3
+ export const generateSchema = z.object({
4
+ openApi: z.string().default('https://petstore.swagger.io/v2/swagger.json').describe('OpenAPI/Swagger spec'),
5
+ plugin: z.enum(['typescript', 'react-query']).describe('Plugin to use'),
6
+ operationId: z.string().nullable().optional().describe('Which operationId should be used'),
7
+ // schemaName: z.string().nullable().optional().describe('Which schema should be used'),
8
+ })
package/src/server.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { startServer } from './index.ts'
2
+
3
+ startServer()
@@ -0,0 +1,104 @@
1
+ import { pluginTs } from '@kubb/plugin-ts'
2
+ import { type Include, pluginOas } from '@kubb/plugin-oas'
3
+ import { pluginReactQuery } from '@kubb/plugin-react-query'
4
+
5
+ import { type Config, safeBuild, type Plugin } from '@kubb/core'
6
+ import type { generateSchema } from '../schemas/generateSchema.ts'
7
+ import type { z } from 'zod'
8
+ import type { CallToolResult } from '@modelcontextprotocol/sdk/types.d.ts'
9
+
10
+ export async function generate({ plugin, openApi, operationId }: z.infer<typeof generateSchema>): Promise<CallToolResult> {
11
+ try {
12
+ const include = [
13
+ operationId
14
+ ? {
15
+ type: 'operationId',
16
+ pattern: operationId,
17
+ }
18
+ : undefined,
19
+ ].filter(Boolean) as Include[]
20
+
21
+ const plugins = [
22
+ pluginOas({ validate: false, generators: [] }),
23
+ pluginTs({
24
+ output: {
25
+ path: 'typescript.ts',
26
+ },
27
+ generators: plugin === 'typescript' ? undefined : [],
28
+ include,
29
+ }),
30
+ pluginReactQuery({
31
+ output: {
32
+ path: 'react-query.ts',
33
+ },
34
+ generators: plugin === 'react-query' ? undefined : [],
35
+ include,
36
+ }),
37
+ ].filter(Boolean) as Plugin[]
38
+
39
+ const definedConfig: Config = {
40
+ root: process.cwd(),
41
+ input: {
42
+ data: openApi,
43
+ },
44
+ output: {
45
+ path: './',
46
+ write: false,
47
+ barrelType: 'named',
48
+ },
49
+ plugins,
50
+ }
51
+
52
+ const { files, error } = await safeBuild({
53
+ config: definedConfig,
54
+ })
55
+
56
+ if (error) {
57
+ return {
58
+ content: [
59
+ {
60
+ type: 'text',
61
+ text: error.message,
62
+ },
63
+ ],
64
+ isError: true,
65
+ }
66
+ }
67
+
68
+ return {
69
+ content: [
70
+ // {
71
+ // type: 'resource',
72
+ // resource: {}
73
+ // },
74
+ {
75
+ type: 'text',
76
+ text: `Config: ${JSON.stringify(definedConfig, null, 2)}`,
77
+ },
78
+ {
79
+ 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
+ )}`,
88
+ },
89
+ ],
90
+ }
91
+ } catch (e) {
92
+ const error = e as Error
93
+
94
+ return {
95
+ content: [
96
+ {
97
+ type: 'text',
98
+ text: error.message,
99
+ },
100
+ ],
101
+ isError: true,
102
+ }
103
+ }
104
+ }