@kubb/plugin-mcp 5.4.0-canary.20261029T124214 → 5.4.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/index.cjs +87 -70
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +36 -19
- package/dist/index.js.map +1 -1
- package/kubb-extension.json +1 -1
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -23,11 +23,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
value: mod,
|
|
24
24
|
enumerable: true
|
|
25
25
|
}) : target, mod));
|
|
26
|
-
let
|
|
26
|
+
let _kubb_kit = require("@kubb/kit");
|
|
27
27
|
let node_path = require("node:path");
|
|
28
28
|
node_path = __toESM(node_path, 1);
|
|
29
|
-
let
|
|
30
|
-
let
|
|
29
|
+
let _kubb_renderer_jsx = require("@kubb/renderer-jsx");
|
|
30
|
+
let _kubb_renderer_jsx_jsx_runtime = require("@kubb/renderer-jsx/jsx-runtime");
|
|
31
31
|
let _kubb_plugin_zod = require("@kubb/plugin-zod");
|
|
32
32
|
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
33
33
|
// ../../internals/shared/src/operation.ts
|
|
@@ -51,19 +51,19 @@ function operationFileEntry(node, name, extname = ".ts") {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
|
-
* Resolves a dependency plugin's generated file for `node.operationId`, cached in `
|
|
55
|
-
*
|
|
54
|
+
* Resolves a dependency plugin's generated file for `node.operationId`, cached in `memo` (the
|
|
55
|
+
* build's `ctx.memo`) under the resolver's own plugin name and the operation. Several dependents reading the
|
|
56
56
|
* same dependency for the same operation in one pass (a query plugin's several hook generators, the
|
|
57
57
|
* MCP handler, ...) share one computed name and path instead of each calling `resolver.file` again.
|
|
58
58
|
*
|
|
59
59
|
* @example Cache `plugin-ts`'s file for the current operation
|
|
60
60
|
* ```ts
|
|
61
|
-
* const fileTs = resolveDependencyOperationFile({
|
|
61
|
+
* const fileTs = resolveDependencyOperationFile({ memo: ctx.memo, node, resolver: tsResolver, root, output })
|
|
62
62
|
* ```
|
|
63
63
|
*/
|
|
64
64
|
function resolveDependencyOperationFile(options) {
|
|
65
|
-
const {
|
|
66
|
-
return
|
|
65
|
+
const { memo, node, resolver, root, output, group } = options;
|
|
66
|
+
return memo(`${resolver.pluginName}:operationFile:${node.operationId}`, () => resolver.file({
|
|
67
67
|
...operationFileEntry(node, node.operationId),
|
|
68
68
|
root,
|
|
69
69
|
output,
|
|
@@ -73,7 +73,7 @@ function resolveDependencyOperationFile(options) {
|
|
|
73
73
|
function getOperationLink(node, link) {
|
|
74
74
|
if (!link) return null;
|
|
75
75
|
if (typeof link === "function") return link(node) ?? null;
|
|
76
|
-
return node.path ? `{@link ${
|
|
76
|
+
return node.path ? `{@link ${_kubb_kit.Url.toPath(node.path)}}` : null;
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* Derives the shared `ContentTypeInfo` shape from a list of content types, tracking whether several
|
|
@@ -177,6 +177,22 @@ function buildOperationComments(node, options = {}) {
|
|
|
177
177
|
}
|
|
178
178
|
const operationParameterGroupsByNode = /* @__PURE__ */ new WeakMap();
|
|
179
179
|
/**
|
|
180
|
+
* An OpenAPI 3.2 `querystring` parameter is the whole query string, so a form-encoded object becomes one query parameter
|
|
181
|
+
* per property, typed and serialized like any other.
|
|
182
|
+
* Another content type, such as JSON, stays one parameter named after it, and the runtime sends its value as the whole query string.
|
|
183
|
+
*/
|
|
184
|
+
function spreadQuerystring(param) {
|
|
185
|
+
const schema = param.schema.type === "ref" ? param.schema.schema : param.schema;
|
|
186
|
+
const formEncoded = !param.contentType || param.contentType.split(";")[0].trim().toLowerCase() === "application/x-www-form-urlencoded";
|
|
187
|
+
if (schema?.type !== "object" || !formEncoded) return [param];
|
|
188
|
+
return schema.properties.map((property) => _kubb_kit.ast.factory.createParameter({
|
|
189
|
+
name: property.name,
|
|
190
|
+
in: "query",
|
|
191
|
+
schema: property.schema,
|
|
192
|
+
required: param.required && property.required
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
180
196
|
* Groups an operation's parameters by location (`path`/`query`/`header`/`cookie`), deduping each
|
|
181
197
|
* group by name. Every plugin generator visiting the same `OperationNode` shares one AST instance
|
|
182
198
|
* (see `KubbDriver`), so the result is cached per node to avoid re-filtering and re-deduping the
|
|
@@ -185,17 +201,18 @@ const operationParameterGroupsByNode = /* @__PURE__ */ new WeakMap();
|
|
|
185
201
|
function getOperationParameters(node) {
|
|
186
202
|
const cached = operationParameterGroupsByNode.get(node);
|
|
187
203
|
if (cached) return cached;
|
|
188
|
-
const
|
|
204
|
+
const dedupe = (params) => {
|
|
189
205
|
const seen = /* @__PURE__ */ new Set();
|
|
190
|
-
return
|
|
191
|
-
if (
|
|
206
|
+
return params.filter((param) => {
|
|
207
|
+
if (seen.has(param.name)) return false;
|
|
192
208
|
seen.add(param.name);
|
|
193
209
|
return true;
|
|
194
210
|
});
|
|
195
211
|
};
|
|
212
|
+
const group = (location) => dedupe(node.parameters.filter((param) => param.in === location));
|
|
196
213
|
const groups = {
|
|
197
214
|
path: group("path"),
|
|
198
|
-
query: group("query"),
|
|
215
|
+
query: dedupe([...group("query"), ...group("querystring").flatMap(spreadQuerystring)]),
|
|
199
216
|
header: group("header"),
|
|
200
217
|
cookie: group("cookie")
|
|
201
218
|
};
|
|
@@ -296,7 +313,7 @@ function createGroupConfig(group) {
|
|
|
296
313
|
if (!group) return null;
|
|
297
314
|
const defaultName = (ctx) => {
|
|
298
315
|
if (group.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
299
|
-
return (0,
|
|
316
|
+
return (0, _kubb_kit.camelCase)(ctx.group);
|
|
300
317
|
};
|
|
301
318
|
return {
|
|
302
319
|
...group,
|
|
@@ -329,11 +346,11 @@ function McpHandler({ name, clientName, node, resolver, returnType = "full" }) {
|
|
|
329
346
|
],
|
|
330
347
|
structuredContent: { data: ${body} }
|
|
331
348
|
}`;
|
|
332
|
-
return /* @__PURE__ */ (0,
|
|
349
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
333
350
|
name,
|
|
334
351
|
isExportable: true,
|
|
335
352
|
isIndexable: true,
|
|
336
|
-
children: /* @__PURE__ */ (0,
|
|
353
|
+
children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.Function, {
|
|
337
354
|
name,
|
|
338
355
|
async: true,
|
|
339
356
|
export: true,
|
|
@@ -342,7 +359,7 @@ function McpHandler({ name, clientName, node, resolver, returnType = "full" }) {
|
|
|
342
359
|
returnType: "CallToolResult",
|
|
343
360
|
children: [
|
|
344
361
|
`const res = await ${clientName}(${callArg})`,
|
|
345
|
-
/* @__PURE__ */ (0,
|
|
362
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
|
|
346
363
|
callToolResult
|
|
347
364
|
]
|
|
348
365
|
})
|
|
@@ -396,12 +413,12 @@ server.registerTool(${JSON.stringify(tool.name)}, {
|
|
|
396
413
|
})
|
|
397
414
|
`;
|
|
398
415
|
}).filter(Boolean).join("\n");
|
|
399
|
-
return /* @__PURE__ */ (0,
|
|
400
|
-
/* @__PURE__ */ (0,
|
|
416
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
417
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
401
418
|
name: "getServer",
|
|
402
419
|
isExportable: true,
|
|
403
420
|
isIndexable: true,
|
|
404
|
-
children: /* @__PURE__ */ (0,
|
|
421
|
+
children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
|
|
405
422
|
name: "getServer",
|
|
406
423
|
export: true,
|
|
407
424
|
children: `const server = new McpServer({
|
|
@@ -412,21 +429,21 @@ ${registrations}
|
|
|
412
429
|
return server`
|
|
413
430
|
})
|
|
414
431
|
}),
|
|
415
|
-
/* @__PURE__ */ (0,
|
|
432
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
416
433
|
name: "server",
|
|
417
434
|
isExportable: true,
|
|
418
435
|
isIndexable: true,
|
|
419
|
-
children: /* @__PURE__ */ (0,
|
|
436
|
+
children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Const, {
|
|
420
437
|
name: "server",
|
|
421
438
|
export: true,
|
|
422
439
|
children: "getServer()"
|
|
423
440
|
})
|
|
424
441
|
}),
|
|
425
|
-
/* @__PURE__ */ (0,
|
|
442
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
426
443
|
name: "startServer",
|
|
427
444
|
isExportable: true,
|
|
428
445
|
isIndexable: true,
|
|
429
|
-
children: /* @__PURE__ */ (0,
|
|
446
|
+
children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
|
|
430
447
|
name: "startServer",
|
|
431
448
|
async: true,
|
|
432
449
|
export: true,
|
|
@@ -489,8 +506,8 @@ function resolveOperationTypes(driver, pluginName) {
|
|
|
489
506
|
group: pluginTs.options?.group ?? void 0
|
|
490
507
|
};
|
|
491
508
|
}
|
|
492
|
-
if (!pluginZod?.options?.inferred) throw new
|
|
493
|
-
code:
|
|
509
|
+
if (!pluginZod?.options?.inferred) throw new _kubb_kit.Diagnostics.Error({
|
|
510
|
+
code: _kubb_kit.Diagnostics.code.missingDependency,
|
|
494
511
|
severity: "error",
|
|
495
512
|
message: `Plugin "${pluginName}" has no source for operation types.`,
|
|
496
513
|
help: `Add \`pluginTs()\` before "${pluginName}", or add \`pluginZod({ inferred: true })\`.`,
|
|
@@ -558,7 +575,7 @@ function resolveClient(options) {
|
|
|
558
575
|
const pluginName = selectorToPlugin[client];
|
|
559
576
|
if (!has(pluginName)) return {
|
|
560
577
|
kind: "error",
|
|
561
|
-
code:
|
|
578
|
+
code: _kubb_kit.Diagnostics.code.missingDependency,
|
|
562
579
|
message: `\`client: '${client}'\` is set but \`@kubb/plugin-${client}\` is not registered in \`plugins\`.`,
|
|
563
580
|
help: `Add \`@kubb/plugin-${client}\` to \`plugins\`, or drop \`client\` to use a different client plugin.`
|
|
564
581
|
};
|
|
@@ -569,7 +586,7 @@ function resolveClient(options) {
|
|
|
569
586
|
}
|
|
570
587
|
if (client !== void 0) return {
|
|
571
588
|
kind: "error",
|
|
572
|
-
code:
|
|
589
|
+
code: _kubb_kit.Diagnostics.code.invalidPluginOptions,
|
|
573
590
|
message: `Option \`client\` is ${typeof client === "string" ? `'${client}'` : String(client)}, but it must be one of 'fetch', 'axios', 'client'.`,
|
|
574
591
|
help: "Set `client` to one of those values, or drop it to use the registered client plugin."
|
|
575
592
|
};
|
|
@@ -580,13 +597,13 @@ function resolveClient(options) {
|
|
|
580
597
|
};
|
|
581
598
|
if (registered.length > 1) return {
|
|
582
599
|
kind: "error",
|
|
583
|
-
code:
|
|
600
|
+
code: _kubb_kit.Diagnostics.code.invalidPluginOptions,
|
|
584
601
|
message: `Multiple client plugins are registered (${registered.map((name) => `\`@kubb/${name}\``).join(", ")}) and \`client\` is not set.`,
|
|
585
602
|
help: "Set `client: 'fetch' | 'axios' | 'client'` to choose which client the hooks call, or register a single client plugin."
|
|
586
603
|
};
|
|
587
604
|
return {
|
|
588
605
|
kind: "error",
|
|
589
|
-
code:
|
|
606
|
+
code: _kubb_kit.Diagnostics.code.missingDependency,
|
|
590
607
|
message: "No client plugin is registered.",
|
|
591
608
|
help: "Add `@kubb/plugin-fetch`, `@kubb/plugin-axios`, or `@kubb/plugin-client` to `plugins` so the generated code has an HTTP client to call."
|
|
592
609
|
};
|
|
@@ -605,7 +622,7 @@ function resolveContractClient(options) {
|
|
|
605
622
|
});
|
|
606
623
|
if (resolved.kind === "error") {
|
|
607
624
|
const { code, message, help } = resolved;
|
|
608
|
-
throw new
|
|
625
|
+
throw new _kubb_kit.Diagnostics.Error({
|
|
609
626
|
code,
|
|
610
627
|
severity: "error",
|
|
611
628
|
message,
|
|
@@ -633,7 +650,7 @@ function resolveImportPath(options) {
|
|
|
633
650
|
* output root, the same path consumers read `RequestConfig` / `ResponseErrorConfig` from.
|
|
634
651
|
* With plugin-client they come from the user's `importPath` module instead.
|
|
635
652
|
*
|
|
636
|
-
* The result is cached in the
|
|
653
|
+
* The result is cached in `memo` (the build's `ctx.memo`) under the client plugin's name and the operation,
|
|
637
654
|
* so several dependents reading the same client plugin for one operation in a single pass
|
|
638
655
|
* (react-query's query/mutation/infinite generators, vue-query, swr, the MCP handler, ...) share
|
|
639
656
|
* one computed result instead of each re-deriving the name and path.
|
|
@@ -643,9 +660,9 @@ function resolveImportPath(options) {
|
|
|
643
660
|
* and import path therefore match the `<op>` actually emitted, even when an `override` changes it.
|
|
644
661
|
*/
|
|
645
662
|
function resolveClientOperation(options) {
|
|
646
|
-
const { clientPlugin, driver, node, root, output,
|
|
663
|
+
const { clientPlugin, driver, node, root, output, memo } = options;
|
|
647
664
|
if (!clientPlugin) return null;
|
|
648
|
-
return
|
|
665
|
+
return memo(`${clientPlugin.pluginName}:clientOperation:${node.operationId}`, () => {
|
|
649
666
|
const resolver = driver.getResolver(clientPlugin.pluginName);
|
|
650
667
|
const pluginOptions = driver.getPlugin(clientPlugin.pluginName)?.options ?? {};
|
|
651
668
|
const { exclude, include, override } = pluginOptions;
|
|
@@ -686,11 +703,11 @@ function resolveClientOperation(options) {
|
|
|
686
703
|
* headers, body }` config and forwards it to the registered client plugin's
|
|
687
704
|
* (`@kubb/plugin-axios` / `@kubb/plugin-fetch`) `<op>` function.
|
|
688
705
|
*/
|
|
689
|
-
const mcpGenerator = (0,
|
|
706
|
+
const mcpGenerator = (0, _kubb_kit.defineGenerator)({
|
|
690
707
|
name: "mcp",
|
|
691
|
-
renderer:
|
|
708
|
+
renderer: _kubb_renderer_jsx.jsxRenderer,
|
|
692
709
|
operation(node, ctx) {
|
|
693
|
-
if (!
|
|
710
|
+
if (!_kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
694
711
|
const { resolver, driver, root, config } = ctx;
|
|
695
712
|
const { output, client, group } = ctx.options;
|
|
696
713
|
const types = resolveOperationTypes(driver, resolver.pluginName);
|
|
@@ -701,7 +718,7 @@ const mcpGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
701
718
|
node,
|
|
702
719
|
root,
|
|
703
720
|
output,
|
|
704
|
-
|
|
721
|
+
memo: ctx.memo
|
|
705
722
|
});
|
|
706
723
|
if (!contractOp) return null;
|
|
707
724
|
const optionsName = tsResolver.response.options(node);
|
|
@@ -714,7 +731,7 @@ const mcpGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
714
731
|
group: group ?? void 0
|
|
715
732
|
}),
|
|
716
733
|
fileTs: resolveDependencyOperationFile({
|
|
717
|
-
|
|
734
|
+
memo: ctx.memo,
|
|
718
735
|
node,
|
|
719
736
|
resolver: tsResolver,
|
|
720
737
|
root,
|
|
@@ -722,7 +739,7 @@ const mcpGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
722
739
|
group: types.group
|
|
723
740
|
})
|
|
724
741
|
};
|
|
725
|
-
return /* @__PURE__ */ (0,
|
|
742
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
|
|
726
743
|
baseName: meta.file.baseName,
|
|
727
744
|
path: meta.file.path,
|
|
728
745
|
meta: meta.file.meta,
|
|
@@ -743,23 +760,23 @@ const mcpGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
743
760
|
}
|
|
744
761
|
}),
|
|
745
762
|
children: [
|
|
746
|
-
meta.fileTs && optionsName && /* @__PURE__ */ (0,
|
|
763
|
+
meta.fileTs && optionsName && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
747
764
|
name: [optionsName],
|
|
748
765
|
root: meta.file.path,
|
|
749
766
|
path: meta.fileTs.path,
|
|
750
767
|
isTypeOnly: true
|
|
751
768
|
}),
|
|
752
|
-
/* @__PURE__ */ (0,
|
|
769
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
753
770
|
name: ["CallToolResult", "ServerContext"],
|
|
754
771
|
path: "@modelcontextprotocol/server",
|
|
755
772
|
isTypeOnly: true
|
|
756
773
|
}),
|
|
757
|
-
/* @__PURE__ */ (0,
|
|
774
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
758
775
|
name: [contractOp.name],
|
|
759
776
|
root: meta.file.path,
|
|
760
777
|
path: contractOp.path
|
|
761
778
|
}),
|
|
762
|
-
/* @__PURE__ */ (0,
|
|
779
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(McpHandler, {
|
|
763
780
|
name: meta.name,
|
|
764
781
|
clientName: contractOp.name,
|
|
765
782
|
node,
|
|
@@ -778,9 +795,9 @@ const mcpGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
778
795
|
* and `resolveResponseStatusName` for per-status response schemas.
|
|
779
796
|
* Query and header params are composed into `z.object({ ... })` from individual schemas.
|
|
780
797
|
*/
|
|
781
|
-
const serverGenerator = (0,
|
|
798
|
+
const serverGenerator = (0, _kubb_kit.defineGenerator)({
|
|
782
799
|
name: "operations",
|
|
783
|
-
renderer:
|
|
800
|
+
renderer: _kubb_renderer_jsx.jsxRenderer,
|
|
784
801
|
operations(nodes, ctx) {
|
|
785
802
|
const { config, resolver, plugin, driver, root } = ctx;
|
|
786
803
|
const { output, group } = ctx.options;
|
|
@@ -799,7 +816,7 @@ const serverGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
799
816
|
command: "npx",
|
|
800
817
|
args: ["tsx", getRelativePath(node_path.default.resolve(config.root), startFile.path)]
|
|
801
818
|
} } };
|
|
802
|
-
const operationsMapped = nodes.filter(
|
|
819
|
+
const operationsMapped = nodes.filter(_kubb_kit.ast.isHttpOperationNode).map((node) => {
|
|
803
820
|
const { path: pathParams, query: queryParams, header: headerParams } = getOperationParameters(node);
|
|
804
821
|
const fileEntry = operationFileEntry(node, node.operationId);
|
|
805
822
|
const mcpFile = resolver.file({
|
|
@@ -850,18 +867,18 @@ const serverGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
850
867
|
zod.responseName
|
|
851
868
|
].filter((name) => Boolean(name));
|
|
852
869
|
const uniqueNames = [...new Set(zodNames)].sort();
|
|
853
|
-
return [/* @__PURE__ */ (0,
|
|
870
|
+
return [/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
854
871
|
name: [mcp.name],
|
|
855
872
|
root: serverFile.path,
|
|
856
873
|
path: mcp.file.path
|
|
857
|
-
}, mcp.name), uniqueNames.length > 0 && /* @__PURE__ */ (0,
|
|
874
|
+
}, mcp.name), uniqueNames.length > 0 && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
858
875
|
name: uniqueNames,
|
|
859
876
|
root: serverFile.path,
|
|
860
877
|
path: zod.file.path
|
|
861
878
|
}, `zod-${mcp.name}`)].filter(Boolean);
|
|
862
879
|
});
|
|
863
|
-
return /* @__PURE__ */ (0,
|
|
864
|
-
/* @__PURE__ */ (0,
|
|
880
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
|
|
881
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
|
|
865
882
|
baseName: serverFile.baseName,
|
|
866
883
|
path: serverFile.path,
|
|
867
884
|
meta: serverFile.meta,
|
|
@@ -882,27 +899,27 @@ const serverGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
882
899
|
}
|
|
883
900
|
}),
|
|
884
901
|
children: [
|
|
885
|
-
/* @__PURE__ */ (0,
|
|
902
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
886
903
|
name: ["McpServer"],
|
|
887
904
|
path: "@modelcontextprotocol/server"
|
|
888
905
|
}),
|
|
889
|
-
/* @__PURE__ */ (0,
|
|
906
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
890
907
|
name: ["serveStdio"],
|
|
891
908
|
path: "@modelcontextprotocol/server/stdio"
|
|
892
909
|
}),
|
|
893
|
-
/* @__PURE__ */ (0,
|
|
910
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
894
911
|
name: ["z"],
|
|
895
912
|
path: "zod"
|
|
896
913
|
}),
|
|
897
914
|
imports,
|
|
898
|
-
/* @__PURE__ */ (0,
|
|
915
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(Server, {
|
|
899
916
|
serverName: ctx.meta.title ?? "server",
|
|
900
917
|
serverVersion: ctx.meta.version ?? "0.0.0",
|
|
901
918
|
operations: operationsMapped
|
|
902
919
|
})
|
|
903
920
|
]
|
|
904
921
|
}),
|
|
905
|
-
/* @__PURE__ */ (0,
|
|
922
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
|
|
906
923
|
baseName: startFile.baseName,
|
|
907
924
|
path: startFile.path,
|
|
908
925
|
meta: startFile.meta,
|
|
@@ -922,20 +939,20 @@ const serverGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
922
939
|
baseName: startFile.baseName
|
|
923
940
|
}
|
|
924
941
|
}),
|
|
925
|
-
children: [/* @__PURE__ */ (0,
|
|
942
|
+
children: [/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
926
943
|
name: ["startServer"],
|
|
927
944
|
root: startFile.path,
|
|
928
945
|
path: serverFile.path
|
|
929
|
-
}), /* @__PURE__ */ (0,
|
|
946
|
+
}), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
930
947
|
name: "start",
|
|
931
948
|
children: "void startServer()"
|
|
932
949
|
})]
|
|
933
950
|
}),
|
|
934
|
-
/* @__PURE__ */ (0,
|
|
951
|
+
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File, {
|
|
935
952
|
baseName: jsonFile.baseName,
|
|
936
953
|
path: jsonFile.path,
|
|
937
954
|
meta: jsonFile.meta,
|
|
938
|
-
children: /* @__PURE__ */ (0,
|
|
955
|
+
children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
939
956
|
name: "server",
|
|
940
957
|
children: `${JSON.stringify(mcpConfig, null, 2)}\n`
|
|
941
958
|
})
|
|
@@ -945,11 +962,11 @@ const serverGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
945
962
|
});
|
|
946
963
|
// kubb-extension.json
|
|
947
964
|
var compatibility = {
|
|
948
|
-
"kubb": ">=5.
|
|
965
|
+
"kubb": ">=5.16.0",
|
|
949
966
|
"node": ">=22.22"
|
|
950
967
|
};
|
|
951
968
|
// package.json
|
|
952
|
-
var version = "5.4.
|
|
969
|
+
var version = "5.4.1";
|
|
953
970
|
// src/resolvers/resolverMcp.ts
|
|
954
971
|
/**
|
|
955
972
|
* Default resolver used by `@kubb/plugin-mcp`. Decides the names and file
|
|
@@ -963,10 +980,10 @@ var version = "5.4.0-canary.20261029T124214";
|
|
|
963
980
|
* resolverMcp.name('addPet') // 'addPetHandler'
|
|
964
981
|
* ```
|
|
965
982
|
*/
|
|
966
|
-
const resolverMcp = (0,
|
|
983
|
+
const resolverMcp = (0, _kubb_kit.createResolver)({
|
|
967
984
|
pluginName: "plugin-mcp",
|
|
968
985
|
name(name) {
|
|
969
|
-
return this.memo(`name:${name}`, () => (0,
|
|
986
|
+
return this.memo(`name:${name}`, () => (0, _kubb_kit.camelCase)(name, { suffix: "handler" }));
|
|
970
987
|
},
|
|
971
988
|
handler: { name(node) {
|
|
972
989
|
const name = this.name(node.operationId);
|
|
@@ -1010,7 +1027,7 @@ const pluginMcpName = "plugin-mcp";
|
|
|
1010
1027
|
* })
|
|
1011
1028
|
* ```
|
|
1012
1029
|
*/
|
|
1013
|
-
const pluginMcp = (0,
|
|
1030
|
+
const pluginMcp = (0, _kubb_kit.defineExtension)({
|
|
1014
1031
|
kind: "plugin",
|
|
1015
1032
|
meta: {
|
|
1016
1033
|
name: pluginMcpName,
|
|
@@ -1026,10 +1043,10 @@ const pluginMcp = (0, kubb_kit.defineExtension)({
|
|
|
1026
1043
|
path: "mcp",
|
|
1027
1044
|
barrel: { type: "named" }
|
|
1028
1045
|
}, group, exclude = [], include, override = [], client, resolver: userResolver, macros: userMacros } = options;
|
|
1029
|
-
const resolver = userResolver ?
|
|
1030
|
-
(0,
|
|
1031
|
-
if (userMacros?.length) (0,
|
|
1032
|
-
(0,
|
|
1046
|
+
const resolver = userResolver ? _kubb_kit.Resolver.merge(resolverMcp, userResolver) : resolverMcp;
|
|
1047
|
+
(0, _kubb_kit.setResolver)(resolver);
|
|
1048
|
+
if (userMacros?.length) (0, _kubb_kit.setMacros)(userMacros);
|
|
1049
|
+
(0, _kubb_kit.addGenerator)(mcpGenerator, serverGenerator);
|
|
1033
1050
|
return {
|
|
1034
1051
|
output,
|
|
1035
1052
|
exclude,
|
|
@@ -1039,7 +1056,7 @@ const pluginMcp = (0, kubb_kit.defineExtension)({
|
|
|
1039
1056
|
client: resolveContractClient({
|
|
1040
1057
|
plugin: pluginMcpName,
|
|
1041
1058
|
client,
|
|
1042
|
-
plugins: (0,
|
|
1059
|
+
plugins: (0, _kubb_kit.useConfig)().plugins
|
|
1043
1060
|
}),
|
|
1044
1061
|
resolver
|
|
1045
1062
|
};
|