@kubb/mcp 3.16.1 → 3.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -11
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -3
- package/dist/server.cjs +4 -5
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +1 -2
- package/dist/server.d.ts +1 -2
- package/dist/server.js +5 -3
- package/dist/server.js.map +1 -1
- package/dist/src-Cv5xAnDV.cjs +131 -0
- package/dist/src-Cv5xAnDV.cjs.map +1 -0
- package/dist/src-DNKD2dn4.js +103 -0
- package/dist/src-DNKD2dn4.js.map +1 -0
- package/package.json +30 -32
- package/dist/chunk-6D3KBU4P.js +0 -121
- package/dist/chunk-6D3KBU4P.js.map +0 -1
- package/dist/chunk-6OXOQQQX.cjs +0 -127
- package/dist/chunk-6OXOQQQX.cjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
const require_src = require('./src-Cv5xAnDV.cjs');
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "startServer", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () { return chunk6OXOQQQX_cjs.startServer; }
|
|
10
|
-
});
|
|
11
|
-
//# sourceMappingURL=index.cjs.map
|
|
12
|
-
//# sourceMappingURL=index.cjs.map
|
|
3
|
+
exports.startServer = require_src.startServer;
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { startServer } from "./src-DNKD2dn4.js";
|
|
2
|
+
|
|
3
|
+
export { startServer };
|
package/dist/server.cjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
const require_src = require('./src-Cv5xAnDV.cjs');
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
//#region src/server.ts
|
|
4
|
+
require_src.startServer();
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
chunk6OXOQQQX_cjs.startServer();
|
|
7
|
-
//# sourceMappingURL=server.cjs.map
|
|
6
|
+
//#endregion
|
|
8
7
|
//# sourceMappingURL=server.cjs.map
|
package/dist/server.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"server.cjs","names":["startServer"],"sources":["../src/server.ts"],"sourcesContent":["import { startServer } from './index.ts'\n\nstartServer()\n"],"mappings":";;;AAEAA,yBAAa"}
|
package/dist/server.d.cts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { }
|
|
1
|
+
export {};
|
package/dist/server.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { }
|
|
1
|
+
export {};
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { startServer } from
|
|
1
|
+
import { startServer } from "./src-DNKD2dn4.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
//#region src/server.ts
|
|
4
4
|
startServer();
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
export { };
|
|
6
8
|
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"server.js","names":[],"sources":["../src/server.ts"],"sourcesContent":["import { startServer } from './index.ts'\n\nstartServer()\n"],"mappings":";;;AAEA,aAAa"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
const node_process = __toESM(require("node:process"));
|
|
25
|
+
const __modelcontextprotocol_sdk_server_mcp_js = __toESM(require("@modelcontextprotocol/sdk/server/mcp.js"));
|
|
26
|
+
const __modelcontextprotocol_sdk_server_stdio_js = __toESM(require("@modelcontextprotocol/sdk/server/stdio.js"));
|
|
27
|
+
const zod = __toESM(require("zod"));
|
|
28
|
+
const __kubb_plugin_ts = __toESM(require("@kubb/plugin-ts"));
|
|
29
|
+
const __kubb_plugin_oas = __toESM(require("@kubb/plugin-oas"));
|
|
30
|
+
const __kubb_plugin_react_query = __toESM(require("@kubb/plugin-react-query"));
|
|
31
|
+
const __kubb_core = __toESM(require("@kubb/core"));
|
|
32
|
+
|
|
33
|
+
//#region package.json
|
|
34
|
+
var version = "3.16.3";
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/schemas/generateSchema.ts
|
|
38
|
+
const generateSchema = zod.z.object({
|
|
39
|
+
openApi: zod.z.string().default("https://petstore.swagger.io/v2/swagger.json").describe("OpenAPI/Swagger spec"),
|
|
40
|
+
plugin: zod.z.enum(["typescript", "react-query"]).describe("Plugin to use"),
|
|
41
|
+
operationId: zod.z.string().nullable().optional().describe("Which operationId should be used")
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/tools/generate.ts
|
|
46
|
+
async function generate({ plugin, openApi, operationId }) {
|
|
47
|
+
try {
|
|
48
|
+
const include = [operationId ? {
|
|
49
|
+
type: "operationId",
|
|
50
|
+
pattern: operationId
|
|
51
|
+
} : void 0].filter(Boolean);
|
|
52
|
+
const plugins = [
|
|
53
|
+
(0, __kubb_plugin_oas.pluginOas)({
|
|
54
|
+
validate: false,
|
|
55
|
+
generators: []
|
|
56
|
+
}),
|
|
57
|
+
(0, __kubb_plugin_ts.pluginTs)({
|
|
58
|
+
output: { path: "typescript.ts" },
|
|
59
|
+
generators: plugin === "typescript" ? void 0 : [],
|
|
60
|
+
include
|
|
61
|
+
}),
|
|
62
|
+
(0, __kubb_plugin_react_query.pluginReactQuery)({
|
|
63
|
+
output: { path: "react-query.ts" },
|
|
64
|
+
generators: plugin === "react-query" ? void 0 : [],
|
|
65
|
+
include
|
|
66
|
+
})
|
|
67
|
+
].filter(Boolean);
|
|
68
|
+
const definedConfig = {
|
|
69
|
+
root: process.cwd(),
|
|
70
|
+
input: { data: openApi },
|
|
71
|
+
output: {
|
|
72
|
+
path: "./",
|
|
73
|
+
write: false,
|
|
74
|
+
barrelType: "named"
|
|
75
|
+
},
|
|
76
|
+
plugins
|
|
77
|
+
};
|
|
78
|
+
const { files, error } = await (0, __kubb_core.safeBuild)({ config: definedConfig });
|
|
79
|
+
if (error) return {
|
|
80
|
+
content: [{
|
|
81
|
+
type: "text",
|
|
82
|
+
text: error.message
|
|
83
|
+
}],
|
|
84
|
+
isError: true
|
|
85
|
+
};
|
|
86
|
+
const promises = files.map((file) => (0, __kubb_core.getSource)(file, { extname: ".ts" }));
|
|
87
|
+
const sources = await Promise.all(promises);
|
|
88
|
+
return { content: [{
|
|
89
|
+
type: "text",
|
|
90
|
+
text: `Config: ${JSON.stringify(definedConfig, null, 2)}`
|
|
91
|
+
}, {
|
|
92
|
+
type: "text",
|
|
93
|
+
text: `Files: ${JSON.stringify(sources, null, 2)}`
|
|
94
|
+
}] };
|
|
95
|
+
} catch (e) {
|
|
96
|
+
const error = e;
|
|
97
|
+
return {
|
|
98
|
+
content: [{
|
|
99
|
+
type: "text",
|
|
100
|
+
text: error.message
|
|
101
|
+
}],
|
|
102
|
+
isError: true
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/index.ts
|
|
109
|
+
async function startServer() {
|
|
110
|
+
try {
|
|
111
|
+
const transport = new __modelcontextprotocol_sdk_server_stdio_js.StdioServerTransport();
|
|
112
|
+
const server = new __modelcontextprotocol_sdk_server_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
|
+
await server.connect(transport);
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.error("Failed to start server:", error);
|
|
120
|
+
node_process.default.exit(1);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
//#endregion
|
|
125
|
+
Object.defineProperty(exports, 'startServer', {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
get: function () {
|
|
128
|
+
return startServer;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
//# sourceMappingURL=src-Cv5xAnDV.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"src-Cv5xAnDV.cjs","names":["z","definedConfig: Config","StdioServerTransport","McpServer","process"],"sources":["../package.json","../src/schemas/generateSchema.ts","../src/tools/generate.ts","../src/index.ts"],"sourcesContent":["{\n \"name\": \"@kubb/mcp\",\n \"version\": \"3.16.3\",\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 },\n \"./server\": {\n \"import\": \"./dist/server.js\",\n \"require\": \"./dist/server.cjs\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.cts\",\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\": \"tsdown\",\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 --fix --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\": \"tsdown --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.17.3\",\n \"zod\": \"^3.25.76\"\n },\n \"devDependencies\": {\n \"@kubb/config-ts\": \"workspace:*\",\n \"@kubb/plugin-oas\": \"workspace:*\",\n \"@types/node\": \"catalog:\",\n \"@types/react\": \"catalog:\",\n \"tsdown\": \"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((file) => getSource(file, { extname: '.ts' }))\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 process from 'node:process'\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\nimport { version } from '../package.json'\nimport { generateSchema } from './schemas/generateSchema.ts'\nimport { generate } from './tools/generate.ts'\n\nexport async function startServer() {\n try {\n const transport = new StdioServerTransport()\n const server = new McpServer({\n name: 'Kubb',\n version,\n })\n\n server.tool('generate', 'generate an openAPI spec to a code snippet', generateSchema.shape, generate)\n\n await server.connect(transport)\n } catch (error) {\n console.error('Failed to start server:', error)\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEa;;;;ACAb,MAAa,iBAAiBA,MAAE,OAAO;CACrC,SAASA,MAAE,QAAQ,CAAC,QAAQ,8CAA8C,C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AQ,GAAG;EACV,MAAM,QAAQ;AAEd,SAAO;GACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,MAAM;GACb,CACF;GACD,SAAS;EACV;CACF;AACF;;;;AC7FD,eAAsB,cAAc;AAClC,KAAI;EACF,MAAM,YAAY,IAAIC;EACtB,MAAM,SAAS,IAAIC,mDAAU;GAC3B,MAAM;GACN;EACD;EAED,OAAO,KAAK,YAAY,8CAA8C,eAAe,OAAO,SAAS;EAErG,MAAM,OAAO,QAAQ,UAAU;CAChC,SAAQ,OAAO;EACd,QAAQ,MAAM,2BAA2B,MAAM;EAC/CC,qBAAQ,KAAK,EAAE;CAChB;AACF"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import process$1 from "node:process";
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
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 { getSource, safeBuild } from "@kubb/core";
|
|
9
|
+
|
|
10
|
+
//#region package.json
|
|
11
|
+
var version = "3.16.3";
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/schemas/generateSchema.ts
|
|
15
|
+
const generateSchema = z.object({
|
|
16
|
+
openApi: z.string().default("https://petstore.swagger.io/v2/swagger.json").describe("OpenAPI/Swagger spec"),
|
|
17
|
+
plugin: z.enum(["typescript", "react-query"]).describe("Plugin to use"),
|
|
18
|
+
operationId: z.string().nullable().optional().describe("Which operationId should be used")
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/tools/generate.ts
|
|
23
|
+
async function generate({ plugin, openApi, operationId }) {
|
|
24
|
+
try {
|
|
25
|
+
const include = [operationId ? {
|
|
26
|
+
type: "operationId",
|
|
27
|
+
pattern: operationId
|
|
28
|
+
} : void 0].filter(Boolean);
|
|
29
|
+
const plugins = [
|
|
30
|
+
pluginOas({
|
|
31
|
+
validate: false,
|
|
32
|
+
generators: []
|
|
33
|
+
}),
|
|
34
|
+
pluginTs({
|
|
35
|
+
output: { path: "typescript.ts" },
|
|
36
|
+
generators: plugin === "typescript" ? void 0 : [],
|
|
37
|
+
include
|
|
38
|
+
}),
|
|
39
|
+
pluginReactQuery({
|
|
40
|
+
output: { path: "react-query.ts" },
|
|
41
|
+
generators: plugin === "react-query" ? void 0 : [],
|
|
42
|
+
include
|
|
43
|
+
})
|
|
44
|
+
].filter(Boolean);
|
|
45
|
+
const definedConfig = {
|
|
46
|
+
root: process.cwd(),
|
|
47
|
+
input: { data: openApi },
|
|
48
|
+
output: {
|
|
49
|
+
path: "./",
|
|
50
|
+
write: false,
|
|
51
|
+
barrelType: "named"
|
|
52
|
+
},
|
|
53
|
+
plugins
|
|
54
|
+
};
|
|
55
|
+
const { files, error } = await safeBuild({ config: definedConfig });
|
|
56
|
+
if (error) return {
|
|
57
|
+
content: [{
|
|
58
|
+
type: "text",
|
|
59
|
+
text: error.message
|
|
60
|
+
}],
|
|
61
|
+
isError: true
|
|
62
|
+
};
|
|
63
|
+
const promises = files.map((file) => getSource(file, { extname: ".ts" }));
|
|
64
|
+
const sources = await Promise.all(promises);
|
|
65
|
+
return { content: [{
|
|
66
|
+
type: "text",
|
|
67
|
+
text: `Config: ${JSON.stringify(definedConfig, null, 2)}`
|
|
68
|
+
}, {
|
|
69
|
+
type: "text",
|
|
70
|
+
text: `Files: ${JSON.stringify(sources, null, 2)}`
|
|
71
|
+
}] };
|
|
72
|
+
} catch (e) {
|
|
73
|
+
const error = e;
|
|
74
|
+
return {
|
|
75
|
+
content: [{
|
|
76
|
+
type: "text",
|
|
77
|
+
text: error.message
|
|
78
|
+
}],
|
|
79
|
+
isError: true
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/index.ts
|
|
86
|
+
async function startServer() {
|
|
87
|
+
try {
|
|
88
|
+
const transport = new StdioServerTransport();
|
|
89
|
+
const server = new McpServer({
|
|
90
|
+
name: "Kubb",
|
|
91
|
+
version
|
|
92
|
+
});
|
|
93
|
+
server.tool("generate", "generate an openAPI spec to a code snippet", generateSchema.shape, generate);
|
|
94
|
+
await server.connect(transport);
|
|
95
|
+
} catch (error) {
|
|
96
|
+
console.error("Failed to start server:", error);
|
|
97
|
+
process$1.exit(1);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
export { startServer };
|
|
103
|
+
//# sourceMappingURL=src-DNKD2dn4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"src-DNKD2dn4.js","names":["definedConfig: Config","process"],"sources":["../package.json","../src/schemas/generateSchema.ts","../src/tools/generate.ts","../src/index.ts"],"sourcesContent":["{\n \"name\": \"@kubb/mcp\",\n \"version\": \"3.16.3\",\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 },\n \"./server\": {\n \"import\": \"./dist/server.js\",\n \"require\": \"./dist/server.cjs\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.cts\",\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\": \"tsdown\",\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 --fix --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\": \"tsdown --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.17.3\",\n \"zod\": \"^3.25.76\"\n },\n \"devDependencies\": {\n \"@kubb/config-ts\": \"workspace:*\",\n \"@kubb/plugin-oas\": \"workspace:*\",\n \"@types/node\": \"catalog:\",\n \"@types/react\": \"catalog:\",\n \"tsdown\": \"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((file) => getSource(file, { extname: '.ts' }))\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 process from 'node:process'\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\nimport { version } from '../package.json'\nimport { generateSchema } from './schemas/generateSchema.ts'\nimport { generate } from './tools/generate.ts'\n\nexport async function startServer() {\n try {\n const transport = new StdioServerTransport()\n const server = new McpServer({\n name: 'Kubb',\n version,\n })\n\n server.tool('generate', 'generate an openAPI spec to a code snippet', generateSchema.shape, generate)\n\n await server.connect(transport)\n } catch (error) {\n console.error('Failed to start server:', error)\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;cAEa;;;;ACAb,MAAa,iBAAiB,EAAE,OAAO;CACrC,SAAS,EAAE,QAAQ,CAAC,QAAQ,8CAA8C,CAAC,SAAS,uBAAuB;CAC3G,QAAQ,EAAE,KAAK,CAAC,cAAc,aAAc,EAAC,CAAC,SAAS,gBAAgB;CACvE,aAAa,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,SAAS,mCAAmC;AAE3F,EAAC;;;;ACEF,eAAsB,SAAS,EAAE,QAAQ,SAAS,aAA6C,EAA2B;AACxH,KAAI;EACF,MAAM,UAAU,CACd,cACI;GACE,MAAM;GACN,SAAS;EACV,IACD,MACL,EAAC,OAAO,QAAQ;EAEjB,MAAM,UAAU;GACd,UAAU;IAAE,UAAU;IAAO,YAAY,CAAE;GAAE,EAAC;GAC9C,SAAS;IACP,QAAQ,EACN,MAAM,gBACP;IACD,YAAY,WAAW,eAAe,SAAY,CAAE;IACpD;GACD,EAAC;GACF,iBAAiB;IACf,QAAQ,EACN,MAAM,iBACP;IACD,YAAY,WAAW,gBAAgB,SAAY,CAAE;IACrD;GACD,EAAC;EACH,EAAC,OAAO,QAAQ;EAEjB,MAAMA,gBAAwB;GAC5B,MAAM,QAAQ,KAAK;GACnB,OAAO,EACL,MAAM,QACP;GACD,QAAQ;IACN,MAAM;IACN,OAAO;IACP,YAAY;GACb;GACD;EACD;EAED,MAAM,EAAE,OAAO,OAAO,GAAG,MAAM,UAAU,EACvC,QAAQ,cACT,EAAC;AAEF,MAAI,MACF,QAAO;GACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,MAAM;GACb,CACF;GACD,SAAS;EACV;EAGH,MAAM,WAAW,MAAM,IAAI,CAAC,SAAS,UAAU,MAAM,EAAE,SAAS,MAAO,EAAC,CAAC;EAEzE,MAAM,UAAU,MAAM,QAAQ,IAAI,SAAS;AAE3C,SAAO,EACL,SAAS,CAKP;GACE,MAAM;GACN,MAAM,CAAC,QAAQ,EAAE,KAAK,UAAU,eAAe,MAAM,EAAE,EAAE;EAC1D,GACD;GACE,MAAM;GACN,MAAM,CAAC,OAAO,EAAE,KAAK,UAAU,SAAS,MAAM,EAAE,EAAE;EACnD,CACF,EACF;CACF,SAAQ,GAAG;EACV,MAAM,QAAQ;AAEd,SAAO;GACL,SAAS,CACP;IACE,MAAM;IACN,MAAM,MAAM;GACb,CACF;GACD,SAAS;EACV;CACF;AACF;;;;AC7FD,eAAsB,cAAc;AAClC,KAAI;EACF,MAAM,YAAY,IAAI;EACtB,MAAM,SAAS,IAAI,UAAU;GAC3B,MAAM;GACN;EACD;EAED,OAAO,KAAK,YAAY,8CAA8C,eAAe,OAAO,SAAS;EAErG,MAAM,OAAO,QAAQ,UAAU;CAChC,SAAQ,OAAO;EACd,QAAQ,MAAM,2BAA2B,MAAM;EAC/CC,UAAQ,KAAK,EAAE;CAChB;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/mcp",
|
|
3
|
-
"version": "3.16.
|
|
3
|
+
"version": "3.16.3",
|
|
4
4
|
"description": "Generator MCP",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -21,18 +21,17 @@
|
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
23
|
"import": "./dist/index.js",
|
|
24
|
-
"require": "./dist/index.cjs"
|
|
25
|
-
"default": "./dist/index.cjs"
|
|
24
|
+
"require": "./dist/index.cjs"
|
|
26
25
|
},
|
|
27
26
|
"./server": {
|
|
28
27
|
"import": "./dist/server.js",
|
|
29
|
-
"require": "./dist/server.cjs"
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
"require": "./dist/server.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
32
31
|
},
|
|
33
|
-
"main": "dist/index.cjs",
|
|
34
|
-
"module": "dist/index.js",
|
|
35
|
-
"types": "./dist/index.d.
|
|
32
|
+
"main": "./dist/index.cjs",
|
|
33
|
+
"module": "./dist/index.js",
|
|
34
|
+
"types": "./dist/index.d.cts",
|
|
36
35
|
"typesVersions": {
|
|
37
36
|
"*": {
|
|
38
37
|
"server": [
|
|
@@ -47,30 +46,29 @@
|
|
|
47
46
|
"!/**/__tests__/**"
|
|
48
47
|
],
|
|
49
48
|
"dependencies": {
|
|
50
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
49
|
+
"@modelcontextprotocol/sdk": "^1.17.3",
|
|
51
50
|
"zod": "^3.25.76",
|
|
52
|
-
"@kubb/core": "3.16.
|
|
53
|
-
"@kubb/plugin-client": "3.16.
|
|
54
|
-
"@kubb/plugin-cypress": "3.16.
|
|
55
|
-
"@kubb/plugin-faker": "3.16.
|
|
56
|
-
"@kubb/plugin-mcp": "3.16.
|
|
57
|
-
"@kubb/plugin-msw": "3.16.
|
|
58
|
-
"@kubb/plugin-oas": "3.16.
|
|
59
|
-
"@kubb/plugin-react-query": "3.16.
|
|
60
|
-
"@kubb/plugin-redoc": "3.16.
|
|
61
|
-
"@kubb/plugin-swr": "3.16.
|
|
62
|
-
"@kubb/plugin-ts": "3.16.
|
|
63
|
-
"@kubb/plugin-zod": "3.16.
|
|
64
|
-
"@kubb/react": "3.16.
|
|
51
|
+
"@kubb/core": "3.16.3",
|
|
52
|
+
"@kubb/plugin-client": "3.16.3",
|
|
53
|
+
"@kubb/plugin-cypress": "3.16.3",
|
|
54
|
+
"@kubb/plugin-faker": "3.16.3",
|
|
55
|
+
"@kubb/plugin-mcp": "3.16.3",
|
|
56
|
+
"@kubb/plugin-msw": "3.16.3",
|
|
57
|
+
"@kubb/plugin-oas": "3.16.3",
|
|
58
|
+
"@kubb/plugin-react-query": "3.16.3",
|
|
59
|
+
"@kubb/plugin-redoc": "3.16.3",
|
|
60
|
+
"@kubb/plugin-swr": "3.16.3",
|
|
61
|
+
"@kubb/plugin-ts": "3.16.3",
|
|
62
|
+
"@kubb/plugin-zod": "3.16.3",
|
|
63
|
+
"@kubb/react": "3.16.3"
|
|
65
64
|
},
|
|
66
65
|
"devDependencies": {
|
|
67
|
-
"@types/node": "^20.19.
|
|
66
|
+
"@types/node": "^20.19.11",
|
|
68
67
|
"@types/react": "^18.3.23",
|
|
69
|
-
"
|
|
70
|
-
"typescript": "^5.
|
|
71
|
-
"@kubb/config-ts": "3.16.
|
|
72
|
-
"@kubb/
|
|
73
|
-
"@kubb/plugin-oas": "3.16.1"
|
|
68
|
+
"tsdown": "^0.14.1",
|
|
69
|
+
"typescript": "^5.9.2",
|
|
70
|
+
"@kubb/config-ts": "3.16.3",
|
|
71
|
+
"@kubb/plugin-oas": "3.16.3"
|
|
74
72
|
},
|
|
75
73
|
"engines": {
|
|
76
74
|
"node": ">=20"
|
|
@@ -80,15 +78,15 @@
|
|
|
80
78
|
"registry": "https://registry.npmjs.org/"
|
|
81
79
|
},
|
|
82
80
|
"scripts": {
|
|
83
|
-
"build": "
|
|
81
|
+
"build": "tsdown",
|
|
84
82
|
"start:mcp": "bun --watch ./src/server.ts",
|
|
85
83
|
"debug:mcp": "npx -y @modelcontextprotocol/inspector node ./dist/server.js",
|
|
86
84
|
"clean": "npx rimraf ./dist",
|
|
87
85
|
"lint": "bun biome lint .",
|
|
88
|
-
"lint:fix": "bun biome lint--fix --unsafe .",
|
|
86
|
+
"lint:fix": "bun biome lint --fix --unsafe .",
|
|
89
87
|
"release": "pnpm publish --no-git-check",
|
|
90
88
|
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
|
|
91
|
-
"start": "
|
|
89
|
+
"start": "tsdown --watch",
|
|
92
90
|
"test": "vitest --passWithNoTests",
|
|
93
91
|
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
|
|
94
92
|
}
|
package/dist/chunk-6D3KBU4P.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import process2 from 'process';
|
|
2
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
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, getSource } from '@kubb/core';
|
|
9
|
-
|
|
10
|
-
// src/index.ts
|
|
11
|
-
|
|
12
|
-
// package.json
|
|
13
|
-
var version = "3.16.1";
|
|
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
|
-
const promises = files.map((file) => getSource(file, { extname: ".ts" }));
|
|
72
|
-
const sources = await Promise.all(promises);
|
|
73
|
-
return {
|
|
74
|
-
content: [
|
|
75
|
-
// {
|
|
76
|
-
// type: 'resource',
|
|
77
|
-
// resource: {}
|
|
78
|
-
// },
|
|
79
|
-
{
|
|
80
|
-
type: "text",
|
|
81
|
-
text: `Config: ${JSON.stringify(definedConfig, null, 2)}`
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
type: "text",
|
|
85
|
-
text: `Files: ${JSON.stringify(sources, null, 2)}`
|
|
86
|
-
}
|
|
87
|
-
]
|
|
88
|
-
};
|
|
89
|
-
} catch (e) {
|
|
90
|
-
const error = e;
|
|
91
|
-
return {
|
|
92
|
-
content: [
|
|
93
|
-
{
|
|
94
|
-
type: "text",
|
|
95
|
-
text: error.message
|
|
96
|
-
}
|
|
97
|
-
],
|
|
98
|
-
isError: true
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// src/index.ts
|
|
104
|
-
async function startServer() {
|
|
105
|
-
try {
|
|
106
|
-
const transport = new StdioServerTransport();
|
|
107
|
-
const server = new McpServer({
|
|
108
|
-
name: "Kubb",
|
|
109
|
-
version
|
|
110
|
-
});
|
|
111
|
-
server.tool("generate", "generate an openAPI spec to a code snippet", generateSchema.shape, generate);
|
|
112
|
-
await server.connect(transport);
|
|
113
|
-
} catch (error) {
|
|
114
|
-
console.error("Failed to start server:", error);
|
|
115
|
-
process2.exit(1);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export { startServer };
|
|
120
|
-
//# sourceMappingURL=chunk-6D3KBU4P.js.map
|
|
121
|
-
//# sourceMappingURL=chunk-6D3KBU4P.js.map
|
|
@@ -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,EA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KAAA,CAAM,2BAA2B,KAAK,CAAA;AAC9C,IAAAA,QAAAA,CAAQ,KAAK,CAAC,CAAA;AAAA;AAElB","file":"chunk-6D3KBU4P.js","sourcesContent":["{\n \"name\": \"@kubb/mcp\",\n \"version\": \"3.16.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--fix --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.15.1\",\n \"zod\": \"^3.25.76\"\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((file) => getSource(file, { extname: '.ts' }))\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 process from 'node:process'\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\nimport { version } from '../package.json'\nimport { generateSchema } from './schemas/generateSchema.ts'\nimport { generate } from './tools/generate.ts'\n\nexport async function startServer() {\n try {\n const transport = new StdioServerTransport()\n const server = new McpServer({\n name: 'Kubb',\n version,\n })\n\n server.tool('generate', 'generate an openAPI spec to a code snippet', generateSchema.shape, generate)\n\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/chunk-6OXOQQQX.cjs
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var process2 = require('process');
|
|
4
|
-
var mcp_js = require('@modelcontextprotocol/sdk/server/mcp.js');
|
|
5
|
-
var stdio_js = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
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.16.1";
|
|
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
|
-
const promises = files.map((file) => core.getSource(file, { extname: ".ts" }));
|
|
78
|
-
const sources = await Promise.all(promises);
|
|
79
|
-
return {
|
|
80
|
-
content: [
|
|
81
|
-
// {
|
|
82
|
-
// type: 'resource',
|
|
83
|
-
// resource: {}
|
|
84
|
-
// },
|
|
85
|
-
{
|
|
86
|
-
type: "text",
|
|
87
|
-
text: `Config: ${JSON.stringify(definedConfig, null, 2)}`
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
type: "text",
|
|
91
|
-
text: `Files: ${JSON.stringify(sources, null, 2)}`
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
};
|
|
95
|
-
} catch (e) {
|
|
96
|
-
const error = e;
|
|
97
|
-
return {
|
|
98
|
-
content: [
|
|
99
|
-
{
|
|
100
|
-
type: "text",
|
|
101
|
-
text: error.message
|
|
102
|
-
}
|
|
103
|
-
],
|
|
104
|
-
isError: true
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// src/index.ts
|
|
110
|
-
async function startServer() {
|
|
111
|
-
try {
|
|
112
|
-
const transport = new stdio_js.StdioServerTransport();
|
|
113
|
-
const server = new mcp_js.McpServer({
|
|
114
|
-
name: "Kubb",
|
|
115
|
-
version
|
|
116
|
-
});
|
|
117
|
-
server.tool("generate", "generate an openAPI spec to a code snippet", generateSchema.shape, generate);
|
|
118
|
-
await server.connect(transport);
|
|
119
|
-
} catch (error) {
|
|
120
|
-
console.error("Failed to start server:", error);
|
|
121
|
-
process2__default.default.exit(1);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
exports.startServer = startServer;
|
|
126
|
-
//# sourceMappingURL=chunk-6OXOQQQX.cjs.map
|
|
127
|
-
//# sourceMappingURL=chunk-6OXOQQQX.cjs.map
|
|
@@ -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","getSource","StdioServerTransport","McpServer","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,O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AA;AAC9C,IAAAC,yBAAAA,CAAQ,KAAK,CAAC,CAAA;AAAA;AAElB","file":"chunk-6OXOQQQX.cjs","sourcesContent":["{\n \"name\": \"@kubb/mcp\",\n \"version\": \"3.16.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--fix --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.15.1\",\n \"zod\": \"^3.25.76\"\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((file) => getSource(file, { extname: '.ts' }))\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 process from 'node:process'\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\nimport { version } from '../package.json'\nimport { generateSchema } from './schemas/generateSchema.ts'\nimport { generate } from './tools/generate.ts'\n\nexport async function startServer() {\n try {\n const transport = new StdioServerTransport()\n const server = new McpServer({\n name: 'Kubb',\n version,\n })\n\n server.tool('generate', 'generate an openAPI spec to a code snippet', generateSchema.shape, generate)\n\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.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|