@kubb/mcp 3.10.0 → 3.10.1
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/chunk-3EYAJYBE.js +123 -0
- package/dist/chunk-3EYAJYBE.js.map +1 -0
- package/dist/chunk-A4QFMFDL.cjs +130 -0
- package/dist/chunk-A4QFMFDL.cjs.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.js +1 -1
- package/dist/server.cjs +2 -2
- package/dist/server.js +1 -1
- package/package.json +17 -17
- package/src/index.ts +5 -113
- package/src/schemas/generateSchema.ts +8 -0
- package/src/tools/generate.ts +104 -0
- package/dist/chunk-45YOYPRS.cjs +0 -134
- package/dist/chunk-45YOYPRS.cjs.map +0 -1
- package/dist/chunk-SAQBYPC4.js +0 -127
- package/dist/chunk-SAQBYPC4.js.map +0 -1
|
@@ -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.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
|
+
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-3EYAJYBE.js.map
|
|
123
|
+
//# sourceMappingURL=chunk-3EYAJYBE.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,IA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B,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"]}
|
|
@@ -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.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
|
+
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-A4QFMFDL.cjs.map
|
|
130
|
+
//# sourceMappingURL=chunk-A4QFMFDL.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,C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AAQ,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"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkA4QFMFDL_cjs = require('./chunk-A4QFMFDL.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "server", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkA4QFMFDL_cjs.server; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "startServer", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkA4QFMFDL_cjs.startServer; }
|
|
14
14
|
});
|
|
15
15
|
//# sourceMappingURL=index.cjs.map
|
|
16
16
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
package/dist/server.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkA4QFMFDL_cjs = require('./chunk-A4QFMFDL.cjs');
|
|
4
4
|
|
|
5
5
|
// src/server.ts
|
|
6
|
-
|
|
6
|
+
chunkA4QFMFDL_cjs.startServer();
|
|
7
7
|
//# sourceMappingURL=server.cjs.map
|
|
8
8
|
//# sourceMappingURL=server.cjs.map
|
package/dist/server.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/mcp",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.1",
|
|
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/
|
|
53
|
-
"@kubb/plugin-
|
|
54
|
-
"@kubb/
|
|
55
|
-
"@kubb/plugin-faker": "3.10.
|
|
56
|
-
"@kubb/plugin-
|
|
57
|
-
"@kubb/plugin-
|
|
58
|
-
"@kubb/plugin-oas": "3.10.
|
|
59
|
-
"@kubb/plugin-react-query": "3.10.
|
|
60
|
-
"@kubb/plugin-redoc": "3.10.
|
|
61
|
-
"@kubb/plugin-swr": "3.10.
|
|
62
|
-
"@kubb/plugin-ts": "3.10.
|
|
63
|
-
"@kubb/plugin-zod": "3.10.
|
|
64
|
-
"@kubb/react": "3.10.
|
|
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"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@types/node": "^20.17.30",
|
|
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.
|
|
72
|
-
"@kubb/config-tsup": "3.10.
|
|
73
|
-
"@kubb/plugin-oas": "3.10.
|
|
71
|
+
"@kubb/config-ts": "3.10.1",
|
|
72
|
+
"@kubb/config-tsup": "3.10.1",
|
|
73
|
+
"@kubb/plugin-oas": "3.10.1"
|
|
74
74
|
},
|
|
75
75
|
"engines": {
|
|
76
76
|
"node": ">=20"
|
package/src/index.ts
CHANGED
|
@@ -1,126 +1,18 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
2
2
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
import { version } from '../package.json'
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
import process from 'node:process'
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { pluginReactQuery } from '@kubb/plugin-react-query'
|
|
7
|
+
import { generateSchema } from './schemas/generateSchema.ts'
|
|
8
|
+
import { generate } from './tools/generate.ts'
|
|
10
9
|
|
|
11
10
|
export const server = new McpServer({
|
|
12
11
|
name: 'Kubb',
|
|
13
12
|
version,
|
|
14
13
|
})
|
|
15
14
|
|
|
16
|
-
server.tool(
|
|
17
|
-
'kubbify',
|
|
18
|
-
'kubbify an openAPI spec to a code snippet',
|
|
19
|
-
{
|
|
20
|
-
openApi: z.string().default('https://petstore.swagger.io/v2/swagger.json').describe('OpenAPI/Swagger spec'),
|
|
21
|
-
plugin: z.enum(['typescript', 'react-query']).describe('Plugin to use'),
|
|
22
|
-
operationId: z.string().nullable().optional().describe('Which operationId should be used'),
|
|
23
|
-
// schemaName: z.string().nullable().optional().describe('Which schema should be used'),
|
|
24
|
-
},
|
|
25
|
-
async ({ plugin, openApi, operationId }) => {
|
|
26
|
-
try {
|
|
27
|
-
const definedConfig: Config = {
|
|
28
|
-
root: process.cwd(),
|
|
29
|
-
input: {
|
|
30
|
-
data: openApi,
|
|
31
|
-
},
|
|
32
|
-
output: {
|
|
33
|
-
path: './',
|
|
34
|
-
write: false,
|
|
35
|
-
barrelType: 'named',
|
|
36
|
-
},
|
|
37
|
-
plugins: [
|
|
38
|
-
pluginOas({ validate: false, generators: [] }),
|
|
39
|
-
pluginTs({
|
|
40
|
-
output: {
|
|
41
|
-
path: 'typescript.ts',
|
|
42
|
-
},
|
|
43
|
-
generators: plugin === 'typescript' ? undefined : [],
|
|
44
|
-
include: [
|
|
45
|
-
operationId
|
|
46
|
-
? {
|
|
47
|
-
type: 'operationId',
|
|
48
|
-
pattern: operationId,
|
|
49
|
-
}
|
|
50
|
-
: undefined,
|
|
51
|
-
].filter(Boolean) as any[],
|
|
52
|
-
}),
|
|
53
|
-
pluginReactQuery({
|
|
54
|
-
output: {
|
|
55
|
-
path: 'react-query.ts',
|
|
56
|
-
},
|
|
57
|
-
generators: plugin === 'react-query' ? undefined : [],
|
|
58
|
-
include: [
|
|
59
|
-
operationId
|
|
60
|
-
? {
|
|
61
|
-
type: 'operationId',
|
|
62
|
-
pattern: operationId,
|
|
63
|
-
}
|
|
64
|
-
: undefined,
|
|
65
|
-
].filter(Boolean) as any[],
|
|
66
|
-
}),
|
|
67
|
-
].filter(Boolean) as Plugin[],
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const { files, error } = await safeBuild({
|
|
71
|
-
config: definedConfig,
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
if (error) {
|
|
75
|
-
return {
|
|
76
|
-
content: [
|
|
77
|
-
{
|
|
78
|
-
type: 'text',
|
|
79
|
-
text: error.message,
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
isError: true,
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return {
|
|
87
|
-
content: [
|
|
88
|
-
// {
|
|
89
|
-
// type: 'resource',
|
|
90
|
-
// resource: {}
|
|
91
|
-
// },
|
|
92
|
-
{
|
|
93
|
-
type: 'text',
|
|
94
|
-
text: `Config: ${JSON.stringify(definedConfig, null, 2)}`,
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
type: 'text',
|
|
98
|
-
text: `Files: ${JSON.stringify(
|
|
99
|
-
files
|
|
100
|
-
.flatMap((file) => file.sources)
|
|
101
|
-
.map((source) => source.value)
|
|
102
|
-
.join('\n\n'),
|
|
103
|
-
null,
|
|
104
|
-
2,
|
|
105
|
-
)}`,
|
|
106
|
-
},
|
|
107
|
-
],
|
|
108
|
-
}
|
|
109
|
-
} catch (e) {
|
|
110
|
-
const error = e as Error
|
|
111
|
-
|
|
112
|
-
return {
|
|
113
|
-
content: [
|
|
114
|
-
{
|
|
115
|
-
type: 'text',
|
|
116
|
-
text: error.message,
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
isError: true,
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
)
|
|
15
|
+
server.tool('generate', 'generate an openAPI spec to a code snippet', generateSchema.shape, generate)
|
|
124
16
|
|
|
125
17
|
export async function startServer() {
|
|
126
18
|
try {
|
|
@@ -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
|
+
})
|
|
@@ -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
|
+
}
|
package/dist/chunk-45YOYPRS.cjs
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
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 zod = require('zod');
|
|
6
|
-
var core = require('@kubb/core');
|
|
7
|
-
var process = require('process');
|
|
8
|
-
var pluginTs = require('@kubb/plugin-ts');
|
|
9
|
-
var pluginOas = require('@kubb/plugin-oas');
|
|
10
|
-
var pluginReactQuery = require('@kubb/plugin-react-query');
|
|
11
|
-
|
|
12
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
|
|
14
|
-
var process__default = /*#__PURE__*/_interopDefault(process);
|
|
15
|
-
|
|
16
|
-
// src/index.ts
|
|
17
|
-
|
|
18
|
-
// package.json
|
|
19
|
-
var version = "3.10.0";
|
|
20
|
-
var server = new mcp_js.McpServer({
|
|
21
|
-
name: "Kubb",
|
|
22
|
-
version
|
|
23
|
-
});
|
|
24
|
-
server.tool(
|
|
25
|
-
"kubbify",
|
|
26
|
-
"kubbify an openAPI spec to a code snippet",
|
|
27
|
-
{
|
|
28
|
-
openApi: zod.z.string().default("https://petstore.swagger.io/v2/swagger.json").describe("OpenAPI/Swagger spec"),
|
|
29
|
-
plugin: zod.z.enum(["typescript", "react-query"]).describe("Plugin to use"),
|
|
30
|
-
operationId: zod.z.string().nullable().optional().describe("Which operationId should be used")
|
|
31
|
-
// schemaName: z.string().nullable().optional().describe('Which schema should be used'),
|
|
32
|
-
},
|
|
33
|
-
async ({ plugin, openApi, operationId }) => {
|
|
34
|
-
try {
|
|
35
|
-
const definedConfig = {
|
|
36
|
-
root: process__default.default.cwd(),
|
|
37
|
-
input: {
|
|
38
|
-
data: openApi
|
|
39
|
-
},
|
|
40
|
-
output: {
|
|
41
|
-
path: "./",
|
|
42
|
-
write: false,
|
|
43
|
-
barrelType: "named"
|
|
44
|
-
},
|
|
45
|
-
plugins: [
|
|
46
|
-
pluginOas.pluginOas({ validate: false, generators: [] }),
|
|
47
|
-
pluginTs.pluginTs({
|
|
48
|
-
output: {
|
|
49
|
-
path: "typescript.ts"
|
|
50
|
-
},
|
|
51
|
-
generators: plugin === "typescript" ? void 0 : [],
|
|
52
|
-
include: [
|
|
53
|
-
operationId ? {
|
|
54
|
-
type: "operationId",
|
|
55
|
-
pattern: operationId
|
|
56
|
-
} : void 0
|
|
57
|
-
].filter(Boolean)
|
|
58
|
-
}),
|
|
59
|
-
pluginReactQuery.pluginReactQuery({
|
|
60
|
-
output: {
|
|
61
|
-
path: "react-query.ts"
|
|
62
|
-
},
|
|
63
|
-
generators: plugin === "react-query" ? void 0 : [],
|
|
64
|
-
include: [
|
|
65
|
-
operationId ? {
|
|
66
|
-
type: "operationId",
|
|
67
|
-
pattern: operationId
|
|
68
|
-
} : void 0
|
|
69
|
-
].filter(Boolean)
|
|
70
|
-
})
|
|
71
|
-
].filter(Boolean)
|
|
72
|
-
};
|
|
73
|
-
const { files, error } = await core.safeBuild({
|
|
74
|
-
config: definedConfig
|
|
75
|
-
});
|
|
76
|
-
if (error) {
|
|
77
|
-
return {
|
|
78
|
-
content: [
|
|
79
|
-
{
|
|
80
|
-
type: "text",
|
|
81
|
-
text: error.message
|
|
82
|
-
}
|
|
83
|
-
],
|
|
84
|
-
isError: true
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
content: [
|
|
89
|
-
// {
|
|
90
|
-
// type: 'resource',
|
|
91
|
-
// resource: {}
|
|
92
|
-
// },
|
|
93
|
-
{
|
|
94
|
-
type: "text",
|
|
95
|
-
text: `Config: ${JSON.stringify(definedConfig, null, 2)}`
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
type: "text",
|
|
99
|
-
text: `Files: ${JSON.stringify(
|
|
100
|
-
files.flatMap((file) => file.sources).map((source) => source.value).join("\n\n"),
|
|
101
|
-
null,
|
|
102
|
-
2
|
|
103
|
-
)}`
|
|
104
|
-
}
|
|
105
|
-
]
|
|
106
|
-
};
|
|
107
|
-
} catch (e) {
|
|
108
|
-
const error = e;
|
|
109
|
-
return {
|
|
110
|
-
content: [
|
|
111
|
-
{
|
|
112
|
-
type: "text",
|
|
113
|
-
text: error.message
|
|
114
|
-
}
|
|
115
|
-
],
|
|
116
|
-
isError: true
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
);
|
|
121
|
-
async function startServer() {
|
|
122
|
-
try {
|
|
123
|
-
const transport = new stdio_js.StdioServerTransport();
|
|
124
|
-
await server.connect(transport);
|
|
125
|
-
} catch (error) {
|
|
126
|
-
console.error("Failed to start server:", error);
|
|
127
|
-
process__default.default.exit(1);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
exports.server = server;
|
|
132
|
-
exports.startServer = startServer;
|
|
133
|
-
//# sourceMappingURL=chunk-45YOYPRS.cjs.map
|
|
134
|
-
//# sourceMappingURL=chunk-45YOYPRS.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/index.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,KAAK,MAAM,CAAA;AAAA,cACd,IAAA;AAAA,cACA;AAAA,aACD,CAAA;AAAA;AACH;AACF,OACF;AAAA,aACO,CAAG,EAAA;AACV,MAAA,MAAM,KAAQ,GAAA,CAAA;AAEd,MAAO,OAAA;AAAA,QACL,OAAS,EAAA;AAAA,UACP;AAAA,YACE,IAAM,EAAA,MAAA;AAAA,YACN,MAAM,KAAM,CAAA;AAAA;AACd,SACF;AAAA,QACA,OAAS,EAAA;AAAA,OACX;AAAA;AACF;AAEJ,CAAA;AAEA,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,IAAAL,wBAAA,CAAQ,KAAK,CAAC,CAAA;AAAA;AAElB","file":"chunk-45YOYPRS.cjs","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 { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\nimport { z } from 'zod'\nimport { version } from '../package.json'\nimport { type Config, type Plugin, safeBuild } from '@kubb/core'\nimport process from 'node:process'\nimport { pluginTs } from '@kubb/plugin-ts'\nimport { pluginOas } from '@kubb/plugin-oas'\nimport { pluginReactQuery } from '@kubb/plugin-react-query'\n\nexport const server = new McpServer({\n name: 'Kubb',\n version,\n})\n\nserver.tool(\n 'kubbify',\n 'kubbify an openAPI spec to a code snippet',\n {\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 async ({ plugin, openApi, operationId }) => {\n try {\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 pluginOas({ validate: false, generators: [] }),\n pluginTs({\n output: {\n path: 'typescript.ts',\n },\n generators: plugin === 'typescript' ? undefined : [],\n include: [\n operationId\n ? {\n type: 'operationId',\n pattern: operationId,\n }\n : undefined,\n ].filter(Boolean) as any[],\n }),\n pluginReactQuery({\n output: {\n path: 'react-query.ts',\n },\n generators: plugin === 'react-query' ? undefined : [],\n include: [\n operationId\n ? {\n type: 'operationId',\n pattern: operationId,\n }\n : undefined,\n ].filter(Boolean) as any[],\n }),\n ].filter(Boolean) as Plugin[],\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)\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/chunk-SAQBYPC4.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
import { safeBuild } from '@kubb/core';
|
|
5
|
-
import process from 'node:process';
|
|
6
|
-
import { pluginTs } from '@kubb/plugin-ts';
|
|
7
|
-
import { pluginOas } from '@kubb/plugin-oas';
|
|
8
|
-
import { pluginReactQuery } from '@kubb/plugin-react-query';
|
|
9
|
-
|
|
10
|
-
// src/index.ts
|
|
11
|
-
|
|
12
|
-
// package.json
|
|
13
|
-
var version = "3.10.0";
|
|
14
|
-
var server = new McpServer({
|
|
15
|
-
name: "Kubb",
|
|
16
|
-
version
|
|
17
|
-
});
|
|
18
|
-
server.tool(
|
|
19
|
-
"kubbify",
|
|
20
|
-
"kubbify an openAPI spec to a code snippet",
|
|
21
|
-
{
|
|
22
|
-
openApi: z.string().default("https://petstore.swagger.io/v2/swagger.json").describe("OpenAPI/Swagger spec"),
|
|
23
|
-
plugin: z.enum(["typescript", "react-query"]).describe("Plugin to use"),
|
|
24
|
-
operationId: z.string().nullable().optional().describe("Which operationId should be used")
|
|
25
|
-
// schemaName: z.string().nullable().optional().describe('Which schema should be used'),
|
|
26
|
-
},
|
|
27
|
-
async ({ plugin, openApi, operationId }) => {
|
|
28
|
-
try {
|
|
29
|
-
const definedConfig = {
|
|
30
|
-
root: process.cwd(),
|
|
31
|
-
input: {
|
|
32
|
-
data: openApi
|
|
33
|
-
},
|
|
34
|
-
output: {
|
|
35
|
-
path: "./",
|
|
36
|
-
write: false,
|
|
37
|
-
barrelType: "named"
|
|
38
|
-
},
|
|
39
|
-
plugins: [
|
|
40
|
-
pluginOas({ validate: false, generators: [] }),
|
|
41
|
-
pluginTs({
|
|
42
|
-
output: {
|
|
43
|
-
path: "typescript.ts"
|
|
44
|
-
},
|
|
45
|
-
generators: plugin === "typescript" ? void 0 : [],
|
|
46
|
-
include: [
|
|
47
|
-
operationId ? {
|
|
48
|
-
type: "operationId",
|
|
49
|
-
pattern: operationId
|
|
50
|
-
} : void 0
|
|
51
|
-
].filter(Boolean)
|
|
52
|
-
}),
|
|
53
|
-
pluginReactQuery({
|
|
54
|
-
output: {
|
|
55
|
-
path: "react-query.ts"
|
|
56
|
-
},
|
|
57
|
-
generators: plugin === "react-query" ? void 0 : [],
|
|
58
|
-
include: [
|
|
59
|
-
operationId ? {
|
|
60
|
-
type: "operationId",
|
|
61
|
-
pattern: operationId
|
|
62
|
-
} : void 0
|
|
63
|
-
].filter(Boolean)
|
|
64
|
-
})
|
|
65
|
-
].filter(Boolean)
|
|
66
|
-
};
|
|
67
|
-
const { files, error } = await safeBuild({
|
|
68
|
-
config: definedConfig
|
|
69
|
-
});
|
|
70
|
-
if (error) {
|
|
71
|
-
return {
|
|
72
|
-
content: [
|
|
73
|
-
{
|
|
74
|
-
type: "text",
|
|
75
|
-
text: error.message
|
|
76
|
-
}
|
|
77
|
-
],
|
|
78
|
-
isError: true
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
content: [
|
|
83
|
-
// {
|
|
84
|
-
// type: 'resource',
|
|
85
|
-
// resource: {}
|
|
86
|
-
// },
|
|
87
|
-
{
|
|
88
|
-
type: "text",
|
|
89
|
-
text: `Config: ${JSON.stringify(definedConfig, null, 2)}`
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
type: "text",
|
|
93
|
-
text: `Files: ${JSON.stringify(
|
|
94
|
-
files.flatMap((file) => file.sources).map((source) => source.value).join("\n\n"),
|
|
95
|
-
null,
|
|
96
|
-
2
|
|
97
|
-
)}`
|
|
98
|
-
}
|
|
99
|
-
]
|
|
100
|
-
};
|
|
101
|
-
} catch (e) {
|
|
102
|
-
const error = e;
|
|
103
|
-
return {
|
|
104
|
-
content: [
|
|
105
|
-
{
|
|
106
|
-
type: "text",
|
|
107
|
-
text: error.message
|
|
108
|
-
}
|
|
109
|
-
],
|
|
110
|
-
isError: true
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
);
|
|
115
|
-
async function startServer() {
|
|
116
|
-
try {
|
|
117
|
-
const transport = new StdioServerTransport();
|
|
118
|
-
await server.connect(transport);
|
|
119
|
-
} catch (error) {
|
|
120
|
-
console.error("Failed to start server:", error);
|
|
121
|
-
process.exit(1);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export { server, startServer };
|
|
126
|
-
//# sourceMappingURL=chunk-SAQBYPC4.js.map
|
|
127
|
-
//# sourceMappingURL=chunk-SAQBYPC4.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEE,IAAW,OAAA,GAAA,QAAA;ACQA,IAAA,MAAA,GAAS,IAAI,SAAU,CAAA;AAAA,EAClC,IAAM,EAAA,MAAA;AAAA,EACN;AACF,CAAC;AAED,MAAO,CAAA,IAAA;AAAA,EACL,SAAA;AAAA,EACA,2CAAA;AAAA,EACA;AAAA,IACE,OAAA,EAAS,EAAE,MAAO,EAAA,CAAE,QAAQ,6CAA6C,CAAA,CAAE,SAAS,sBAAsB,CAAA;AAAA,IAC1G,MAAA,EAAQ,EAAE,IAAK,CAAA,CAAC,cAAc,aAAa,CAAC,CAAE,CAAA,QAAA,CAAS,eAAe,CAA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d,IAAQ,OAAA,CAAA,KAAA,CAAM,2BAA2B,KAAK,CAAA;AAC9C,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA;AAElB","file":"chunk-SAQBYPC4.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 { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\nimport { z } from 'zod'\nimport { version } from '../package.json'\nimport { type Config, type Plugin, safeBuild } from '@kubb/core'\nimport process from 'node:process'\nimport { pluginTs } from '@kubb/plugin-ts'\nimport { pluginOas } from '@kubb/plugin-oas'\nimport { pluginReactQuery } from '@kubb/plugin-react-query'\n\nexport const server = new McpServer({\n name: 'Kubb',\n version,\n})\n\nserver.tool(\n 'kubbify',\n 'kubbify an openAPI spec to a code snippet',\n {\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 async ({ plugin, openApi, operationId }) => {\n try {\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 pluginOas({ validate: false, generators: [] }),\n pluginTs({\n output: {\n path: 'typescript.ts',\n },\n generators: plugin === 'typescript' ? undefined : [],\n include: [\n operationId\n ? {\n type: 'operationId',\n pattern: operationId,\n }\n : undefined,\n ].filter(Boolean) as any[],\n }),\n pluginReactQuery({\n output: {\n path: 'react-query.ts',\n },\n generators: plugin === 'react-query' ? undefined : [],\n include: [\n operationId\n ? {\n type: 'operationId',\n pattern: operationId,\n }\n : undefined,\n ].filter(Boolean) as any[],\n }),\n ].filter(Boolean) as Plugin[],\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)\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"]}
|