@kubb/plugin-mcp 5.0.0-beta.64 → 5.0.0-beta.74

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
@@ -1,100 +1,18 @@
1
- import { t as __name } from "./chunk-C0LytTxp.js";
2
- import { Exclude, Generator, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
1
+ import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
+ import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
3
3
  import { ResolverTs } from "@kubb/plugin-ts";
4
- import { ClientImportPath, PluginClient } from "@kubb/plugin-client";
5
4
  import { KubbReactNode } from "@kubb/renderer-jsx/types";
6
5
 
7
- //#region src/types.d.ts
8
- /**
9
- * Resolver for MCP that provides naming methods for handler functions.
10
- */
11
- type ResolverMcp = Resolver & {
12
- /**
13
- * Resolves the base handler function name for an operation.
14
- *
15
- * @example Resolving handler function names
16
- * `resolver.resolveName('show pet by id') // -> 'showPetByIdHandler'`
17
- */
18
- resolveName(this: ResolverMcp, name: string): string;
19
- /**
20
- * Resolves the output file name for an MCP module.
21
- */
22
- resolvePathName(this: ResolverMcp, name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
23
- /**
24
- * Resolves the handler function name for an operation.
25
- */
26
- resolveHandlerName(this: ResolverMcp, node: ast.OperationNode): string;
27
- };
28
- /**
29
- * Where the generated MCP tool handlers are written and how they are exported, plus the optional
30
- * `group` strategy. The `group` option organizes `output.mode: 'directory'` output into per-tag or per-path subdirectories.
31
- *
32
- * @default { path: 'mcp', barrel: { type: 'named' } }
33
- */
34
- type Options = OutputOptions & {
35
- /**
36
- * HTTP client used by each MCP handler to call the underlying API. Mirrors a
37
- * subset of `pluginClient` options.
38
- */
39
- client?: ClientImportPath & Pick<PluginClient['options'], 'clientType' | 'dataReturnType' | 'baseURL' | 'bundle' | 'paramsCasing'>;
40
- /**
41
- * Rename parameter properties in the generated handlers. The HTTP layer still
42
- * uses the original spec names; Kubb writes the mapping for you.
43
- *
44
- * @note Must match the value of `paramsCasing` on `@kubb/plugin-ts`.
45
- */
46
- paramsCasing?: 'camelcase';
47
- /**
48
- * Skip operations matching at least one entry in the list.
49
- */
50
- exclude?: Array<Exclude>;
51
- /**
52
- * Restrict generation to operations matching at least one entry in the list.
53
- */
54
- include?: Array<Include>;
55
- /**
56
- * Apply a different options object to operations matching a pattern.
57
- */
58
- override?: Array<Override<ResolvedOptions>>;
59
- /**
60
- * Override how handler names and file paths are built. Methods you omit fall
61
- * back to the default `resolverMcp`.
62
- */
63
- resolver?: Partial<ResolverMcp> & ThisType<ResolverMcp>;
64
- /**
65
- * Macros applied to each operation node before printing.
66
- */
67
- macros?: Array<ast.Macro>;
68
- /**
69
- * Custom generators that run alongside the built-in MCP generators.
70
- */
71
- generators?: Array<Generator<PluginMcp>>;
72
- };
73
- type ResolvedOptions = {
74
- output: Output;
75
- exclude: Array<Exclude>;
76
- include: Array<Include> | undefined;
77
- override: Array<Override<ResolvedOptions>>;
78
- group: Group | null;
79
- client: Pick<PluginClient['options'], 'client' | 'clientType' | 'dataReturnType' | 'importPath' | 'baseURL' | 'bundle' | 'paramsCasing'>;
80
- paramsCasing: Options['paramsCasing'];
81
- resolver: ResolverMcp;
82
- };
83
- type PluginMcp = PluginFactoryOptions<'plugin-mcp', Options, ResolvedOptions, ResolverMcp>;
84
- declare global {
85
- namespace Kubb {
86
- interface PluginRegistry {
87
- 'plugin-mcp': PluginMcp;
88
- }
89
- }
90
- }
91
- //#endregion
92
6
  //#region src/components/McpHandler.d.ts
93
7
  type Props$1 = {
94
8
  /**
95
9
  * Name of the handler function.
96
10
  */
97
11
  name: string;
12
+ /**
13
+ * Name of the contract client `<op>` the handler calls.
14
+ */
15
+ clientName: string;
98
16
  /**
99
17
  * AST operation node.
100
18
  */
@@ -103,29 +21,12 @@ type Props$1 = {
103
21
  * TypeScript resolver for resolving param/data/response type names.
104
22
  */
105
23
  resolver: ResolverTs;
106
- /**
107
- * Base URL prepended to every generated request URL.
108
- */
109
- baseURL: string | null | undefined;
110
- /**
111
- * Return type when calling fetch.
112
- * - 'data' returns response data only.
113
- * - 'full' returns the full response object.
114
- * @default 'data'
115
- */
116
- dataReturnType: PluginMcp['resolvedOptions']['client']['dataReturnType'];
117
- /**
118
- * How to style your params.
119
- */
120
- paramsCasing?: PluginMcp['resolvedOptions']['paramsCasing'];
121
24
  };
122
25
  declare function McpHandler({
123
26
  name,
27
+ clientName,
124
28
  node,
125
- resolver,
126
- baseURL,
127
- dataReturnType,
128
- paramsCasing
29
+ resolver
129
30
  }: Props$1): KubbReactNode;
130
31
  //#endregion
131
32
  //#region src/utils.d.ts
@@ -148,10 +49,6 @@ type Props = {
148
49
  * Semantic version string passed to `new McpServer({ version })`.
149
50
  */
150
51
  serverVersion: string;
151
- /**
152
- * How to style your params.
153
- */
154
- paramsCasing?: PluginMcp['resolvedOptions']['paramsCasing'];
155
52
  /**
156
53
  * Operations to register as MCP tools, each carrying its handler,
157
54
  * zod schema, and AST node metadata.
@@ -186,16 +83,127 @@ declare function Server({
186
83
  name,
187
84
  serverName,
188
85
  serverVersion,
189
- paramsCasing,
190
86
  operations
191
87
  }: Props): KubbReactNode;
192
88
  //#endregion
89
+ //#region ../../internals/client/src/resolveClient.d.ts
90
+ /**
91
+ * Resolves which client plugin a consumer (react-query, vue-query, swr, mcp) should call for an
92
+ * operation, shared so the selection rules and diagnostics stay in one place.
93
+ *
94
+ * Every client runtime lives in a dedicated client plugin, so a consumer always calls a registered
95
+ * contract client plugin (plugin-fetch or plugin-axios) and never emits its own inline client:
96
+ *
97
+ * - `contract` — a registered contract client plugin owns the `<op>` functions and the consumer
98
+ * imports and calls them.
99
+ * - `error` — no client plugin is registered, several are registered without a selector, or the
100
+ * requested one is missing.
101
+ *
102
+ * The `client` string selects explicitly (`'fetch'` / `'axios'`); when it is unset a lone registered
103
+ * contract client plugin is picked up automatically.
104
+ */
105
+ /**
106
+ * The client selector accepted by a consumer's `client` option. Both call a registered contract
107
+ * client plugin.
108
+ */
109
+ type ClientSelector = 'fetch' | 'axios';
110
+ //#endregion
111
+ //#region src/types.d.ts
112
+ /**
113
+ * Resolver for MCP that provides naming methods for handler functions.
114
+ */
115
+ type ResolverMcp = Resolver & {
116
+ /**
117
+ * Resolves the base handler function name for an operation.
118
+ *
119
+ * @example Resolving handler function names
120
+ * `resolver.resolveName('show pet by id') // -> 'showPetByIdHandler'`
121
+ */
122
+ resolveName(this: ResolverMcp, name: string): string;
123
+ /**
124
+ * Resolves the output file name for an MCP module.
125
+ */
126
+ resolvePathName(this: ResolverMcp, name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
127
+ /**
128
+ * Resolves the handler function name for an operation.
129
+ */
130
+ resolveHandlerName(this: ResolverMcp, node: ast.OperationNode): string;
131
+ };
132
+ /**
133
+ * Where the generated MCP tool handlers are written and how they are exported, plus the optional
134
+ * `group` strategy. The `group` option organizes `output.mode: 'directory'` output into per-tag or per-path subdirectories.
135
+ *
136
+ * @default { path: 'mcp', barrel: { type: 'named' } }
137
+ */
138
+ type Options = OutputOptions & {
139
+ /**
140
+ * Selects the HTTP client each MCP handler calls. Every client plugin speaks the `RequestResult`
141
+ * contract, so each handler calls a contract `<op>` that takes one grouped `{ path, query, headers,
142
+ * body }` object.
143
+ *
144
+ * `'fetch'` / `'axios'` calls the `@kubb/plugin-fetch` / `@kubb/plugin-axios` functions. When a
145
+ * single client plugin (plugin-fetch or plugin-axios) is registered it is auto-detected, so the
146
+ * string is only needed to disambiguate several client plugins. Register one of those plugins.
147
+ * Options such as `baseURL` live there.
148
+ */
149
+ client?: ClientSelector;
150
+ /**
151
+ * Skip operations matching at least one entry in the list.
152
+ */
153
+ exclude?: Array<Exclude>;
154
+ /**
155
+ * Restrict generation to operations matching at least one entry in the list.
156
+ */
157
+ include?: Array<Include>;
158
+ /**
159
+ * Apply a different options object to operations matching a pattern.
160
+ */
161
+ override?: Array<Override<ResolvedOptions>>;
162
+ /**
163
+ * Override how handler names and file paths are built. Methods you omit fall
164
+ * back to the default `resolverMcp`.
165
+ */
166
+ resolver?: Partial<ResolverMcp> & ThisType<ResolverMcp>;
167
+ /**
168
+ * Macros applied to each operation node before printing.
169
+ */
170
+ macros?: Array<ast.Macro>;
171
+ };
172
+ /**
173
+ * The resolved client strategy for the generated handlers, computed once during setup. The handlers
174
+ * always import and call a registered contract client plugin's `<op>`.
175
+ */
176
+ type ResolvedClient = {
177
+ kind: 'contract';
178
+ pluginName: string;
179
+ };
180
+ type ResolvedOptions = {
181
+ output: Output;
182
+ exclude: Array<Exclude>;
183
+ include: Array<Include> | undefined;
184
+ override: Array<Override<ResolvedOptions>>;
185
+ group: Group | null;
186
+ /**
187
+ * The resolved client strategy the generators branch on.
188
+ */
189
+ client: ResolvedClient;
190
+ resolver: ResolverMcp;
191
+ };
192
+ type PluginMcp = PluginFactoryOptions<'plugin-mcp', Options, ResolvedOptions, ResolverMcp>;
193
+ declare global {
194
+ namespace Kubb {
195
+ interface PluginRegistry {
196
+ 'plugin-mcp': PluginMcp;
197
+ }
198
+ }
199
+ }
200
+ //#endregion
193
201
  //#region src/generators/mcpGenerator.d.ts
194
202
  /**
195
203
  * Built-in operation generator for `@kubb/plugin-mcp`. Emits one MCP tool
196
- * handler per OpenAPI operation, wiring the input Zod schema, the HTTP call,
197
- * and the response shape into a single function that an MCP server can
198
- * register as a callable tool.
204
+ * handler per OpenAPI operation. The handler takes the grouped `{ path, query,
205
+ * headers, body }` config and forwards it to the registered client plugin's
206
+ * (`@kubb/plugin-axios` / `@kubb/plugin-fetch`) `<op>` function.
199
207
  */
200
208
  declare const mcpGenerator: import("@kubb/core").Generator<PluginMcp, unknown>;
201
209
  //#endregion
@@ -218,13 +226,13 @@ declare const pluginMcpName = "plugin-mcp";
218
226
  /**
219
227
  * Generates a Model Context Protocol (MCP) server from an OpenAPI spec. Every
220
228
  * operation becomes a typed MCP tool that AI assistants (Claude Desktop, Claude
221
- * Code, MCP-compatible clients) can call directly.
229
+ * Code, MCP-compatible clients) can call directly. Each handler calls a contract
230
+ * client `<op>` from a registered `@kubb/plugin-axios` or `@kubb/plugin-fetch`.
222
231
  *
223
232
  * @example
224
233
  * ```ts
225
234
  * import { defineConfig } from 'kubb'
226
235
  * import { pluginTs } from '@kubb/plugin-ts'
227
- * import { pluginClient } from '@kubb/plugin-client'
228
236
  * import { pluginZod } from '@kubb/plugin-zod'
229
237
  * import { pluginMcp } from '@kubb/plugin-mcp'
230
238
  *
@@ -233,11 +241,10 @@ declare const pluginMcpName = "plugin-mcp";
233
241
  * output: { path: './src/gen' },
234
242
  * plugins: [
235
243
  * pluginTs(),
236
- * pluginClient(),
237
244
  * pluginZod(),
238
245
  * pluginMcp({
239
246
  * output: { path: './mcp' },
240
- * client: { baseURL: 'https://petstore.swagger.io/v2' },
247
+ * baseURL: 'https://petstore.swagger.io/v2',
241
248
  * }),
242
249
  * ],
243
250
  * })