@kubb/plugin-mcp 5.2.1 → 5.2.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 +2 -2
- package/dist/index.d.cts +241 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +3 -3
- package/kubb-extension.json +1 -1
- package/package.json +14 -9
- package/dist/rolldown-runtime-C0LytTxp.js +0 -8
package/dist/index.cjs
CHANGED
|
@@ -873,11 +873,11 @@ const serverGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
873
873
|
//#region kubb-extension.json
|
|
874
874
|
var compatibility = {
|
|
875
875
|
"kubb": ">=5.8.3",
|
|
876
|
-
"node": ">=22"
|
|
876
|
+
"node": ">=22.12"
|
|
877
877
|
};
|
|
878
878
|
//#endregion
|
|
879
879
|
//#region package.json
|
|
880
|
-
var version = "5.2.
|
|
880
|
+
var version = "5.2.3";
|
|
881
881
|
//#endregion
|
|
882
882
|
//#region src/resolvers/resolverMcp.ts
|
|
883
883
|
/**
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
|
|
2
|
+
import { ResolverTs } from "@kubb/plugin-ts";
|
|
3
|
+
import { KubbReactNode } from "kubb/jsx";
|
|
4
|
+
import "@kubb/plugin-zod";
|
|
5
|
+
//#region src/components/McpHandler.d.ts
|
|
6
|
+
type Props$1 = {
|
|
7
|
+
/**
|
|
8
|
+
* Name of the handler function.
|
|
9
|
+
*/
|
|
10
|
+
name: string;
|
|
11
|
+
/**
|
|
12
|
+
* Name of the contract client `<op>` the handler calls.
|
|
13
|
+
*/
|
|
14
|
+
clientName: string;
|
|
15
|
+
/**
|
|
16
|
+
* AST operation node.
|
|
17
|
+
*/
|
|
18
|
+
node: ast.HttpOperationNode;
|
|
19
|
+
/**
|
|
20
|
+
* TypeScript resolver for resolving param/data/response type names.
|
|
21
|
+
*/
|
|
22
|
+
resolver: ResolverTs;
|
|
23
|
+
/**
|
|
24
|
+
* The registered client plugin's `returnType`, read by the caller off `resolveClientOperation`.
|
|
25
|
+
*/
|
|
26
|
+
returnType?: 'full' | 'data' | 'plain';
|
|
27
|
+
};
|
|
28
|
+
export declare function McpHandler({ name, clientName, node, resolver, returnType }: Props$1): KubbReactNode;
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/components/Server.d.ts
|
|
31
|
+
type ZodParam = {
|
|
32
|
+
name: string;
|
|
33
|
+
schemaName: string;
|
|
34
|
+
};
|
|
35
|
+
type Props = {
|
|
36
|
+
/**
|
|
37
|
+
* Human-readable server name passed to `new McpServer({ name })`.
|
|
38
|
+
*/
|
|
39
|
+
serverName: string;
|
|
40
|
+
/**
|
|
41
|
+
* Semantic version string passed to `new McpServer({ version })`.
|
|
42
|
+
*/
|
|
43
|
+
serverVersion: string;
|
|
44
|
+
/**
|
|
45
|
+
* Operations to register as MCP tools, each carrying its handler,
|
|
46
|
+
* zod schema, and AST node metadata.
|
|
47
|
+
*/
|
|
48
|
+
operations: Array<{
|
|
49
|
+
tool: {
|
|
50
|
+
name: string;
|
|
51
|
+
title?: string;
|
|
52
|
+
description: string;
|
|
53
|
+
};
|
|
54
|
+
mcp: {
|
|
55
|
+
name: string;
|
|
56
|
+
file: ast.FileNode;
|
|
57
|
+
};
|
|
58
|
+
zod: {
|
|
59
|
+
pathParams: Array<ZodParam>;
|
|
60
|
+
/**
|
|
61
|
+
* Query params — individual schemas to compose into `z.object({ ... })`.
|
|
62
|
+
*/
|
|
63
|
+
queryParams?: Array<ZodParam> | null;
|
|
64
|
+
/**
|
|
65
|
+
* Header params — individual schemas to compose into `z.object({ ... })`.
|
|
66
|
+
*/
|
|
67
|
+
headerParams?: Array<ZodParam> | null;
|
|
68
|
+
requestName?: string | null;
|
|
69
|
+
responseName?: string | null;
|
|
70
|
+
};
|
|
71
|
+
}>;
|
|
72
|
+
};
|
|
73
|
+
export declare function Server({ serverName, serverVersion, operations }: Props): KubbReactNode;
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region ../../internals/client/src/resolveClient.d.ts
|
|
76
|
+
/**
|
|
77
|
+
* The client selector accepted by a consumer's `client` option. Each calls a registered contract
|
|
78
|
+
* client plugin.
|
|
79
|
+
*/
|
|
80
|
+
type ClientSelector = 'fetch' | 'axios' | 'client';
|
|
81
|
+
/**
|
|
82
|
+
* The resolved client strategy stored in a consumer plugin's options: the generated code always
|
|
83
|
+
* imports and calls a registered contract client plugin's `<op>`. The client runtime lives in
|
|
84
|
+
* plugin-axios / plugin-fetch, so nothing is bundled by the consumer.
|
|
85
|
+
*/
|
|
86
|
+
type ResolvedContractClient = {
|
|
87
|
+
kind: 'contract';
|
|
88
|
+
pluginName: string;
|
|
89
|
+
};
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/types.d.ts
|
|
92
|
+
/**
|
|
93
|
+
* Resolver for MCP that provides naming methods for handler functions.
|
|
94
|
+
*/
|
|
95
|
+
type ResolverMcp = Resolver & {
|
|
96
|
+
/**
|
|
97
|
+
* Naming for the generated MCP tool handler functions.
|
|
98
|
+
*/
|
|
99
|
+
handler: {
|
|
100
|
+
/**
|
|
101
|
+
* Resolves the handler function name for an operation.
|
|
102
|
+
*
|
|
103
|
+
* @example Resolving handler function names
|
|
104
|
+
* `resolver.handler.name(operationNode) // -> 'showPetByIdHandler'`
|
|
105
|
+
*/
|
|
106
|
+
name(node: ast.OperationNode): string;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Where the generated MCP tool handlers are written and how they are exported, plus the optional
|
|
111
|
+
* `group` strategy. The `group` option organizes `output.mode: 'directory'` output into per-tag or per-path subdirectories.
|
|
112
|
+
*
|
|
113
|
+
* @default { path: 'mcp', barrel: { type: 'named' } }
|
|
114
|
+
*/
|
|
115
|
+
type Options = OutputOptions & {
|
|
116
|
+
/**
|
|
117
|
+
* Selects the HTTP client each MCP handler calls. Every client plugin speaks the `RequestResult`
|
|
118
|
+
* contract, so each handler calls a contract `<op>` that takes one grouped `{ path, query, headers,
|
|
119
|
+
* body }` object.
|
|
120
|
+
*
|
|
121
|
+
* `'fetch'` / `'axios'` / `'client'` calls the `@kubb/plugin-fetch` / `@kubb/plugin-axios` /
|
|
122
|
+
* `@kubb/plugin-client` functions. When a single client plugin is registered it is auto-detected, so the
|
|
123
|
+
* string is only needed to disambiguate several client plugins. Register one of those plugins.
|
|
124
|
+
* Options such as `baseURL` live there, or in your own module with `@kubb/plugin-client`.
|
|
125
|
+
*/
|
|
126
|
+
client?: ClientSelector;
|
|
127
|
+
/**
|
|
128
|
+
* Skip operations matching at least one entry in the list.
|
|
129
|
+
*/
|
|
130
|
+
exclude?: Array<Exclude>;
|
|
131
|
+
/**
|
|
132
|
+
* Restrict generation to operations matching at least one entry in the list.
|
|
133
|
+
*/
|
|
134
|
+
include?: Array<Include>;
|
|
135
|
+
/**
|
|
136
|
+
* Apply a different options object to operations matching a pattern.
|
|
137
|
+
*/
|
|
138
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
139
|
+
/**
|
|
140
|
+
* Override how handler names and file paths are built. Methods you omit fall
|
|
141
|
+
* back to the default `resolverMcp`.
|
|
142
|
+
*/
|
|
143
|
+
resolver?: ResolverPatch<ResolverMcp>;
|
|
144
|
+
/**
|
|
145
|
+
* Macros applied to each operation node before printing.
|
|
146
|
+
*/
|
|
147
|
+
macros?: Array<ast.Macro>;
|
|
148
|
+
};
|
|
149
|
+
type ResolvedOptions = {
|
|
150
|
+
output: Output;
|
|
151
|
+
exclude: Array<Exclude>;
|
|
152
|
+
include: Array<Include> | undefined;
|
|
153
|
+
override: Array<Override<ResolvedOptions>>;
|
|
154
|
+
group: Group | null;
|
|
155
|
+
/**
|
|
156
|
+
* The resolved client strategy the generators branch on.
|
|
157
|
+
*/
|
|
158
|
+
client: ResolvedContractClient;
|
|
159
|
+
resolver: ResolverMcp;
|
|
160
|
+
};
|
|
161
|
+
type PluginMcp = PluginType<'plugin-mcp', Options, ResolvedOptions, ResolverMcp>;
|
|
162
|
+
declare global {
|
|
163
|
+
namespace Kubb {
|
|
164
|
+
interface PluginRegistry {
|
|
165
|
+
'plugin-mcp': PluginMcp;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region src/generators/mcpGenerator.d.ts
|
|
171
|
+
/**
|
|
172
|
+
* Built-in operation generator for `@kubb/plugin-mcp`. Emits one MCP tool
|
|
173
|
+
* handler per OpenAPI operation. The handler takes the grouped `{ path, query,
|
|
174
|
+
* headers, body }` config and forwards it to the registered client plugin's
|
|
175
|
+
* (`@kubb/plugin-axios` / `@kubb/plugin-fetch`) `<op>` function.
|
|
176
|
+
*/
|
|
177
|
+
export declare const mcpGenerator: import("kubb/kit").Generator<PluginMcp, unknown>;
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/generators/serverGenerator.d.ts
|
|
180
|
+
/**
|
|
181
|
+
* Default v5 server generator for `@kubb/plugin-mcp`.
|
|
182
|
+
*
|
|
183
|
+
* Uses individual zod schemas for each param (e.g. `createPetsPathUuidSchema`, `createPetsQueryOffsetSchema`)
|
|
184
|
+
* and `resolveResponseStatusName` for per-status response schemas.
|
|
185
|
+
* Query and header params are composed into `z.object({ ... })` from individual schemas.
|
|
186
|
+
*/
|
|
187
|
+
export declare const serverGenerator: import("kubb/kit").Generator<PluginMcp, unknown>;
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region src/plugin.d.ts
|
|
190
|
+
/**
|
|
191
|
+
* Canonical plugin name for `@kubb/plugin-mcp`. Used for driver lookups and
|
|
192
|
+
* cross-plugin dependency references.
|
|
193
|
+
*/
|
|
194
|
+
export declare const pluginMcpName = "plugin-mcp";
|
|
195
|
+
/**
|
|
196
|
+
* Generates a Model Context Protocol (MCP) server from an OpenAPI spec. Every
|
|
197
|
+
* operation becomes a typed MCP tool that AI assistants (Claude Desktop, Claude
|
|
198
|
+
* Code, MCP-compatible clients) can call directly. Each handler calls a contract
|
|
199
|
+
* client `<op>` from a registered `@kubb/plugin-axios` or `@kubb/plugin-fetch`.
|
|
200
|
+
* Next to the handlers it writes `server.ts`, a `start.ts` entry that serves the
|
|
201
|
+
* tools over stdio, and a `.mcp.json` that runs `start.ts` with `tsx`.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts
|
|
205
|
+
* import { defineConfig } from 'kubb/config'
|
|
206
|
+
* import { pluginTs } from '@kubb/plugin-ts'
|
|
207
|
+
* import { pluginZod } from '@kubb/plugin-zod'
|
|
208
|
+
* import { pluginFetch } from '@kubb/plugin-fetch'
|
|
209
|
+
* import { pluginMcp } from '@kubb/plugin-mcp'
|
|
210
|
+
*
|
|
211
|
+
* export default defineConfig({
|
|
212
|
+
* input: './petStore.yaml',
|
|
213
|
+
* output: { path: './src/gen' },
|
|
214
|
+
* plugins: [
|
|
215
|
+
* pluginTs(),
|
|
216
|
+
* pluginZod(),
|
|
217
|
+
* pluginFetch({ baseURL: 'https://petstore.swagger.io/v2' }),
|
|
218
|
+
* pluginMcp({ output: { path: 'mcp' } }),
|
|
219
|
+
* ],
|
|
220
|
+
* })
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
export declare const pluginMcp: import("kubb/kit").PluginFactory<PluginMcp>;
|
|
224
|
+
//#endregion
|
|
225
|
+
//#region src/resolvers/resolverMcp.d.ts
|
|
226
|
+
/**
|
|
227
|
+
* Default resolver used by `@kubb/plugin-mcp`. Decides the names and file
|
|
228
|
+
* paths for every generated MCP tool handler. Function names get a `Handler`
|
|
229
|
+
* suffix so an operation `addPet` becomes `addPetHandler`.
|
|
230
|
+
*
|
|
231
|
+
* @example Resolve a handler name
|
|
232
|
+
* ```ts
|
|
233
|
+
* import { resolverMcp } from '@kubb/plugin-mcp'
|
|
234
|
+
*
|
|
235
|
+
* resolverMcp.name('addPet') // 'addPetHandler'
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
export declare const resolverMcp: ResolverMcp;
|
|
239
|
+
//#endregion
|
|
240
|
+
export { type PluginMcp, type ResolverMcp, pluginMcp as default };
|
|
241
|
+
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
|
|
2
|
+
import { ResolverTs } from "@kubb/plugin-ts";
|
|
3
3
|
import { KubbReactNode } from "kubb/jsx";
|
|
4
4
|
import "@kubb/plugin-zod";
|
|
5
|
-
import { ResolverTs } from "@kubb/plugin-ts";
|
|
6
5
|
//#region src/components/McpHandler.d.ts
|
|
7
6
|
type Props$1 = {
|
|
8
7
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
1
|
import { Diagnostics, Resolver, Url, addGenerator, ast, createResolver, defineExtension, defineGenerator, setMacros, setResolver, useConfig } from "kubb/kit";
|
|
3
2
|
import path, { posix } from "node:path";
|
|
4
3
|
import { Const, File, Function, jsxRenderer } from "kubb/jsx";
|
|
5
4
|
import { Fragment, jsx, jsxs } from "kubb/jsx/jsx-runtime";
|
|
6
5
|
import { pluginZodName } from "@kubb/plugin-zod";
|
|
7
6
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
7
|
+
//#endregion
|
|
8
8
|
//#region ../../internals/shared/src/operation.ts
|
|
9
9
|
/**
|
|
10
10
|
* Builds the `ResolverFileParams` every operation generator passes to
|
|
@@ -847,11 +847,11 @@ const serverGenerator = defineGenerator({
|
|
|
847
847
|
//#region kubb-extension.json
|
|
848
848
|
var compatibility = {
|
|
849
849
|
"kubb": ">=5.8.3",
|
|
850
|
-
"node": ">=22"
|
|
850
|
+
"node": ">=22.12"
|
|
851
851
|
};
|
|
852
852
|
//#endregion
|
|
853
853
|
//#region package.json
|
|
854
|
-
var version = "5.2.
|
|
854
|
+
var version = "5.2.3";
|
|
855
855
|
//#endregion
|
|
856
856
|
//#region src/resolvers/resolverMcp.ts
|
|
857
857
|
/**
|
package/kubb-extension.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-mcp",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.3",
|
|
4
4
|
"description": "Generate Model Context Protocol (MCP) tool definitions with Kubb. Expose your REST APIs as AI-callable tools for LLMs, Claude, ChatGPT, and other AI assistants.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -51,9 +51,14 @@
|
|
|
51
51
|
"types": "./dist/index.d.ts",
|
|
52
52
|
"exports": {
|
|
53
53
|
".": {
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
"import": {
|
|
55
|
+
"types": "./dist/index.d.ts",
|
|
56
|
+
"default": "./dist/index.js"
|
|
57
|
+
},
|
|
58
|
+
"require": {
|
|
59
|
+
"types": "./dist/index.d.cts",
|
|
60
|
+
"default": "./dist/index.cjs"
|
|
61
|
+
}
|
|
57
62
|
},
|
|
58
63
|
"./package.json": "./package.json",
|
|
59
64
|
"./kubb-extension.json": "./kubb-extension.json"
|
|
@@ -63,20 +68,20 @@
|
|
|
63
68
|
"registry": "https://registry.npmjs.org/"
|
|
64
69
|
},
|
|
65
70
|
"dependencies": {
|
|
66
|
-
"@kubb/plugin-ts": "^5.0.
|
|
67
|
-
"@kubb/plugin-zod": "^5.4.
|
|
71
|
+
"@kubb/plugin-ts": "^5.0.14",
|
|
72
|
+
"@kubb/plugin-zod": "^5.4.12"
|
|
68
73
|
},
|
|
69
74
|
"devDependencies": {
|
|
70
75
|
"@internals/client": "0.0.0",
|
|
71
76
|
"@internals/shared": "0.0.0",
|
|
72
77
|
"@internals/utils": "0.0.0",
|
|
73
78
|
"@modelcontextprotocol/server": "^2.3.1",
|
|
74
|
-
"kubb": "^5.10.
|
|
79
|
+
"kubb": "^5.10.3",
|
|
75
80
|
"zod": "^4.6.6"
|
|
76
81
|
},
|
|
77
82
|
"peerDependencies": {
|
|
78
83
|
"@modelcontextprotocol/server": "^2.0.0",
|
|
79
|
-
"kubb": "^5.10.
|
|
84
|
+
"kubb": "^5.10.3",
|
|
80
85
|
"zod": "^4.2.0"
|
|
81
86
|
},
|
|
82
87
|
"peerDependenciesMeta": {
|
|
@@ -88,7 +93,7 @@
|
|
|
88
93
|
}
|
|
89
94
|
},
|
|
90
95
|
"engines": {
|
|
91
|
-
"node": ">=22"
|
|
96
|
+
"node": ">=22.12"
|
|
92
97
|
},
|
|
93
98
|
"scripts": {
|
|
94
99
|
"build": "tsdown",
|