@kubb/plugin-mcp 5.5.0 → 5.5.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.d.ts CHANGED
@@ -273,5 +273,4 @@ export declare const pluginMcp: import("@kubb/kit").PluginFactory<PluginMcp>;
273
273
  * ```
274
274
  */
275
275
  export declare const resolverMcp: ResolverMcp;
276
- export { type PluginMcp, type ResolverMcp, pluginMcp as default };
277
- //# sourceMappingURL=index.d.ts.map
276
+ export { type PluginMcp, type ResolverMcp, pluginMcp as default };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import path, { posix } from "node:path";
3
3
  import { Const, File, Function, jsxRenderer } from "@kubb/renderer-jsx";
4
4
  import { Fragment, jsx, jsxs } from "@kubb/renderer-jsx/jsx-runtime";
5
5
  import { pluginTsName } from "@kubb/plugin-ts";
6
- import { pluginZodName } from "@kubb/plugin-zod";
6
+ import { pluginZodName as pluginZodName$1 } from "@kubb/plugin-zod";
7
7
  // ../../internals/utils/src/fs.ts
8
8
  function toSlash(p) {
9
9
  if (p.startsWith("\\\\?\\")) return p;
@@ -371,12 +371,12 @@ function Server({ serverName, serverVersion, operations }) {
371
371
  value: zod.requestName
372
372
  });
373
373
  const destructured = `{ ${entries.map((e) => e.key).join(", ")} }`;
374
- const inputSchema = entries.length ? `z.object({ ${entries.map((e) => `${e.key}: ${e.value}`).join(", ")} })` : null;
374
+ const inputSchema = entries.length ? `toolSchema(z.object({ ${entries.map((e) => `${e.key}: ${e.value}`).join(", ")} }))` : null;
375
375
  const outputSchema = zod.responseName;
376
376
  const config = [
377
377
  tool.title ? `title: ${JSON.stringify(tool.title)}` : null,
378
378
  `description: ${JSON.stringify(tool.description)}`,
379
- outputSchema ? `outputSchema: z.object({ data: ${outputSchema} })` : null
379
+ outputSchema ? `outputSchema: toolSchema(z.object({ data: ${outputSchema} }))` : null
380
380
  ].filter(Boolean).join(",\n ");
381
381
  if (inputSchema) return `
382
382
  server.registerTool(${JSON.stringify(tool.name)}, {
@@ -395,6 +395,31 @@ server.registerTool(${JSON.stringify(tool.name)}, {
395
395
  `;
396
396
  }).filter(Boolean).join("");
397
397
  return /* @__PURE__ */ jsxs(Fragment, { children: [
398
+ /* @__PURE__ */ jsx(File.Source, {
399
+ name: "toolSchema",
400
+ children: /* @__PURE__ */ jsx(Function, {
401
+ name: "toolSchema",
402
+ generics: "T extends z.ZodType",
403
+ params: "schema: T",
404
+ JSDoc: { comments: ["Converts with `unrepresentable: \"any\"`, because a `bigint` or `Blob` in one tool schema fails every `tools/list` request.", "A `bigint` is listed as an `int64` integer and a `Blob` as an unconstrained value."] },
405
+ children: `const standard = schema['~standard']
406
+ const convert = (io: 'input' | 'output') => (options: Parameters<typeof standard.jsonSchema.input>[0]) =>
407
+ standard.jsonSchema[io]({
408
+ ...options,
409
+ libraryOptions: {
410
+ unrepresentable: 'any',
411
+ override: ({ zodSchema, jsonSchema }: { zodSchema: z.core.$ZodType; jsonSchema: Record<string, unknown> }) => {
412
+ if (zodSchema._zod.def.type === 'bigint') {
413
+ jsonSchema.type = 'integer'
414
+ jsonSchema.format = 'int64'
415
+ }
416
+ },
417
+ },
418
+ })
419
+
420
+ return { '~standard': { ...standard, jsonSchema: { input: convert('input'), output: convert('output') } } }`
421
+ })
422
+ }),
398
423
  /* @__PURE__ */ jsx(File.Source, {
399
424
  name: "getServer",
400
425
  isExportable: true,
@@ -610,7 +635,7 @@ function resolveClientOperation(options) {
610
635
  });
611
636
  }
612
637
  // ../../internals/client/src/resolveOperationTypes.ts
613
- const pluginZodName$1 = "plugin-zod";
638
+ const pluginZodName = "plugin-zod";
614
639
  /**
615
640
  * A `plugin-ts` shaped resolver whose operation type names point at the types `pluginZod({ inferred })`
616
641
  * exports next to each schema, so code written against `plugin-ts` names picks up the zod types.
@@ -654,7 +679,7 @@ function toZodTypeResolver(resolver) {
654
679
  function resolveOperationTypes(driver, pluginName) {
655
680
  return driver.memo(`operationTypes:${pluginName}`, () => {
656
681
  const pluginTs = driver.getPlugin(pluginTsName);
657
- const pluginZod = driver.getPlugin(pluginZodName$1);
682
+ const pluginZod = driver.getPlugin(pluginZodName);
658
683
  if (pluginTs && pluginZod?.options?.inferred !== "codec") {
659
684
  const resolver = driver.getResolver(pluginTsName);
660
685
  return {
@@ -672,7 +697,7 @@ function resolveOperationTypes(driver, pluginName) {
672
697
  location: { kind: "config" },
673
698
  plugin: pluginName
674
699
  });
675
- const resolver = toZodTypeResolver(driver.getResolver(pluginZodName$1));
700
+ const resolver = toZodTypeResolver(driver.getResolver(pluginZodName));
676
701
  return {
677
702
  response: resolver.response,
678
703
  resolver,
@@ -787,8 +812,8 @@ const serverGenerator = defineGenerator({
787
812
  operations(nodes, ctx) {
788
813
  const { config, resolver, plugin, driver, root } = ctx;
789
814
  const { output, group } = ctx.options;
790
- const pluginZod = ctx.requirePlugin(pluginZodName);
791
- const zodResolver = driver.getResolver(pluginZodName);
815
+ const pluginZod = ctx.requirePlugin(pluginZodName$1);
816
+ const zodResolver = driver.getResolver(pluginZodName$1);
792
817
  const fileAt = (baseName) => ({
793
818
  baseName,
794
819
  path: path.resolve(root, output.path, baseName),
@@ -956,7 +981,7 @@ var compatibility = {
956
981
  "node": ">=22.22"
957
982
  };
958
983
  // package.json
959
- var version = "5.5.0";
984
+ var version = "5.5.1";
960
985
  // src/resolvers/resolverMcp.ts
961
986
  /**
962
987
  * Default resolver used by `@kubb/plugin-mcp`. Decides the names and file
@@ -1026,7 +1051,7 @@ const pluginMcp = defineExtension({
1026
1051
  },
1027
1052
  dependencies: {
1028
1053
  [pluginTsName]: { optional: true },
1029
- [pluginZodName]: {}
1054
+ [pluginZodName$1]: {}
1030
1055
  },
1031
1056
  setup(options) {
1032
1057
  const { output = {