@kubb/plugin-mcp 5.0.0-alpha.27 → 5.0.0-alpha.29
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 +1041 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +221 -2
- package/dist/index.js +1014 -62
- package/dist/index.js.map +1 -1
- package/package.json +6 -31
- package/src/components/McpHandler.tsx +171 -0
- package/src/components/Server.tsx +86 -104
- package/src/generators/mcpGenerator.tsx +70 -83
- package/src/generators/serverGenerator.tsx +99 -57
- package/src/generators/serverGeneratorLegacy.tsx +144 -0
- package/src/index.ts +11 -1
- package/src/plugin.ts +76 -82
- package/src/presets.ts +25 -0
- package/src/resolvers/resolverMcp.ts +29 -0
- package/src/types.ts +51 -21
- package/src/utils.ts +97 -0
- package/dist/Server-EjbvNRYy.cjs +0 -231
- package/dist/Server-EjbvNRYy.cjs.map +0 -1
- package/dist/Server-kM1BVYP3.js +0 -183
- package/dist/Server-kM1BVYP3.js.map +0 -1
- package/dist/components.cjs +0 -3
- package/dist/components.d.ts +0 -41
- package/dist/components.js +0 -2
- package/dist/generators-Cc2InAz4.js +0 -274
- package/dist/generators-Cc2InAz4.js.map +0 -1
- package/dist/generators-CzP7VKQw.cjs +0 -285
- package/dist/generators-CzP7VKQw.cjs.map +0 -1
- package/dist/generators.cjs +0 -4
- package/dist/generators.d.ts +0 -12
- package/dist/generators.js +0 -2
- package/dist/types-DNDVb19t.d.ts +0 -64
- package/src/components/index.ts +0 -1
- package/src/generators/index.ts +0 -2
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import { t as Server } from "./Server-kM1BVYP3.js";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { pluginTsName } from "@kubb/plugin-ts";
|
|
5
|
-
import { pluginZodName } from "@kubb/plugin-zod";
|
|
6
|
-
import { Client } from "@kubb/plugin-client/components";
|
|
7
|
-
import { createReactGenerator } from "@kubb/plugin-oas/generators";
|
|
8
|
-
import { useOas, useOperationManager } from "@kubb/plugin-oas/hooks";
|
|
9
|
-
import { getBanner, getFooter } from "@kubb/plugin-oas/utils";
|
|
10
|
-
import { File } from "@kubb/react-fabric";
|
|
11
|
-
import { Fragment, jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
|
|
12
|
-
import { useDriver } from "@kubb/core/hooks";
|
|
13
|
-
//#region src/generators/mcpGenerator.tsx
|
|
14
|
-
const mcpGenerator = createReactGenerator({
|
|
15
|
-
name: "mcp",
|
|
16
|
-
Operation({ config, operation, generator, plugin }) {
|
|
17
|
-
const { options } = plugin;
|
|
18
|
-
const oas = useOas();
|
|
19
|
-
const { getSchemas, getName, getFile } = useOperationManager(generator);
|
|
20
|
-
const mcp = {
|
|
21
|
-
name: getName(operation, {
|
|
22
|
-
type: "function",
|
|
23
|
-
suffix: "handler"
|
|
24
|
-
}),
|
|
25
|
-
file: getFile(operation)
|
|
26
|
-
};
|
|
27
|
-
const type = {
|
|
28
|
-
file: getFile(operation, { pluginName: pluginTsName }),
|
|
29
|
-
schemas: getSchemas(operation, {
|
|
30
|
-
pluginName: pluginTsName,
|
|
31
|
-
type: "type"
|
|
32
|
-
})
|
|
33
|
-
};
|
|
34
|
-
return /* @__PURE__ */ jsxs(File, {
|
|
35
|
-
baseName: mcp.file.baseName,
|
|
36
|
-
path: mcp.file.path,
|
|
37
|
-
meta: mcp.file.meta,
|
|
38
|
-
banner: getBanner({
|
|
39
|
-
oas,
|
|
40
|
-
output: options.output
|
|
41
|
-
}),
|
|
42
|
-
footer: getFooter({
|
|
43
|
-
oas,
|
|
44
|
-
output: options.output
|
|
45
|
-
}),
|
|
46
|
-
children: [
|
|
47
|
-
options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
48
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
49
|
-
name: "fetch",
|
|
50
|
-
path: options.client.importPath
|
|
51
|
-
}),
|
|
52
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
53
|
-
name: [
|
|
54
|
-
"Client",
|
|
55
|
-
"RequestConfig",
|
|
56
|
-
"ResponseErrorConfig"
|
|
57
|
-
],
|
|
58
|
-
path: options.client.importPath,
|
|
59
|
-
isTypeOnly: true
|
|
60
|
-
}),
|
|
61
|
-
options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
|
|
62
|
-
name: ["ResponseConfig"],
|
|
63
|
-
path: options.client.importPath,
|
|
64
|
-
isTypeOnly: true
|
|
65
|
-
})
|
|
66
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
67
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
68
|
-
name: ["fetch"],
|
|
69
|
-
root: mcp.file.path,
|
|
70
|
-
path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
71
|
-
}),
|
|
72
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
73
|
-
name: [
|
|
74
|
-
"Client",
|
|
75
|
-
"RequestConfig",
|
|
76
|
-
"ResponseErrorConfig"
|
|
77
|
-
],
|
|
78
|
-
root: mcp.file.path,
|
|
79
|
-
path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
|
|
80
|
-
isTypeOnly: true
|
|
81
|
-
}),
|
|
82
|
-
options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
|
|
83
|
-
name: ["ResponseConfig"],
|
|
84
|
-
root: mcp.file.path,
|
|
85
|
-
path: path.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
|
|
86
|
-
isTypeOnly: true
|
|
87
|
-
})
|
|
88
|
-
] }),
|
|
89
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
90
|
-
name: ["buildFormData"],
|
|
91
|
-
root: mcp.file.path,
|
|
92
|
-
path: path.resolve(config.root, config.output.path, ".kubb/config.ts")
|
|
93
|
-
}),
|
|
94
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
95
|
-
name: ["CallToolResult"],
|
|
96
|
-
path: "@modelcontextprotocol/sdk/types",
|
|
97
|
-
isTypeOnly: true
|
|
98
|
-
}),
|
|
99
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
100
|
-
name: [
|
|
101
|
-
type.schemas.request?.name,
|
|
102
|
-
type.schemas.response.name,
|
|
103
|
-
type.schemas.pathParams?.name,
|
|
104
|
-
type.schemas.queryParams?.name,
|
|
105
|
-
type.schemas.headerParams?.name,
|
|
106
|
-
...type.schemas.statusCodes?.map((item) => item.name) || []
|
|
107
|
-
].filter(Boolean),
|
|
108
|
-
root: mcp.file.path,
|
|
109
|
-
path: type.file.path,
|
|
110
|
-
isTypeOnly: true
|
|
111
|
-
}),
|
|
112
|
-
/* @__PURE__ */ jsxs(Client, {
|
|
113
|
-
name: mcp.name,
|
|
114
|
-
isConfigurable: false,
|
|
115
|
-
returnType: "Promise<CallToolResult>",
|
|
116
|
-
baseURL: options.client.baseURL,
|
|
117
|
-
operation,
|
|
118
|
-
typeSchemas: type.schemas,
|
|
119
|
-
zodSchemas: void 0,
|
|
120
|
-
dataReturnType: options.client.dataReturnType || "data",
|
|
121
|
-
paramsType: "object",
|
|
122
|
-
paramsCasing: options.client?.paramsCasing || options.paramsCasing,
|
|
123
|
-
pathParamsType: "object",
|
|
124
|
-
parser: "client",
|
|
125
|
-
children: [options.client.dataReturnType === "data" && `return {
|
|
126
|
-
content: [
|
|
127
|
-
{
|
|
128
|
-
type: 'text',
|
|
129
|
-
text: JSON.stringify(res.data)
|
|
130
|
-
}
|
|
131
|
-
],
|
|
132
|
-
structuredContent: { data: res.data }
|
|
133
|
-
}`, options.client.dataReturnType === "full" && `return {
|
|
134
|
-
content: [
|
|
135
|
-
{
|
|
136
|
-
type: 'text',
|
|
137
|
-
text: JSON.stringify(res)
|
|
138
|
-
}
|
|
139
|
-
],
|
|
140
|
-
structuredContent: { data: res.data }
|
|
141
|
-
}`]
|
|
142
|
-
})
|
|
143
|
-
]
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
//#endregion
|
|
148
|
-
//#region src/generators/serverGenerator.tsx
|
|
149
|
-
const serverGenerator = createReactGenerator({
|
|
150
|
-
name: "operations",
|
|
151
|
-
Operations({ operations, generator, plugin }) {
|
|
152
|
-
const driver = useDriver();
|
|
153
|
-
const { options } = plugin;
|
|
154
|
-
const oas = useOas();
|
|
155
|
-
const { getFile, getName, getSchemas } = useOperationManager(generator);
|
|
156
|
-
const name = "server";
|
|
157
|
-
const file = driver.getFile({
|
|
158
|
-
name,
|
|
159
|
-
extname: ".ts",
|
|
160
|
-
pluginName: plugin.name
|
|
161
|
-
});
|
|
162
|
-
const jsonFile = driver.getFile({
|
|
163
|
-
name: ".mcp",
|
|
164
|
-
extname: ".json",
|
|
165
|
-
pluginName: plugin.name
|
|
166
|
-
});
|
|
167
|
-
const operationsMapped = operations.map((operation) => {
|
|
168
|
-
return {
|
|
169
|
-
tool: {
|
|
170
|
-
name: operation.getOperationId() || operation.getSummary() || `${operation.method.toUpperCase()} ${operation.path}`,
|
|
171
|
-
title: operation.getSummary() || void 0,
|
|
172
|
-
description: operation.getDescription() || `Make a ${operation.method.toUpperCase()} request to ${operation.path}`
|
|
173
|
-
},
|
|
174
|
-
mcp: {
|
|
175
|
-
name: getName(operation, {
|
|
176
|
-
type: "function",
|
|
177
|
-
suffix: "handler"
|
|
178
|
-
}),
|
|
179
|
-
file: getFile(operation)
|
|
180
|
-
},
|
|
181
|
-
zod: {
|
|
182
|
-
name: getName(operation, {
|
|
183
|
-
type: "function",
|
|
184
|
-
pluginName: pluginZodName
|
|
185
|
-
}),
|
|
186
|
-
schemas: getSchemas(operation, {
|
|
187
|
-
pluginName: pluginZodName,
|
|
188
|
-
type: "function"
|
|
189
|
-
}),
|
|
190
|
-
file: getFile(operation, { pluginName: pluginZodName })
|
|
191
|
-
},
|
|
192
|
-
type: { schemas: getSchemas(operation, {
|
|
193
|
-
pluginName: pluginTsName,
|
|
194
|
-
type: "type"
|
|
195
|
-
}) }
|
|
196
|
-
};
|
|
197
|
-
});
|
|
198
|
-
const imports = operationsMapped.flatMap(({ mcp, zod }) => {
|
|
199
|
-
return [/* @__PURE__ */ jsx(File.Import, {
|
|
200
|
-
name: [mcp.name],
|
|
201
|
-
root: file.path,
|
|
202
|
-
path: mcp.file.path
|
|
203
|
-
}, mcp.name), /* @__PURE__ */ jsx(File.Import, {
|
|
204
|
-
name: [
|
|
205
|
-
zod.schemas.request?.name,
|
|
206
|
-
zod.schemas.pathParams?.name,
|
|
207
|
-
zod.schemas.queryParams?.name,
|
|
208
|
-
zod.schemas.headerParams?.name,
|
|
209
|
-
zod.schemas.response?.name
|
|
210
|
-
].filter(Boolean),
|
|
211
|
-
root: file.path,
|
|
212
|
-
path: zod.file.path
|
|
213
|
-
}, zod.name)];
|
|
214
|
-
});
|
|
215
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(File, {
|
|
216
|
-
baseName: file.baseName,
|
|
217
|
-
path: file.path,
|
|
218
|
-
meta: file.meta,
|
|
219
|
-
banner: getBanner({
|
|
220
|
-
oas,
|
|
221
|
-
output: options.output,
|
|
222
|
-
config: driver.config
|
|
223
|
-
}),
|
|
224
|
-
footer: getFooter({
|
|
225
|
-
oas,
|
|
226
|
-
output: options.output
|
|
227
|
-
}),
|
|
228
|
-
children: [
|
|
229
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
230
|
-
name: ["McpServer"],
|
|
231
|
-
path: "@modelcontextprotocol/sdk/server/mcp"
|
|
232
|
-
}),
|
|
233
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
234
|
-
name: ["z"],
|
|
235
|
-
path: "zod"
|
|
236
|
-
}),
|
|
237
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
238
|
-
name: ["StdioServerTransport"],
|
|
239
|
-
path: "@modelcontextprotocol/sdk/server/stdio"
|
|
240
|
-
}),
|
|
241
|
-
imports,
|
|
242
|
-
/* @__PURE__ */ jsx(Server, {
|
|
243
|
-
name,
|
|
244
|
-
serverName: oas.api.info?.title,
|
|
245
|
-
serverVersion: oas.getVersion(),
|
|
246
|
-
paramsCasing: options.paramsCasing,
|
|
247
|
-
operations: operationsMapped
|
|
248
|
-
})
|
|
249
|
-
]
|
|
250
|
-
}), /* @__PURE__ */ jsx(File, {
|
|
251
|
-
baseName: jsonFile.baseName,
|
|
252
|
-
path: jsonFile.path,
|
|
253
|
-
meta: jsonFile.meta,
|
|
254
|
-
children: /* @__PURE__ */ jsx(File.Source, {
|
|
255
|
-
name,
|
|
256
|
-
children: `
|
|
257
|
-
{
|
|
258
|
-
"mcpServers": {
|
|
259
|
-
"${oas.api.info?.title || "server"}": {
|
|
260
|
-
"type": "stdio",
|
|
261
|
-
"command": "npx",
|
|
262
|
-
"args": ["tsx", "${path.relative(path.dirname(jsonFile.path), file.path)}"]
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
`
|
|
267
|
-
})
|
|
268
|
-
})] });
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
//#endregion
|
|
272
|
-
export { mcpGenerator as n, serverGenerator as t };
|
|
273
|
-
|
|
274
|
-
//# sourceMappingURL=generators-Cc2InAz4.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators-Cc2InAz4.js","names":[],"sources":["../src/generators/mcpGenerator.tsx","../src/generators/serverGenerator.tsx"],"sourcesContent":["import path from 'node:path'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/react-fabric'\nimport type { PluginMcp } from '../types'\n\nexport const mcpGenerator = createReactGenerator<PluginMcp>({\n name: 'mcp',\n Operation({ config, operation, generator, plugin }) {\n const { options } = plugin\n const oas = useOas()\n\n const { getSchemas, getName, getFile } = useOperationManager(generator)\n\n const mcp = {\n name: getName(operation, { type: 'function', suffix: 'handler' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginName: pluginTsName }),\n schemas: getSchemas(operation, { pluginName: pluginTsName, type: 'type' }),\n }\n\n return (\n <File\n baseName={mcp.file.baseName}\n path={mcp.file.path}\n meta={mcp.file.meta}\n banner={getBanner({ oas, output: options.output })}\n footer={getFooter({ oas, output: options.output })}\n >\n {options.client.importPath ? (\n <>\n <File.Import name={'fetch'} path={options.client.importPath} />\n <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n </>\n ) : (\n <>\n <File.Import name={['fetch']} root={mcp.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />\n <File.Import\n name={['Client', 'RequestConfig', 'ResponseErrorConfig']}\n root={mcp.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n {options.client.dataReturnType === 'full' && (\n <File.Import name={['ResponseConfig']} root={mcp.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} isTypeOnly />\n )}\n </>\n )}\n <File.Import name={['buildFormData']} root={mcp.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />\n <File.Import name={['CallToolResult']} path={'@modelcontextprotocol/sdk/types'} isTypeOnly />\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={mcp.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <Client\n name={mcp.name}\n isConfigurable={false}\n returnType={'Promise<CallToolResult>'}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={undefined}\n dataReturnType={options.client.dataReturnType || 'data'}\n paramsType={'object'}\n paramsCasing={options.client?.paramsCasing || options.paramsCasing}\n pathParamsType={'object'}\n parser={'client'}\n >\n {options.client.dataReturnType === 'data' &&\n `return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(res.data)\n }\n ],\n structuredContent: { data: res.data }\n }`}\n {options.client.dataReturnType === 'full' &&\n `return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(res)\n }\n ],\n structuredContent: { data: res.data }\n }`}\n </Client>\n </File>\n )\n },\n})\n","import path from 'node:path'\nimport { useDriver } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File } from '@kubb/react-fabric'\nimport { Server } from '../components/Server'\nimport type { PluginMcp } from '../types'\n\nexport const serverGenerator = createReactGenerator<PluginMcp>({\n name: 'operations',\n Operations({ operations, generator, plugin }) {\n const driver = useDriver()\n const { options } = plugin\n\n const oas = useOas()\n const { getFile, getName, getSchemas } = useOperationManager(generator)\n\n const name = 'server'\n const file = driver.getFile({ name, extname: '.ts', pluginName: plugin.name })\n\n const jsonFile = driver.getFile({ name: '.mcp', extname: '.json', pluginName: plugin.name })\n\n const operationsMapped = operations.map((operation) => {\n return {\n tool: {\n name: operation.getOperationId() || operation.getSummary() || `${operation.method.toUpperCase()} ${operation.path}`,\n title: operation.getSummary() || undefined,\n description: operation.getDescription() || `Make a ${operation.method.toUpperCase()} request to ${operation.path}`,\n },\n mcp: {\n name: getName(operation, {\n type: 'function',\n suffix: 'handler',\n }),\n file: getFile(operation),\n },\n zod: {\n name: getName(operation, {\n type: 'function',\n pluginName: pluginZodName,\n }),\n schemas: getSchemas(operation, { pluginName: pluginZodName, type: 'function' }),\n file: getFile(operation, { pluginName: pluginZodName }),\n },\n type: {\n schemas: getSchemas(operation, { pluginName: pluginTsName, type: 'type' }),\n },\n }\n })\n\n const imports = operationsMapped.flatMap(({ mcp, zod }) => {\n return [\n <File.Import key={mcp.name} name={[mcp.name]} root={file.path} path={mcp.file.path} />,\n <File.Import\n key={zod.name}\n name={[\n zod.schemas.request?.name,\n zod.schemas.pathParams?.name,\n zod.schemas.queryParams?.name,\n zod.schemas.headerParams?.name,\n zod.schemas.response?.name,\n ].filter(Boolean)}\n root={file.path}\n path={zod.file.path}\n />,\n ]\n })\n\n return (\n <>\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: options.output, config: driver.config })}\n footer={getFooter({ oas, output: options.output })}\n >\n <File.Import name={['McpServer']} path={'@modelcontextprotocol/sdk/server/mcp'} />\n <File.Import name={['z']} path={'zod'} />\n <File.Import name={['StdioServerTransport']} path={'@modelcontextprotocol/sdk/server/stdio'} />\n\n {imports}\n <Server\n name={name}\n serverName={oas.api.info?.title}\n serverVersion={oas.getVersion()}\n paramsCasing={options.paramsCasing}\n operations={operationsMapped}\n />\n </File>\n\n <File baseName={jsonFile.baseName} path={jsonFile.path} meta={jsonFile.meta}>\n <File.Source name={name}>\n {`\n {\n \"mcpServers\": {\n \"${oas.api.info?.title || 'server'}\": {\n \"type\": \"stdio\",\n \"command\": \"npx\",\n \"args\": [\"tsx\", \"${path.relative(path.dirname(jsonFile.path), file.path)}\"]\n }\n }\n }\n `}\n </File.Source>\n </File>\n </>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;AASA,MAAa,eAAe,qBAAgC;CAC1D,MAAM;CACN,UAAU,EAAE,QAAQ,WAAW,WAAW,UAAU;EAClD,MAAM,EAAE,YAAY;EACpB,MAAM,MAAM,QAAQ;EAEpB,MAAM,EAAE,YAAY,SAAS,YAAY,oBAAoB,UAAU;EAEvE,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;IAAW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AAK;IACX,MAAM,IAAI,KAAK;IACf,EAVK,IAAI,KAUT,CACH;IACD;AAEF,SACE,qBAAA,UAAA,EAAA,UAAA,CACE,qBAAC,MAAD;GACE,UAAU,KAAK;GACf,MAAM,KAAK;GACX,MAAM,KAAK;GACX,QAAQ,UAAU;IAAE;IAAK,QAAQ,QAAQ;IAAQ,QAAQ,OAAO;IAAQ,CAAC;GACzE,QAAQ,UAAU;IAAE;IAAK,QAAQ,QAAQ;IAAQ,CAAC;aALpD;IAOE,oBAAC,KAAK,QAAN;KAAa,MAAM,CAAC,YAAY;KAAE,MAAM;KAA0C,CAAA;IAClF,oBAAC,KAAK,QAAN;KAAa,MAAM,CAAC,IAAI;KAAE,MAAM;KAAS,CAAA;IACzC,oBAAC,KAAK,QAAN;KAAa,MAAM,CAAC,uBAAuB;KAAE,MAAM;KAA4C,CAAA;IAE9F;IACD,oBAAC,QAAD;KACQ;KACN,YAAY,IAAI,IAAI,MAAM;KAC1B,eAAe,IAAI,YAAY;KAC/B,cAAc,QAAQ;KACtB,YAAY;KACZ,CAAA;IACG;MAEP,oBAAC,MAAD;GAAM,UAAU,SAAS;GAAU,MAAM,SAAS;GAAM,MAAM,SAAS;aACrE,oBAAC,KAAK,QAAN;IAAmB;cAChB;;;iBAGI,IAAI,IAAI,MAAM,SAAS,SAAS;;;mCAGd,KAAK,SAAS,KAAK,QAAQ,SAAS,KAAK,EAAE,KAAK,KAAK,CAAC;;;;;IAKjE,CAAA;GACT,CAAA,CACN,EAAA,CAAA;;CAGR,CAAC"}
|
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
const require_Server = require("./Server-EjbvNRYy.cjs");
|
|
2
|
-
let node_path = require("node:path");
|
|
3
|
-
node_path = require_Server.__toESM(node_path);
|
|
4
|
-
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
5
|
-
let _kubb_plugin_zod = require("@kubb/plugin-zod");
|
|
6
|
-
let _kubb_plugin_client_components = require("@kubb/plugin-client/components");
|
|
7
|
-
let _kubb_plugin_oas_generators = require("@kubb/plugin-oas/generators");
|
|
8
|
-
let _kubb_plugin_oas_hooks = require("@kubb/plugin-oas/hooks");
|
|
9
|
-
let _kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
|
|
10
|
-
let _kubb_react_fabric = require("@kubb/react-fabric");
|
|
11
|
-
let _kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
12
|
-
let _kubb_core_hooks = require("@kubb/core/hooks");
|
|
13
|
-
//#region src/generators/mcpGenerator.tsx
|
|
14
|
-
const mcpGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
15
|
-
name: "mcp",
|
|
16
|
-
Operation({ config, operation, generator, plugin }) {
|
|
17
|
-
const { options } = plugin;
|
|
18
|
-
const oas = (0, _kubb_plugin_oas_hooks.useOas)();
|
|
19
|
-
const { getSchemas, getName, getFile } = (0, _kubb_plugin_oas_hooks.useOperationManager)(generator);
|
|
20
|
-
const mcp = {
|
|
21
|
-
name: getName(operation, {
|
|
22
|
-
type: "function",
|
|
23
|
-
suffix: "handler"
|
|
24
|
-
}),
|
|
25
|
-
file: getFile(operation)
|
|
26
|
-
};
|
|
27
|
-
const type = {
|
|
28
|
-
file: getFile(operation, { pluginName: _kubb_plugin_ts.pluginTsName }),
|
|
29
|
-
schemas: getSchemas(operation, {
|
|
30
|
-
pluginName: _kubb_plugin_ts.pluginTsName,
|
|
31
|
-
type: "type"
|
|
32
|
-
})
|
|
33
|
-
};
|
|
34
|
-
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
|
|
35
|
-
baseName: mcp.file.baseName,
|
|
36
|
-
path: mcp.file.path,
|
|
37
|
-
meta: mcp.file.meta,
|
|
38
|
-
banner: (0, _kubb_plugin_oas_utils.getBanner)({
|
|
39
|
-
oas,
|
|
40
|
-
output: options.output
|
|
41
|
-
}),
|
|
42
|
-
footer: (0, _kubb_plugin_oas_utils.getFooter)({
|
|
43
|
-
oas,
|
|
44
|
-
output: options.output
|
|
45
|
-
}),
|
|
46
|
-
children: [
|
|
47
|
-
options.client.importPath ? /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
48
|
-
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
49
|
-
name: "fetch",
|
|
50
|
-
path: options.client.importPath
|
|
51
|
-
}),
|
|
52
|
-
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
53
|
-
name: [
|
|
54
|
-
"Client",
|
|
55
|
-
"RequestConfig",
|
|
56
|
-
"ResponseErrorConfig"
|
|
57
|
-
],
|
|
58
|
-
path: options.client.importPath,
|
|
59
|
-
isTypeOnly: true
|
|
60
|
-
}),
|
|
61
|
-
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
62
|
-
name: ["ResponseConfig"],
|
|
63
|
-
path: options.client.importPath,
|
|
64
|
-
isTypeOnly: true
|
|
65
|
-
})
|
|
66
|
-
] }) : /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
67
|
-
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
68
|
-
name: ["fetch"],
|
|
69
|
-
root: mcp.file.path,
|
|
70
|
-
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
71
|
-
}),
|
|
72
|
-
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
73
|
-
name: [
|
|
74
|
-
"Client",
|
|
75
|
-
"RequestConfig",
|
|
76
|
-
"ResponseErrorConfig"
|
|
77
|
-
],
|
|
78
|
-
root: mcp.file.path,
|
|
79
|
-
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
|
|
80
|
-
isTypeOnly: true
|
|
81
|
-
}),
|
|
82
|
-
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
83
|
-
name: ["ResponseConfig"],
|
|
84
|
-
root: mcp.file.path,
|
|
85
|
-
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
|
|
86
|
-
isTypeOnly: true
|
|
87
|
-
})
|
|
88
|
-
] }),
|
|
89
|
-
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
90
|
-
name: ["buildFormData"],
|
|
91
|
-
root: mcp.file.path,
|
|
92
|
-
path: node_path.default.resolve(config.root, config.output.path, ".kubb/config.ts")
|
|
93
|
-
}),
|
|
94
|
-
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
95
|
-
name: ["CallToolResult"],
|
|
96
|
-
path: "@modelcontextprotocol/sdk/types",
|
|
97
|
-
isTypeOnly: true
|
|
98
|
-
}),
|
|
99
|
-
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
100
|
-
name: [
|
|
101
|
-
type.schemas.request?.name,
|
|
102
|
-
type.schemas.response.name,
|
|
103
|
-
type.schemas.pathParams?.name,
|
|
104
|
-
type.schemas.queryParams?.name,
|
|
105
|
-
type.schemas.headerParams?.name,
|
|
106
|
-
...type.schemas.statusCodes?.map((item) => item.name) || []
|
|
107
|
-
].filter(Boolean),
|
|
108
|
-
root: mcp.file.path,
|
|
109
|
-
path: type.file.path,
|
|
110
|
-
isTypeOnly: true
|
|
111
|
-
}),
|
|
112
|
-
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_plugin_client_components.Client, {
|
|
113
|
-
name: mcp.name,
|
|
114
|
-
isConfigurable: false,
|
|
115
|
-
returnType: "Promise<CallToolResult>",
|
|
116
|
-
baseURL: options.client.baseURL,
|
|
117
|
-
operation,
|
|
118
|
-
typeSchemas: type.schemas,
|
|
119
|
-
zodSchemas: void 0,
|
|
120
|
-
dataReturnType: options.client.dataReturnType || "data",
|
|
121
|
-
paramsType: "object",
|
|
122
|
-
paramsCasing: options.client?.paramsCasing || options.paramsCasing,
|
|
123
|
-
pathParamsType: "object",
|
|
124
|
-
parser: "client",
|
|
125
|
-
children: [options.client.dataReturnType === "data" && `return {
|
|
126
|
-
content: [
|
|
127
|
-
{
|
|
128
|
-
type: 'text',
|
|
129
|
-
text: JSON.stringify(res.data)
|
|
130
|
-
}
|
|
131
|
-
],
|
|
132
|
-
structuredContent: { data: res.data }
|
|
133
|
-
}`, options.client.dataReturnType === "full" && `return {
|
|
134
|
-
content: [
|
|
135
|
-
{
|
|
136
|
-
type: 'text',
|
|
137
|
-
text: JSON.stringify(res)
|
|
138
|
-
}
|
|
139
|
-
],
|
|
140
|
-
structuredContent: { data: res.data }
|
|
141
|
-
}`]
|
|
142
|
-
})
|
|
143
|
-
]
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
//#endregion
|
|
148
|
-
//#region src/generators/serverGenerator.tsx
|
|
149
|
-
const serverGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
150
|
-
name: "operations",
|
|
151
|
-
Operations({ operations, generator, plugin }) {
|
|
152
|
-
const driver = (0, _kubb_core_hooks.useDriver)();
|
|
153
|
-
const { options } = plugin;
|
|
154
|
-
const oas = (0, _kubb_plugin_oas_hooks.useOas)();
|
|
155
|
-
const { getFile, getName, getSchemas } = (0, _kubb_plugin_oas_hooks.useOperationManager)(generator);
|
|
156
|
-
const name = "server";
|
|
157
|
-
const file = driver.getFile({
|
|
158
|
-
name,
|
|
159
|
-
extname: ".ts",
|
|
160
|
-
pluginName: plugin.name
|
|
161
|
-
});
|
|
162
|
-
const jsonFile = driver.getFile({
|
|
163
|
-
name: ".mcp",
|
|
164
|
-
extname: ".json",
|
|
165
|
-
pluginName: plugin.name
|
|
166
|
-
});
|
|
167
|
-
const operationsMapped = operations.map((operation) => {
|
|
168
|
-
return {
|
|
169
|
-
tool: {
|
|
170
|
-
name: operation.getOperationId() || operation.getSummary() || `${operation.method.toUpperCase()} ${operation.path}`,
|
|
171
|
-
title: operation.getSummary() || void 0,
|
|
172
|
-
description: operation.getDescription() || `Make a ${operation.method.toUpperCase()} request to ${operation.path}`
|
|
173
|
-
},
|
|
174
|
-
mcp: {
|
|
175
|
-
name: getName(operation, {
|
|
176
|
-
type: "function",
|
|
177
|
-
suffix: "handler"
|
|
178
|
-
}),
|
|
179
|
-
file: getFile(operation)
|
|
180
|
-
},
|
|
181
|
-
zod: {
|
|
182
|
-
name: getName(operation, {
|
|
183
|
-
type: "function",
|
|
184
|
-
pluginName: _kubb_plugin_zod.pluginZodName
|
|
185
|
-
}),
|
|
186
|
-
schemas: getSchemas(operation, {
|
|
187
|
-
pluginName: _kubb_plugin_zod.pluginZodName,
|
|
188
|
-
type: "function"
|
|
189
|
-
}),
|
|
190
|
-
file: getFile(operation, { pluginName: _kubb_plugin_zod.pluginZodName })
|
|
191
|
-
},
|
|
192
|
-
type: { schemas: getSchemas(operation, {
|
|
193
|
-
pluginName: _kubb_plugin_ts.pluginTsName,
|
|
194
|
-
type: "type"
|
|
195
|
-
}) }
|
|
196
|
-
};
|
|
197
|
-
});
|
|
198
|
-
const imports = operationsMapped.flatMap(({ mcp, zod }) => {
|
|
199
|
-
return [/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
200
|
-
name: [mcp.name],
|
|
201
|
-
root: file.path,
|
|
202
|
-
path: mcp.file.path
|
|
203
|
-
}, mcp.name), /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
204
|
-
name: [
|
|
205
|
-
zod.schemas.request?.name,
|
|
206
|
-
zod.schemas.pathParams?.name,
|
|
207
|
-
zod.schemas.queryParams?.name,
|
|
208
|
-
zod.schemas.headerParams?.name,
|
|
209
|
-
zod.schemas.response?.name
|
|
210
|
-
].filter(Boolean),
|
|
211
|
-
root: file.path,
|
|
212
|
-
path: zod.file.path
|
|
213
|
-
}, zod.name)];
|
|
214
|
-
});
|
|
215
|
-
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
|
|
216
|
-
baseName: file.baseName,
|
|
217
|
-
path: file.path,
|
|
218
|
-
meta: file.meta,
|
|
219
|
-
banner: (0, _kubb_plugin_oas_utils.getBanner)({
|
|
220
|
-
oas,
|
|
221
|
-
output: options.output,
|
|
222
|
-
config: driver.config
|
|
223
|
-
}),
|
|
224
|
-
footer: (0, _kubb_plugin_oas_utils.getFooter)({
|
|
225
|
-
oas,
|
|
226
|
-
output: options.output
|
|
227
|
-
}),
|
|
228
|
-
children: [
|
|
229
|
-
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
230
|
-
name: ["McpServer"],
|
|
231
|
-
path: "@modelcontextprotocol/sdk/server/mcp"
|
|
232
|
-
}),
|
|
233
|
-
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
234
|
-
name: ["z"],
|
|
235
|
-
path: "zod"
|
|
236
|
-
}),
|
|
237
|
-
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
238
|
-
name: ["StdioServerTransport"],
|
|
239
|
-
path: "@modelcontextprotocol/sdk/server/stdio"
|
|
240
|
-
}),
|
|
241
|
-
imports,
|
|
242
|
-
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_Server.Server, {
|
|
243
|
-
name,
|
|
244
|
-
serverName: oas.api.info?.title,
|
|
245
|
-
serverVersion: oas.getVersion(),
|
|
246
|
-
paramsCasing: options.paramsCasing,
|
|
247
|
-
operations: operationsMapped
|
|
248
|
-
})
|
|
249
|
-
]
|
|
250
|
-
}), /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File, {
|
|
251
|
-
baseName: jsonFile.baseName,
|
|
252
|
-
path: jsonFile.path,
|
|
253
|
-
meta: jsonFile.meta,
|
|
254
|
-
children: /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Source, {
|
|
255
|
-
name,
|
|
256
|
-
children: `
|
|
257
|
-
{
|
|
258
|
-
"mcpServers": {
|
|
259
|
-
"${oas.api.info?.title || "server"}": {
|
|
260
|
-
"type": "stdio",
|
|
261
|
-
"command": "npx",
|
|
262
|
-
"args": ["tsx", "${node_path.default.relative(node_path.default.dirname(jsonFile.path), file.path)}"]
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
`
|
|
267
|
-
})
|
|
268
|
-
})] });
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
//#endregion
|
|
272
|
-
Object.defineProperty(exports, "mcpGenerator", {
|
|
273
|
-
enumerable: true,
|
|
274
|
-
get: function() {
|
|
275
|
-
return mcpGenerator;
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
Object.defineProperty(exports, "serverGenerator", {
|
|
279
|
-
enumerable: true,
|
|
280
|
-
get: function() {
|
|
281
|
-
return serverGenerator;
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
//# sourceMappingURL=generators-CzP7VKQw.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators-CzP7VKQw.cjs","names":["pluginTsName","File","path","Client","pluginZodName","pluginTsName","File","Server","path"],"sources":["../src/generators/mcpGenerator.tsx","../src/generators/serverGenerator.tsx"],"sourcesContent":["import path from 'node:path'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/react-fabric'\nimport type { PluginMcp } from '../types'\n\nexport const mcpGenerator = createReactGenerator<PluginMcp>({\n name: 'mcp',\n Operation({ config, operation, generator, plugin }) {\n const { options } = plugin\n const oas = useOas()\n\n const { getSchemas, getName, getFile } = useOperationManager(generator)\n\n const mcp = {\n name: getName(operation, { type: 'function', suffix: 'handler' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginName: pluginTsName }),\n schemas: getSchemas(operation, { pluginName: pluginTsName, type: 'type' }),\n }\n\n return (\n <File\n baseName={mcp.file.baseName}\n path={mcp.file.path}\n meta={mcp.file.meta}\n banner={getBanner({ oas, output: options.output })}\n footer={getFooter({ oas, output: options.output })}\n >\n {options.client.importPath ? (\n <>\n <File.Import name={'fetch'} path={options.client.importPath} />\n <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n </>\n ) : (\n <>\n <File.Import name={['fetch']} root={mcp.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />\n <File.Import\n name={['Client', 'RequestConfig', 'ResponseErrorConfig']}\n root={mcp.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n {options.client.dataReturnType === 'full' && (\n <File.Import name={['ResponseConfig']} root={mcp.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} isTypeOnly />\n )}\n </>\n )}\n <File.Import name={['buildFormData']} root={mcp.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />\n <File.Import name={['CallToolResult']} path={'@modelcontextprotocol/sdk/types'} isTypeOnly />\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={mcp.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <Client\n name={mcp.name}\n isConfigurable={false}\n returnType={'Promise<CallToolResult>'}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={undefined}\n dataReturnType={options.client.dataReturnType || 'data'}\n paramsType={'object'}\n paramsCasing={options.client?.paramsCasing || options.paramsCasing}\n pathParamsType={'object'}\n parser={'client'}\n >\n {options.client.dataReturnType === 'data' &&\n `return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(res.data)\n }\n ],\n structuredContent: { data: res.data }\n }`}\n {options.client.dataReturnType === 'full' &&\n `return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(res)\n }\n ],\n structuredContent: { data: res.data }\n }`}\n </Client>\n </File>\n )\n },\n})\n","import path from 'node:path'\nimport { useDriver } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File } from '@kubb/react-fabric'\nimport { Server } from '../components/Server'\nimport type { PluginMcp } from '../types'\n\nexport const serverGenerator = createReactGenerator<PluginMcp>({\n name: 'operations',\n Operations({ operations, generator, plugin }) {\n const driver = useDriver()\n const { options } = plugin\n\n const oas = useOas()\n const { getFile, getName, getSchemas } = useOperationManager(generator)\n\n const name = 'server'\n const file = driver.getFile({ name, extname: '.ts', pluginName: plugin.name })\n\n const jsonFile = driver.getFile({ name: '.mcp', extname: '.json', pluginName: plugin.name })\n\n const operationsMapped = operations.map((operation) => {\n return {\n tool: {\n name: operation.getOperationId() || operation.getSummary() || `${operation.method.toUpperCase()} ${operation.path}`,\n title: operation.getSummary() || undefined,\n description: operation.getDescription() || `Make a ${operation.method.toUpperCase()} request to ${operation.path}`,\n },\n mcp: {\n name: getName(operation, {\n type: 'function',\n suffix: 'handler',\n }),\n file: getFile(operation),\n },\n zod: {\n name: getName(operation, {\n type: 'function',\n pluginName: pluginZodName,\n }),\n schemas: getSchemas(operation, { pluginName: pluginZodName, type: 'function' }),\n file: getFile(operation, { pluginName: pluginZodName }),\n },\n type: {\n schemas: getSchemas(operation, { pluginName: pluginTsName, type: 'type' }),\n },\n }\n })\n\n const imports = operationsMapped.flatMap(({ mcp, zod }) => {\n return [\n <File.Import key={mcp.name} name={[mcp.name]} root={file.path} path={mcp.file.path} />,\n <File.Import\n key={zod.name}\n name={[\n zod.schemas.request?.name,\n zod.schemas.pathParams?.name,\n zod.schemas.queryParams?.name,\n zod.schemas.headerParams?.name,\n zod.schemas.response?.name,\n ].filter(Boolean)}\n root={file.path}\n path={zod.file.path}\n />,\n ]\n })\n\n return (\n <>\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: options.output, config: driver.config })}\n footer={getFooter({ oas, output: options.output })}\n >\n <File.Import name={['McpServer']} path={'@modelcontextprotocol/sdk/server/mcp'} />\n <File.Import name={['z']} path={'zod'} />\n <File.Import name={['StdioServerTransport']} path={'@modelcontextprotocol/sdk/server/stdio'} />\n\n {imports}\n <Server\n name={name}\n serverName={oas.api.info?.title}\n serverVersion={oas.getVersion()}\n paramsCasing={options.paramsCasing}\n operations={operationsMapped}\n />\n </File>\n\n <File baseName={jsonFile.baseName} path={jsonFile.path} meta={jsonFile.meta}>\n <File.Source name={name}>\n {`\n {\n \"mcpServers\": {\n \"${oas.api.info?.title || 'server'}\": {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M,KAAK;GACX,MAAM,KAAK;GACX,SAAA,GAAA,uBAAA,WAAkB;IAAE;IAAK,QAAQ,QAAQ;IAAQ,QAAQ,OAAO;IAAQ,CAAC;GACzE,SAAA,GAAA,uBAAA,WAAkB;IAAE;IAAK,QAAQ,QAAQ;IAAQ,CAAC;aALpD;IAOE,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;KAAa,MAAM,CAAC,YAAY;KAAE,MAAM;KAA0C,CAAA;IAClF,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;KAAa,MAAM,CAAC,IAAI;KAAE,MAAM;KAAS,CAAA;IACzC,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;KAAa,MAAM,CAAC,uBAAuB;KAAE,MAAM;KAA4C,CAAA;IAE9F;IACD,iBAAA,GAAA,+BAAA,KAACC,eAAAA,QAAD;KACQ;KACN,YAAY,IAAI,IAAI,MAAM;KAC1B,eAAe,IAAI,YAAY;KAC/B,cAAc,QAAQ;KACtB,YAAY;KACZ,CAAA;IACG;MAEP,iBAAA,GAAA,+BAAA,KAACD,mBAAAA,MAAD;GAAM,UAAU,SAAS;GAAU,MAAM,SAAS;GAAM,MAAM,SAAS;aACrE,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;IAAmB;cAChB;;;iBAGI,IAAI,IAAI,MAAM,SAAS,SAAS;;;mCAGdE,UAAAA,QAAK,SAASA,UAAAA,QAAK,QAAQ,SAAS,KAAK,EAAE,KAAK,KAAK,CAAC;;;;;IAKjE,CAAA;GACT,CAAA,CACN,EAAA,CAAA;;CAGR,CAAC"}
|
package/dist/generators.cjs
DELETED
package/dist/generators.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { n as PluginMcp } from "./types-DNDVb19t.js";
|
|
3
|
-
import * as _$_kubb_plugin_oas_generators0 from "@kubb/plugin-oas/generators";
|
|
4
|
-
|
|
5
|
-
//#region src/generators/mcpGenerator.d.ts
|
|
6
|
-
declare const mcpGenerator: _$_kubb_plugin_oas_generators0.ReactGenerator<PluginMcp>;
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/generators/serverGenerator.d.ts
|
|
9
|
-
declare const serverGenerator: _$_kubb_plugin_oas_generators0.ReactGenerator<PluginMcp>;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { mcpGenerator, serverGenerator };
|
|
12
|
-
//# sourceMappingURL=generators.d.ts.map
|
package/dist/generators.js
DELETED