@kubb/plugin-mcp 5.0.0-alpha.9 → 5.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,124 +1,989 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_Server = require("./Server-DV9zFrUP.cjs");
3
- const require_generators = require("./generators-CWAFnA94.cjs");
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ //#region \0rolldown/runtime.js
6
+ var __create = Object.create;
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getProtoOf = Object.getPrototypeOf;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
14
+ key = keys[i];
15
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: ((k) => from[k]).bind(null, key),
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+ //#endregion
4
27
  let node_path = require("node:path");
5
- node_path = require_Server.__toESM(node_path);
28
+ let node_path$1 = __toESM(node_path, 1);
29
+ node_path = __toESM(node_path);
6
30
  let _kubb_core = require("@kubb/core");
31
+ let _kubb_plugin_ts = require("@kubb/plugin-ts");
32
+ let _kubb_renderer_jsx = require("@kubb/renderer-jsx");
33
+ let _kubb_renderer_jsx_jsx_runtime = require("@kubb/renderer-jsx/jsx-runtime");
34
+ let _kubb_plugin_zod = require("@kubb/plugin-zod");
7
35
  let _kubb_plugin_client = require("@kubb/plugin-client");
8
36
  let _kubb_plugin_client_templates_clients_axios_source = require("@kubb/plugin-client/templates/clients/axios.source");
9
37
  let _kubb_plugin_client_templates_clients_fetch_source = require("@kubb/plugin-client/templates/clients/fetch.source");
10
38
  let _kubb_plugin_client_templates_config_source = require("@kubb/plugin-client/templates/config.source");
11
- let _kubb_plugin_oas = require("@kubb/plugin-oas");
12
- let _kubb_plugin_ts = require("@kubb/plugin-ts");
13
- let _kubb_plugin_zod = require("@kubb/plugin-zod");
39
+ //#region ../../internals/utils/src/casing.ts
40
+ /**
41
+ * Shared implementation for camelCase and PascalCase conversion.
42
+ * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
43
+ * and capitalizes each word according to `pascal`.
44
+ *
45
+ * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
46
+ */
47
+ function toCamelOrPascal(text, pascal) {
48
+ return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
49
+ if (word.length > 1 && word === word.toUpperCase()) return word;
50
+ if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
51
+ return word.charAt(0).toUpperCase() + word.slice(1);
52
+ }).join("").replace(/[^a-zA-Z0-9]/g, "");
53
+ }
54
+ /**
55
+ * Splits `text` on `.` and applies `transformPart` to each segment.
56
+ * The last segment receives `isLast = true`, all earlier segments receive `false`.
57
+ * Segments are joined with `/` to form a file path.
58
+ *
59
+ * Only splits on dots followed by a letter so that version numbers
60
+ * embedded in operationIds (e.g. `v2025.0`) are kept intact.
61
+ */
62
+ function applyToFileParts(text, transformPart) {
63
+ const parts = text.split(/\.(?=[a-zA-Z])/);
64
+ return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
65
+ }
66
+ /**
67
+ * Converts `text` to camelCase.
68
+ * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.
69
+ *
70
+ * @example
71
+ * camelCase('hello-world') // 'helloWorld'
72
+ * camelCase('pet.petId', { isFile: true }) // 'pet/petId'
73
+ */
74
+ function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
75
+ if (isFile) return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? {
76
+ prefix,
77
+ suffix
78
+ } : {}));
79
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
80
+ }
81
+ //#endregion
82
+ //#region ../../internals/utils/src/reserved.ts
83
+ /**
84
+ * JavaScript and Java reserved words.
85
+ * @link https://github.com/jonschlinkert/reserved/blob/master/index.js
86
+ */
87
+ const reservedWords = new Set([
88
+ "abstract",
89
+ "arguments",
90
+ "boolean",
91
+ "break",
92
+ "byte",
93
+ "case",
94
+ "catch",
95
+ "char",
96
+ "class",
97
+ "const",
98
+ "continue",
99
+ "debugger",
100
+ "default",
101
+ "delete",
102
+ "do",
103
+ "double",
104
+ "else",
105
+ "enum",
106
+ "eval",
107
+ "export",
108
+ "extends",
109
+ "false",
110
+ "final",
111
+ "finally",
112
+ "float",
113
+ "for",
114
+ "function",
115
+ "goto",
116
+ "if",
117
+ "implements",
118
+ "import",
119
+ "in",
120
+ "instanceof",
121
+ "int",
122
+ "interface",
123
+ "let",
124
+ "long",
125
+ "native",
126
+ "new",
127
+ "null",
128
+ "package",
129
+ "private",
130
+ "protected",
131
+ "public",
132
+ "return",
133
+ "short",
134
+ "static",
135
+ "super",
136
+ "switch",
137
+ "synchronized",
138
+ "this",
139
+ "throw",
140
+ "throws",
141
+ "transient",
142
+ "true",
143
+ "try",
144
+ "typeof",
145
+ "var",
146
+ "void",
147
+ "volatile",
148
+ "while",
149
+ "with",
150
+ "yield",
151
+ "Array",
152
+ "Date",
153
+ "hasOwnProperty",
154
+ "Infinity",
155
+ "isFinite",
156
+ "isNaN",
157
+ "isPrototypeOf",
158
+ "length",
159
+ "Math",
160
+ "name",
161
+ "NaN",
162
+ "Number",
163
+ "Object",
164
+ "prototype",
165
+ "String",
166
+ "toString",
167
+ "undefined",
168
+ "valueOf"
169
+ ]);
170
+ /**
171
+ * Returns `true` when `name` is a syntactically valid JavaScript variable name.
172
+ *
173
+ * @example
174
+ * ```ts
175
+ * isValidVarName('status') // true
176
+ * isValidVarName('class') // false (reserved word)
177
+ * isValidVarName('42foo') // false (starts with digit)
178
+ * ```
179
+ */
180
+ function isValidVarName(name) {
181
+ if (!name || reservedWords.has(name)) return false;
182
+ return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
183
+ }
184
+ //#endregion
185
+ //#region ../../internals/utils/src/urlPath.ts
186
+ /**
187
+ * Parses and transforms an OpenAPI/Swagger path string into various URL formats.
188
+ *
189
+ * @example
190
+ * const p = new URLPath('/pet/{petId}')
191
+ * p.URL // '/pet/:petId'
192
+ * p.template // '`/pet/${petId}`'
193
+ */
194
+ var URLPath = class {
195
+ /**
196
+ * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.
197
+ */
198
+ path;
199
+ #options;
200
+ constructor(path, options = {}) {
201
+ this.path = path;
202
+ this.#options = options;
203
+ }
204
+ /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.
205
+ *
206
+ * @example
207
+ * ```ts
208
+ * new URLPath('/pet/{petId}').URL // '/pet/:petId'
209
+ * ```
210
+ */
211
+ get URL() {
212
+ return this.toURLPath();
213
+ }
214
+ /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).
215
+ *
216
+ * @example
217
+ * ```ts
218
+ * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true
219
+ * new URLPath('/pet/{petId}').isURL // false
220
+ * ```
221
+ */
222
+ get isURL() {
223
+ try {
224
+ return !!new URL(this.path).href;
225
+ } catch {
226
+ return false;
227
+ }
228
+ }
229
+ /**
230
+ * Converts the OpenAPI path to a TypeScript template literal string.
231
+ *
232
+ * @example
233
+ * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'
234
+ * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'
235
+ */
236
+ get template() {
237
+ return this.toTemplateString();
238
+ }
239
+ /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.
240
+ *
241
+ * @example
242
+ * ```ts
243
+ * new URLPath('/pet/{petId}').object
244
+ * // { url: '/pet/:petId', params: { petId: 'petId' } }
245
+ * ```
246
+ */
247
+ get object() {
248
+ return this.toObject();
249
+ }
250
+ /** Returns a map of path parameter names, or `undefined` when the path has no parameters.
251
+ *
252
+ * @example
253
+ * ```ts
254
+ * new URLPath('/pet/{petId}').params // { petId: 'petId' }
255
+ * new URLPath('/pet').params // undefined
256
+ * ```
257
+ */
258
+ get params() {
259
+ return this.getParams();
260
+ }
261
+ #transformParam(raw) {
262
+ const param = isValidVarName(raw) ? raw : camelCase(raw);
263
+ return this.#options.casing === "camelcase" ? camelCase(param) : param;
264
+ }
265
+ /**
266
+ * Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name.
267
+ */
268
+ #eachParam(fn) {
269
+ for (const match of this.path.matchAll(/\{([^}]+)\}/g)) {
270
+ const raw = match[1];
271
+ fn(raw, this.#transformParam(raw));
272
+ }
273
+ }
274
+ toObject({ type = "path", replacer, stringify } = {}) {
275
+ const object = {
276
+ url: type === "path" ? this.toURLPath() : this.toTemplateString({ replacer }),
277
+ params: this.getParams()
278
+ };
279
+ if (stringify) {
280
+ if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
281
+ if (object.params) return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll("'", "").replaceAll(`"`, "")} }`;
282
+ return `{ url: '${object.url}' }`;
283
+ }
284
+ return object;
285
+ }
286
+ /**
287
+ * Converts the OpenAPI path to a TypeScript template literal string.
288
+ * An optional `replacer` can transform each extracted parameter name before interpolation.
289
+ *
290
+ * @example
291
+ * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
292
+ */
293
+ toTemplateString({ prefix = "", replacer } = {}) {
294
+ return `\`${prefix}${this.path.split(/\{([^}]+)\}/).map((part, i) => {
295
+ if (i % 2 === 0) return part;
296
+ const param = this.#transformParam(part);
297
+ return `\${${replacer ? replacer(param) : param}}`;
298
+ }).join("")}\``;
299
+ }
300
+ /**
301
+ * Extracts all `{param}` segments from the path and returns them as a key-value map.
302
+ * An optional `replacer` transforms each parameter name in both key and value positions.
303
+ * Returns `undefined` when no path parameters are found.
304
+ *
305
+ * @example
306
+ * ```ts
307
+ * new URLPath('/pet/{petId}/tag/{tagId}').getParams()
308
+ * // { petId: 'petId', tagId: 'tagId' }
309
+ * ```
310
+ */
311
+ getParams(replacer) {
312
+ const params = {};
313
+ this.#eachParam((_raw, param) => {
314
+ const key = replacer ? replacer(param) : param;
315
+ params[key] = key;
316
+ });
317
+ return Object.keys(params).length > 0 ? params : void 0;
318
+ }
319
+ /** Converts the OpenAPI path to Express-style colon syntax.
320
+ *
321
+ * @example
322
+ * ```ts
323
+ * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'
324
+ * ```
325
+ */
326
+ toURLPath() {
327
+ return this.path.replace(/\{([^}]+)\}/g, ":$1");
328
+ }
329
+ };
330
+ //#endregion
331
+ //#region src/utils.ts
332
+ /**
333
+ * Find the first 2xx response status code from an operation's responses.
334
+ */
335
+ function findSuccessStatusCode(responses) {
336
+ for (const res of responses) {
337
+ const code = Number(res.statusCode);
338
+ if (code >= 200 && code < 300) return res.statusCode;
339
+ }
340
+ }
341
+ /**
342
+ * Render a group param value — compose individual schemas into `z.object({ ... })`,
343
+ * or use a schema name string directly.
344
+ */
345
+ function zodGroupExpr(entry) {
346
+ if (typeof entry === "string") return entry;
347
+ return `z.object({ ${entry.map((p) => `${JSON.stringify(p.name)}: ${p.schemaName}`).join(", ")} })`;
348
+ }
349
+ /**
350
+ * Build JSDoc comment lines from an OperationNode.
351
+ */
352
+ function getComments(node) {
353
+ return [
354
+ node.description && `@description ${node.description}`,
355
+ node.summary && `@summary ${node.summary}`,
356
+ node.deprecated && "@deprecated",
357
+ `{@link ${node.path.replaceAll("{", ":").replaceAll("}", "")}}`
358
+ ].filter((x) => Boolean(x));
359
+ }
360
+ /**
361
+ * Build a mapping of original param names → camelCase names.
362
+ * Returns `undefined` when no names actually change (no remapping needed).
363
+ */
364
+ function getParamsMapping(params) {
365
+ if (!params.length) return;
366
+ const mapping = {};
367
+ let hasDifference = false;
368
+ for (const p of params) {
369
+ const camelName = camelCase(p.name);
370
+ mapping[p.name] = camelName;
371
+ if (p.name !== camelName) hasDifference = true;
372
+ }
373
+ return hasDifference ? mapping : void 0;
374
+ }
375
+ /**
376
+ * Convert a SchemaNode type to an inline Zod expression string.
377
+ * Used as fallback when no named zod schema is available for a path parameter.
378
+ */
379
+ function zodExprFromSchemaNode(schema) {
380
+ let expr;
381
+ switch (schema.type) {
382
+ case "enum": {
383
+ const rawValues = schema.namedEnumValues?.length ? schema.namedEnumValues.map((v) => v.value) : (schema.enumValues ?? []).filter((v) => v !== null);
384
+ if (rawValues.length > 0 && rawValues.every((v) => typeof v === "string")) expr = `z.enum([${rawValues.map((v) => JSON.stringify(v)).join(", ")}])`;
385
+ else if (rawValues.length > 0) {
386
+ const literals = rawValues.map((v) => `z.literal(${JSON.stringify(v)})`);
387
+ expr = literals.length === 1 ? literals[0] : `z.union([${literals.join(", ")}])`;
388
+ } else expr = "z.string()";
389
+ break;
390
+ }
391
+ case "integer":
392
+ expr = "z.coerce.number()";
393
+ break;
394
+ case "number":
395
+ expr = "z.number()";
396
+ break;
397
+ case "boolean":
398
+ expr = "z.boolean()";
399
+ break;
400
+ case "array":
401
+ expr = "z.array(z.unknown())";
402
+ break;
403
+ default: expr = "z.string()";
404
+ }
405
+ if (schema.nullable) expr = `${expr}.nullable()`;
406
+ return expr;
407
+ }
408
+ //#endregion
409
+ //#region src/components/McpHandler.tsx
410
+ /**
411
+ * Generate a remapping statement: `const mappedX = x ? { "orig": x.camel, ... } : undefined`
412
+ */
413
+ function buildRemappingCode(mapping, varName, sourceName) {
414
+ return `const ${varName} = ${sourceName} ? { ${Object.entries(mapping).map(([orig, camel]) => `"${orig}": ${sourceName}.${camel}`).join(", ")} } : undefined`;
415
+ }
416
+ const declarationPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
417
+ function McpHandler({ name, node, resolver, baseURL, dataReturnType, paramsCasing }) {
418
+ const urlPath = new URLPath(node.path);
419
+ const contentType = node.requestBody?.content?.[0]?.contentType;
420
+ const isFormData = contentType === "multipart/form-data";
421
+ const casedParams = _kubb_core.ast.caseParams(node.parameters, paramsCasing);
422
+ const queryParams = casedParams.filter((p) => p.in === "query");
423
+ const headerParams = casedParams.filter((p) => p.in === "header");
424
+ const originalPathParams = node.parameters.filter((p) => p.in === "path");
425
+ const originalQueryParams = node.parameters.filter((p) => p.in === "query");
426
+ const originalHeaderParams = node.parameters.filter((p) => p.in === "header");
427
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
428
+ const responseName = resolver.resolveResponseName(node);
429
+ const errorResponses = node.responses.filter((r) => Number(r.statusCode) >= 400).map((r) => resolver.resolveResponseStatusName(node, r.statusCode));
430
+ const generics = [
431
+ responseName,
432
+ `ResponseErrorConfig<${errorResponses.length > 0 ? errorResponses.join(" | ") : "Error"}>`,
433
+ requestName || "unknown"
434
+ ].filter(Boolean);
435
+ const paramsNode = _kubb_core.ast.createOperationParams(node, {
436
+ paramsType: "object",
437
+ pathParamsType: "inline",
438
+ resolver,
439
+ paramsCasing
440
+ });
441
+ const baseParamsSignature = declarationPrinter.print(paramsNode) ?? "";
442
+ const paramsSignature = baseParamsSignature ? `${baseParamsSignature}, request: RequestHandlerExtra<ServerRequest, ServerNotification>` : "request: RequestHandlerExtra<ServerRequest, ServerNotification>";
443
+ const pathParamsMapping = paramsCasing ? getParamsMapping(originalPathParams) : void 0;
444
+ const queryParamsMapping = paramsCasing ? getParamsMapping(originalQueryParams) : void 0;
445
+ const headerParamsMapping = paramsCasing ? getParamsMapping(originalHeaderParams) : void 0;
446
+ const contentTypeHeader = contentType && contentType !== "application/json" && contentType !== "multipart/form-data" ? `'Content-Type': '${contentType}'` : void 0;
447
+ const headers = [headerParams.length ? headerParamsMapping ? "...mappedHeaders" : "...headers" : void 0, contentTypeHeader].filter(Boolean);
448
+ const fetchConfig = [];
449
+ fetchConfig.push(`method: ${JSON.stringify(node.method.toUpperCase())}`);
450
+ fetchConfig.push(`url: ${urlPath.template}`);
451
+ if (baseURL) fetchConfig.push(`baseURL: \`${baseURL}\``);
452
+ if (queryParams.length) fetchConfig.push(queryParamsMapping ? "params: mappedParams" : "params");
453
+ if (requestName) fetchConfig.push(`data: ${isFormData ? "formData as FormData" : "requestData"}`);
454
+ if (headers.length) fetchConfig.push(`headers: { ${headers.join(", ")} }`);
455
+ const callToolResult = dataReturnType === "data" ? `return {
456
+ content: [
457
+ {
458
+ type: 'text',
459
+ text: JSON.stringify(res.data)
460
+ }
461
+ ],
462
+ structuredContent: { data: res.data }
463
+ }` : `return {
464
+ content: [
465
+ {
466
+ type: 'text',
467
+ text: JSON.stringify(res)
468
+ }
469
+ ],
470
+ structuredContent: { data: res.data }
471
+ }`;
472
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
473
+ name,
474
+ isExportable: true,
475
+ isIndexable: true,
476
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.Function, {
477
+ name,
478
+ async: true,
479
+ export: true,
480
+ params: paramsSignature,
481
+ JSDoc: { comments: getComments(node) },
482
+ returnType: "Promise<CallToolResult>",
483
+ children: [
484
+ "",
485
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
486
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
487
+ pathParamsMapping && Object.entries(pathParamsMapping).filter(([originalName, camelCaseName]) => originalName !== camelCaseName && isValidVarName(originalName)).map(([originalName, camelCaseName]) => `const ${originalName} = ${camelCaseName}`).join("\n"),
488
+ pathParamsMapping && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {})] }),
489
+ queryParamsMapping && queryParams.length > 0 && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
490
+ buildRemappingCode(queryParamsMapping, "mappedParams", "params"),
491
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
492
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {})
493
+ ] }),
494
+ headerParamsMapping && headerParams.length > 0 && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
495
+ buildRemappingCode(headerParamsMapping, "mappedHeaders", "headers"),
496
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
497
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {})
498
+ ] }),
499
+ requestName && "const requestData = data",
500
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
501
+ isFormData && requestName && "const formData = buildFormData(requestData)",
502
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
503
+ `const res = await fetch<${generics.join(", ")}>({ ${fetchConfig.join(", ")} }, request)`,
504
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
505
+ callToolResult
506
+ ]
507
+ })
508
+ });
509
+ }
510
+ //#endregion
511
+ //#region src/components/Server.tsx
512
+ const keysPrinter = (0, _kubb_plugin_ts.functionPrinter)({ mode: "keys" });
513
+ function Server({ name, serverName, serverVersion, paramsCasing, operations }) {
514
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File.Source, {
515
+ name,
516
+ isExportable: true,
517
+ isIndexable: true,
518
+ children: [
519
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Const, {
520
+ name: "server",
521
+ export: true,
522
+ children: `
523
+ new McpServer({
524
+ name: '${serverName}',
525
+ version: '${serverVersion}',
526
+ })
527
+ `
528
+ }),
529
+ operations.map(({ tool, mcp, zod, node }) => {
530
+ const pathParams = _kubb_core.ast.caseParams(node.parameters, paramsCasing).filter((p) => p.in === "path");
531
+ const pathEntries = [];
532
+ const otherEntries = [];
533
+ for (const p of pathParams) {
534
+ const zodParam = zod.pathParams.find((zp) => zp.name === p.name);
535
+ pathEntries.push({
536
+ key: p.name,
537
+ value: zodParam ? zodParam.schemaName : zodExprFromSchemaNode(p.schema)
538
+ });
539
+ }
540
+ if (zod.requestName) otherEntries.push({
541
+ key: "data",
542
+ value: zod.requestName
543
+ });
544
+ if (zod.queryParams) otherEntries.push({
545
+ key: "params",
546
+ value: zodGroupExpr(zod.queryParams)
547
+ });
548
+ if (zod.headerParams) otherEntries.push({
549
+ key: "headers",
550
+ value: zodGroupExpr(zod.headerParams)
551
+ });
552
+ otherEntries.sort((a, b) => a.key.localeCompare(b.key));
553
+ const entries = [...pathEntries, ...otherEntries];
554
+ const paramsNode = entries.length ? _kubb_core.ast.createFunctionParameters({ params: [_kubb_core.ast.createParameterGroup({ properties: entries.map((e) => _kubb_core.ast.createFunctionParameter({
555
+ name: e.key,
556
+ optional: false
557
+ })) })] }) : void 0;
558
+ const destructured = paramsNode ? keysPrinter.print(paramsNode) ?? "" : "";
559
+ const inputSchema = entries.length ? `{ ${entries.map((e) => `${e.key}: ${e.value}`).join(", ")} }` : void 0;
560
+ const outputSchema = zod.responseName;
561
+ const config = [
562
+ tool.title ? `title: ${JSON.stringify(tool.title)}` : null,
563
+ `description: ${JSON.stringify(tool.description)}`,
564
+ outputSchema ? `outputSchema: { data: ${outputSchema} }` : null
565
+ ].filter(Boolean).join(",\n ");
566
+ if (inputSchema) return `
567
+ server.registerTool(${JSON.stringify(tool.name)}, {
568
+ ${config},
569
+ inputSchema: ${inputSchema},
570
+ }, async (${destructured}, request) => {
571
+ return ${mcp.name}(${destructured}, request)
572
+ })
573
+ `;
574
+ return `
575
+ server.registerTool(${JSON.stringify(tool.name)}, {
576
+ ${config},
577
+ }, async (request) => {
578
+ return ${mcp.name}(request)
579
+ })
580
+ `;
581
+ }).filter(Boolean),
582
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
583
+ name: "startServer",
584
+ async: true,
585
+ export: true,
586
+ children: `try {
587
+ const transport = new StdioServerTransport()
588
+ await server.connect(transport)
589
+
590
+ } catch (error) {
591
+ console.error('Failed to start server:', error)
592
+ process.exit(1)
593
+ }`
594
+ })
595
+ ]
596
+ });
597
+ }
598
+ //#endregion
599
+ //#region src/generators/mcpGenerator.tsx
600
+ const mcpGenerator = (0, _kubb_core.defineGenerator)({
601
+ name: "mcp",
602
+ renderer: _kubb_renderer_jsx.jsxRenderer,
603
+ operation(node, ctx) {
604
+ const { resolver, driver, root } = ctx;
605
+ const { output, client, paramsCasing, group } = ctx.options;
606
+ const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
607
+ if (!pluginTs) return null;
608
+ const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
609
+ const casedParams = _kubb_core.ast.caseParams(node.parameters, paramsCasing);
610
+ const pathParams = casedParams.filter((p) => p.in === "path");
611
+ const queryParams = casedParams.filter((p) => p.in === "query");
612
+ const headerParams = casedParams.filter((p) => p.in === "header");
613
+ const importedTypeNames = [
614
+ ...pathParams.map((p) => tsResolver.resolvePathParamsName(node, p)),
615
+ ...queryParams.map((p) => tsResolver.resolveQueryParamsName(node, p)),
616
+ ...headerParams.map((p) => tsResolver.resolveHeaderParamsName(node, p)),
617
+ node.requestBody?.content?.[0]?.schema ? tsResolver.resolveDataName(node) : void 0,
618
+ tsResolver.resolveResponseName(node),
619
+ ...node.responses.filter((r) => Number(r.statusCode) >= 400).map((r) => tsResolver.resolveResponseStatusName(node, r.statusCode))
620
+ ].filter(Boolean);
621
+ const meta = {
622
+ name: resolver.resolveName(node.operationId),
623
+ file: resolver.resolveFile({
624
+ name: node.operationId,
625
+ extname: ".ts",
626
+ tag: node.tags[0] ?? "default",
627
+ path: node.path
628
+ }, {
629
+ root,
630
+ output,
631
+ group
632
+ }),
633
+ fileTs: tsResolver.resolveFile({
634
+ name: node.operationId,
635
+ extname: ".ts",
636
+ tag: node.tags[0] ?? "default",
637
+ path: node.path
638
+ }, {
639
+ root,
640
+ output: pluginTs.options?.output ?? output,
641
+ group: pluginTs.options?.group
642
+ })
643
+ };
644
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
645
+ baseName: meta.file.baseName,
646
+ path: meta.file.path,
647
+ meta: meta.file.meta,
648
+ children: [
649
+ meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
650
+ name: Array.from(new Set(importedTypeNames)).sort(),
651
+ root: meta.file.path,
652
+ path: meta.fileTs.path,
653
+ isTypeOnly: true
654
+ }),
655
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
656
+ name: [
657
+ "CallToolResult",
658
+ "ServerNotification",
659
+ "ServerRequest"
660
+ ],
661
+ path: "@modelcontextprotocol/sdk/types",
662
+ isTypeOnly: true
663
+ }),
664
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
665
+ name: ["RequestHandlerExtra"],
666
+ path: "@modelcontextprotocol/sdk/shared/protocol",
667
+ isTypeOnly: true
668
+ }),
669
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
670
+ name: ["buildFormData"],
671
+ root: meta.file.path,
672
+ path: node_path.default.resolve(root, ".kubb/config.ts")
673
+ }),
674
+ client.importPath ? /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
675
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
676
+ name: [
677
+ "Client",
678
+ "RequestConfig",
679
+ "ResponseErrorConfig"
680
+ ],
681
+ path: client.importPath,
682
+ isTypeOnly: true
683
+ }),
684
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
685
+ name: "fetch",
686
+ path: client.importPath
687
+ }),
688
+ client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
689
+ name: ["ResponseConfig"],
690
+ path: client.importPath,
691
+ isTypeOnly: true
692
+ })
693
+ ] }) : /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
694
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
695
+ name: [
696
+ "Client",
697
+ "RequestConfig",
698
+ "ResponseErrorConfig"
699
+ ],
700
+ root: meta.file.path,
701
+ path: node_path.default.resolve(root, ".kubb/fetch.ts"),
702
+ isTypeOnly: true
703
+ }),
704
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
705
+ name: ["fetch"],
706
+ root: meta.file.path,
707
+ path: node_path.default.resolve(root, ".kubb/fetch.ts")
708
+ }),
709
+ client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
710
+ name: ["ResponseConfig"],
711
+ root: meta.file.path,
712
+ path: node_path.default.resolve(root, ".kubb/fetch.ts"),
713
+ isTypeOnly: true
714
+ })
715
+ ] }),
716
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(McpHandler, {
717
+ name: meta.name,
718
+ node,
719
+ resolver: tsResolver,
720
+ baseURL: client.baseURL,
721
+ dataReturnType: client.dataReturnType || "data",
722
+ paramsCasing
723
+ })
724
+ ]
725
+ });
726
+ }
727
+ });
728
+ //#endregion
729
+ //#region src/generators/serverGenerator.tsx
730
+ /**
731
+ * Default v5 server generator for `@kubb/plugin-mcp`.
732
+ *
733
+ * Uses individual zod schemas for each param (e.g. `createPetsPathUuidSchema`, `createPetsQueryOffsetSchema`)
734
+ * and `resolveResponseStatusName` for per-status response schemas.
735
+ * Query and header params are composed into `z.object({ ... })` from individual schemas.
736
+ */
737
+ const serverGenerator = (0, _kubb_core.defineGenerator)({
738
+ name: "operations",
739
+ renderer: _kubb_renderer_jsx.jsxRenderer,
740
+ operations(nodes, ctx) {
741
+ const { adapter, config, resolver, plugin, driver, root } = ctx;
742
+ const { output, paramsCasing, group } = ctx.options;
743
+ const pluginZod = driver.getPlugin(_kubb_plugin_zod.pluginZodName);
744
+ if (!pluginZod) return;
745
+ const zodResolver = driver.getResolver(_kubb_plugin_zod.pluginZodName);
746
+ const name = "server";
747
+ const serverFile = {
748
+ baseName: "server.ts",
749
+ path: node_path.default.resolve(root, output.path, "server.ts"),
750
+ meta: { pluginName: plugin.name }
751
+ };
752
+ const jsonFile = {
753
+ baseName: ".mcp.json",
754
+ path: node_path.default.resolve(root, output.path, ".mcp.json"),
755
+ meta: { pluginName: plugin.name }
756
+ };
757
+ const operationsMapped = nodes.map((node) => {
758
+ const casedParams = _kubb_core.ast.caseParams(node.parameters, paramsCasing);
759
+ const pathParams = casedParams.filter((p) => p.in === "path");
760
+ const queryParams = casedParams.filter((p) => p.in === "query");
761
+ const headerParams = casedParams.filter((p) => p.in === "header");
762
+ const mcpFile = resolver.resolveFile({
763
+ name: node.operationId,
764
+ extname: ".ts",
765
+ tag: node.tags[0] ?? "default",
766
+ path: node.path
767
+ }, {
768
+ root,
769
+ output,
770
+ group
771
+ });
772
+ const zodFile = zodResolver.resolveFile({
773
+ name: node.operationId,
774
+ extname: ".ts",
775
+ tag: node.tags[0] ?? "default",
776
+ path: node.path
777
+ }, {
778
+ root,
779
+ output: pluginZod.options?.output ?? output,
780
+ group: pluginZod.options?.group
781
+ });
782
+ const requestName = node.requestBody?.content?.[0]?.schema ? zodResolver.resolveDataName(node) : void 0;
783
+ const successStatus = findSuccessStatusCode(node.responses);
784
+ const responseName = successStatus ? zodResolver.resolveResponseStatusName(node, successStatus) : void 0;
785
+ const resolveParams = (params) => params.map((p) => ({
786
+ name: p.name,
787
+ schemaName: zodResolver.resolveParamName(node, p)
788
+ }));
789
+ return {
790
+ tool: {
791
+ name: node.operationId,
792
+ title: node.summary || void 0,
793
+ description: node.description || `Make a ${node.method.toUpperCase()} request to ${node.path}`
794
+ },
795
+ mcp: {
796
+ name: resolver.resolveName(node.operationId),
797
+ file: mcpFile
798
+ },
799
+ zod: {
800
+ pathParams: resolveParams(pathParams),
801
+ queryParams: queryParams.length ? resolveParams(queryParams) : void 0,
802
+ headerParams: headerParams.length ? resolveParams(headerParams) : void 0,
803
+ requestName,
804
+ responseName,
805
+ file: zodFile
806
+ },
807
+ node
808
+ };
809
+ });
810
+ const imports = operationsMapped.flatMap(({ mcp, zod }) => {
811
+ const zodNames = [
812
+ ...zod.pathParams.map((p) => p.schemaName),
813
+ ...(zod.queryParams ?? []).map((p) => p.schemaName),
814
+ ...(zod.headerParams ?? []).map((p) => p.schemaName),
815
+ zod.requestName,
816
+ zod.responseName
817
+ ].filter(Boolean);
818
+ const uniqueNames = [...new Set(zodNames)].sort();
819
+ return [/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
820
+ name: [mcp.name],
821
+ root: serverFile.path,
822
+ path: mcp.file.path
823
+ }, mcp.name), uniqueNames.length > 0 && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
824
+ name: uniqueNames,
825
+ root: serverFile.path,
826
+ path: zod.file.path
827
+ }, `zod-${mcp.name}`)].filter(Boolean);
828
+ });
829
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
830
+ baseName: serverFile.baseName,
831
+ path: serverFile.path,
832
+ meta: serverFile.meta,
833
+ banner: resolver.resolveBanner(adapter.inputNode, {
834
+ output,
835
+ config
836
+ }),
837
+ footer: resolver.resolveFooter(adapter.inputNode, {
838
+ output,
839
+ config
840
+ }),
841
+ children: [
842
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
843
+ name: ["McpServer"],
844
+ path: "@modelcontextprotocol/sdk/server/mcp"
845
+ }),
846
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
847
+ name: ["z"],
848
+ path: "zod"
849
+ }),
850
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
851
+ name: ["StdioServerTransport"],
852
+ path: "@modelcontextprotocol/sdk/server/stdio"
853
+ }),
854
+ imports,
855
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(Server, {
856
+ name,
857
+ serverName: adapter.inputNode?.meta?.title ?? "server",
858
+ serverVersion: adapter.inputNode?.meta?.version ?? "0.0.0",
859
+ paramsCasing,
860
+ operations: operationsMapped
861
+ })
862
+ ]
863
+ }), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File, {
864
+ baseName: jsonFile.baseName,
865
+ path: jsonFile.path,
866
+ meta: jsonFile.meta,
867
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
868
+ name,
869
+ children: `
870
+ {
871
+ "mcpServers": {
872
+ "${adapter.inputNode?.meta?.title || "server"}": {
873
+ "type": "stdio",
874
+ "command": "npx",
875
+ "args": ["tsx", "${node_path.default.relative(node_path.default.dirname(jsonFile.path), serverFile.path)}"]
876
+ }
877
+ }
878
+ }
879
+ `
880
+ })
881
+ })] });
882
+ }
883
+ });
884
+ //#endregion
885
+ //#region src/resolvers/resolverMcp.ts
886
+ /**
887
+ * Naming convention resolver for MCP plugin.
888
+ *
889
+ * Provides default naming helpers using camelCase with a `handler` suffix for functions.
890
+ *
891
+ * @example
892
+ * `resolverMcp.default('addPet', 'function') // → 'addPetHandler'`
893
+ */
894
+ const resolverMcp = (0, _kubb_core.defineResolver)((ctx) => ({
895
+ name: "default",
896
+ pluginName: "plugin-mcp",
897
+ default(name, type) {
898
+ if (type === "file") return camelCase(name, { isFile: true });
899
+ return camelCase(name, { suffix: "handler" });
900
+ },
901
+ resolveName(name) {
902
+ return ctx.default(name, "function");
903
+ }
904
+ }));
905
+ //#endregion
14
906
  //#region src/plugin.ts
15
907
  const pluginMcpName = "plugin-mcp";
16
- const pluginMcp = (0, _kubb_core.createPlugin)((options) => {
908
+ const pluginMcp = (0, _kubb_core.definePlugin)((options) => {
17
909
  const { output = {
18
910
  path: "mcp",
19
911
  barrelType: "named"
20
- }, group, exclude = [], include, override = [], transformers = {}, generators = [require_generators.mcpGenerator, require_generators.serverGenerator].filter(Boolean), contentType, paramsCasing, client } = options;
912
+ }, group, exclude = [], include, override = [], paramsCasing, client, resolver: userResolver, transformer: userTransformer, generators: userGenerators = [] } = options;
21
913
  const clientName = client?.client ?? "axios";
22
914
  const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : void 0);
915
+ const groupConfig = group ? {
916
+ ...group,
917
+ name: group.name ? group.name : (ctx) => {
918
+ if (group.type === "path") return `${ctx.group.split("/")[1]}`;
919
+ return `${camelCase(ctx.group)}Requests`;
920
+ }
921
+ } : void 0;
23
922
  return {
24
923
  name: pluginMcpName,
25
- options: {
26
- output,
27
- group,
28
- paramsCasing,
29
- client: {
30
- client: clientName,
31
- clientType: client?.clientType ?? "function",
32
- importPath: clientImportPath,
33
- dataReturnType: client?.dataReturnType ?? "data",
34
- bundle: client?.bundle,
35
- baseURL: client?.baseURL,
36
- paramsCasing: client?.paramsCasing
37
- }
38
- },
39
- pre: [
40
- _kubb_plugin_oas.pluginOasName,
41
- _kubb_plugin_ts.pluginTsName,
42
- _kubb_plugin_zod.pluginZodName
43
- ].filter(Boolean),
44
- resolvePath(baseName, pathMode, options) {
45
- const root = node_path.default.resolve(this.config.root, this.config.output.path);
46
- if ((pathMode ?? (0, _kubb_core.getMode)(node_path.default.resolve(root, output.path))) === "single")
47
- /**
48
- * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
49
- * Other plugins then need to call addOrAppend instead of just add from the fileManager class
50
- */
51
- return node_path.default.resolve(root, output.path);
52
- if (group && (options?.group?.path || options?.group?.tag)) {
53
- const groupName = group?.name ? group.name : (ctx) => {
54
- if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
55
- return `${require_Server.camelCase(ctx.group)}Requests`;
56
- };
57
- return node_path.default.resolve(root, output.path, groupName({ group: group.type === "path" ? options.group.path : options.group.tag }), baseName);
58
- }
59
- return node_path.default.resolve(root, output.path, baseName);
60
- },
61
- resolveName(name, type) {
62
- const resolvedName = require_Server.camelCase(name, { isFile: type === "file" });
63
- if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
64
- return resolvedName;
65
- },
66
- async install() {
67
- const root = node_path.default.resolve(this.config.root, this.config.output.path);
68
- const mode = (0, _kubb_core.getMode)(node_path.default.resolve(root, output.path));
69
- const oas = await this.getOas();
70
- const baseURL = await this.getBaseURL();
71
- if (baseURL) this.plugin.options.client.baseURL = baseURL;
72
- const hasClientPlugin = !!this.driver.getPluginByName(_kubb_plugin_client.pluginClientName);
73
- if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.addFile({
924
+ options,
925
+ dependencies: [_kubb_plugin_ts.pluginTsName, _kubb_plugin_zod.pluginZodName],
926
+ hooks: { "kubb:plugin:setup"(ctx) {
927
+ const resolver = userResolver ? {
928
+ ...resolverMcp,
929
+ ...userResolver
930
+ } : resolverMcp;
931
+ ctx.setOptions({
932
+ output,
933
+ exclude,
934
+ include,
935
+ override,
936
+ group: groupConfig,
937
+ paramsCasing,
938
+ client: {
939
+ client: clientName,
940
+ clientType: client?.clientType ?? "function",
941
+ importPath: clientImportPath,
942
+ dataReturnType: client?.dataReturnType ?? "data",
943
+ bundle: client?.bundle,
944
+ baseURL: client?.baseURL,
945
+ paramsCasing: client?.paramsCasing
946
+ },
947
+ resolver
948
+ });
949
+ ctx.setResolver(resolver);
950
+ if (userTransformer) ctx.setTransformer(userTransformer);
951
+ ctx.addGenerator(mcpGenerator);
952
+ ctx.addGenerator(serverGenerator);
953
+ for (const gen of userGenerators) ctx.addGenerator(gen);
954
+ const root = node_path$1.default.resolve(ctx.config.root, ctx.config.output.path);
955
+ const hasClientPlugin = ctx.config.plugins?.some((p) => p.name === _kubb_plugin_client.pluginClientName);
956
+ if (client?.bundle && !hasClientPlugin && !clientImportPath) ctx.injectFile({
74
957
  baseName: "fetch.ts",
75
- path: node_path.default.resolve(root, ".kubb/fetch.ts"),
76
- sources: [{
958
+ path: node_path$1.default.resolve(root, ".kubb/fetch.ts"),
959
+ sources: [_kubb_core.ast.createSource({
77
960
  name: "fetch",
78
- value: this.plugin.options.client.client === "fetch" ? _kubb_plugin_client_templates_clients_fetch_source.source : _kubb_plugin_client_templates_clients_axios_source.source,
961
+ nodes: [_kubb_core.ast.createText(clientName === "fetch" ? _kubb_plugin_client_templates_clients_fetch_source.source : _kubb_plugin_client_templates_clients_axios_source.source)],
79
962
  isExportable: true,
80
963
  isIndexable: true
81
- }],
82
- imports: [],
83
- exports: []
964
+ })]
84
965
  });
85
- if (!hasClientPlugin) await this.addFile({
966
+ if (!hasClientPlugin) ctx.injectFile({
86
967
  baseName: "config.ts",
87
- path: node_path.default.resolve(root, ".kubb/config.ts"),
88
- sources: [{
968
+ path: node_path$1.default.resolve(root, ".kubb/config.ts"),
969
+ sources: [_kubb_core.ast.createSource({
89
970
  name: "config",
90
- value: _kubb_plugin_client_templates_config_source.source,
971
+ nodes: [_kubb_core.ast.createText(_kubb_plugin_client_templates_config_source.source)],
91
972
  isExportable: false,
92
973
  isIndexable: false
93
- }],
94
- imports: [],
95
- exports: []
974
+ })]
96
975
  });
97
- const files = await new _kubb_plugin_oas.OperationGenerator(this.plugin.options, {
98
- fabric: this.fabric,
99
- oas,
100
- driver: this.driver,
101
- events: this.events,
102
- plugin: this.plugin,
103
- contentType,
104
- exclude,
105
- include,
106
- override,
107
- mode
108
- }).build(...generators);
109
- await this.upsertFile(...files);
110
- const barrelFiles = await (0, _kubb_core.getBarrelFiles)(this.fabric.files, {
111
- type: output.barrelType ?? "named",
112
- root,
113
- output,
114
- meta: { pluginName: this.plugin.name }
115
- });
116
- await this.upsertFile(...barrelFiles);
117
- }
976
+ } }
118
977
  };
119
978
  });
120
979
  //#endregion
980
+ exports.McpHandler = McpHandler;
981
+ exports.Server = Server;
982
+ exports.default = pluginMcp;
983
+ exports.mcpGenerator = mcpGenerator;
121
984
  exports.pluginMcp = pluginMcp;
122
985
  exports.pluginMcpName = pluginMcpName;
986
+ exports.resolverMcp = resolverMcp;
987
+ exports.serverGenerator = serverGenerator;
123
988
 
124
989
  //# sourceMappingURL=index.cjs.map