@kubb/plugin-mcp 5.0.0-beta.56 → 5.0.0-beta.73

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.
@@ -1,159 +0,0 @@
1
- import { getOperationParameters } from '@internals/shared'
2
- import { ast } from '@kubb/core'
3
- import { functionPrinter } from '@kubb/plugin-ts'
4
- import { Const, File, Function } from '@kubb/renderer-jsx'
5
- import type { KubbReactNode } from '@kubb/renderer-jsx/types'
6
- import type { PluginMcp } from '../types.ts'
7
- import type { ZodParam } from '../utils.ts'
8
- import { zodExprFromSchemaNode, zodGroupExpr } from '../utils.ts'
9
-
10
- type Props = {
11
- /**
12
- * Variable name for the MCP server instance (e.g. 'server').
13
- */
14
- name: string
15
- /**
16
- * Human-readable server name passed to `new McpServer({ name })`.
17
- */
18
- serverName: string
19
- /**
20
- * Semantic version string passed to `new McpServer({ version })`.
21
- */
22
- serverVersion: string
23
- /**
24
- * How to style your params.
25
- */
26
- paramsCasing?: PluginMcp['resolvedOptions']['paramsCasing']
27
- /**
28
- * Operations to register as MCP tools, each carrying its handler,
29
- * zod schema, and AST node metadata.
30
- */
31
- operations: Array<{
32
- tool: {
33
- name: string
34
- title?: string
35
- description: string
36
- }
37
- mcp: {
38
- name: string
39
- file: ast.FileNode
40
- }
41
- zod: {
42
- pathParams: Array<ZodParam>
43
- /**
44
- * Query params — individual schemas to compose into `z.object({ ... })`.
45
- */
46
- queryParams?: string | Array<ZodParam> | null
47
- /**
48
- * Header params — individual schemas to compose into `z.object({ ... })`.
49
- */
50
- headerParams?: string | Array<ZodParam> | null
51
- requestName?: string | null
52
- responseName?: string | null
53
- }
54
- node: ast.OperationNode
55
- }>
56
- }
57
-
58
- const keysPrinter = functionPrinter({ mode: 'keys' })
59
-
60
- export function Server({ name, serverName, serverVersion, paramsCasing, operations }: Props): KubbReactNode {
61
- const registrations = operations
62
- .map(({ tool, mcp, zod, node }) => {
63
- const { path: pathParams } = getOperationParameters(node, { paramsCasing })
64
-
65
- const pathEntries: Array<{ key: string; value: string }> = []
66
- const otherEntries: Array<{ key: string; value: string }> = []
67
-
68
- for (const p of pathParams) {
69
- const zodParam = zod.pathParams.find((zp) => zp.name === p.name)
70
- pathEntries.push({ key: p.name, value: zodParam ? zodParam.schemaName : zodExprFromSchemaNode(p.schema) })
71
- }
72
-
73
- if (zod.requestName) {
74
- otherEntries.push({ key: 'data', value: zod.requestName })
75
- }
76
-
77
- if (zod.queryParams) {
78
- otherEntries.push({ key: 'params', value: zodGroupExpr(zod.queryParams) })
79
- }
80
-
81
- if (zod.headerParams) {
82
- otherEntries.push({ key: 'headers', value: zodGroupExpr(zod.headerParams) })
83
- }
84
-
85
- otherEntries.sort((a, b) => a.key.localeCompare(b.key))
86
- const entries = [...pathEntries, ...otherEntries]
87
-
88
- const paramsNode = entries.length
89
- ? ast.createFunctionParameters({
90
- params: [
91
- ast.createParameterGroup({
92
- properties: entries.map((e) => ast.createFunctionParameter({ name: e.key, optional: false })),
93
- }),
94
- ],
95
- })
96
- : null
97
-
98
- const destructured = paramsNode ? (keysPrinter.print(paramsNode) ?? '') : ''
99
- const inputSchema = entries.length ? `{ ${entries.map((e) => `${e.key}: ${e.value}`).join(', ')} }` : null
100
- const outputSchema = zod.responseName
101
-
102
- const config = [
103
- tool.title ? `title: ${JSON.stringify(tool.title)}` : null,
104
- `description: ${JSON.stringify(tool.description)}`,
105
- outputSchema ? `outputSchema: { data: ${outputSchema} }` : null,
106
- ]
107
- .filter(Boolean)
108
- .join(',\n ')
109
-
110
- if (inputSchema) {
111
- return `
112
- server.registerTool(${JSON.stringify(tool.name)}, {
113
- ${config},
114
- inputSchema: ${inputSchema},
115
- }, async (${destructured}, request) => {
116
- return ${mcp.name}(${destructured}, request)
117
- })
118
- `
119
- }
120
-
121
- return `
122
- server.registerTool(${JSON.stringify(tool.name)}, {
123
- ${config},
124
- }, async (request) => {
125
- return ${mcp.name}(request)
126
- })
127
- `
128
- })
129
- .filter(Boolean)
130
- .join('\n')
131
-
132
- return (
133
- <File.Source name={name} isExportable isIndexable>
134
- <Function name="getServer" export>
135
- {`const server = new McpServer({
136
- name: '${serverName}',
137
- version: '${serverVersion}',
138
- })
139
- ${registrations}
140
- return server`}
141
- </Function>
142
-
143
- <Const name={'server'} export>
144
- {'getServer()'}
145
- </Const>
146
-
147
- <Function name="startServer" async export>
148
- {`try {
149
- const transport = new StdioServerTransport()
150
- await server.connect(transport)
151
-
152
- } catch (error) {
153
- console.error('Failed to start server:', error)
154
- process.exit(1)
155
- }`}
156
- </Function>
157
- </File.Source>
158
- )
159
- }
@@ -1,89 +0,0 @@
1
- import path from 'node:path'
2
- import { resolveOperationTypeNames } from '@internals/shared'
3
- import { ast, defineGenerator } from '@kubb/core'
4
- import { pluginTsName } from '@kubb/plugin-ts'
5
- import { File, jsxRenderer } from '@kubb/renderer-jsx'
6
- import { McpHandler } from '../components/McpHandler.tsx'
7
- import type { PluginMcp } from '../types.ts'
8
-
9
- /**
10
- * Built-in operation generator for `@kubb/plugin-mcp`. Emits one MCP tool
11
- * handler per OpenAPI operation, wiring the input Zod schema, the HTTP call,
12
- * and the response shape into a single function that an MCP server can
13
- * register as a callable tool.
14
- */
15
- export const mcpGenerator = defineGenerator<PluginMcp>({
16
- name: 'mcp',
17
- renderer: jsxRenderer,
18
- operation(node, ctx) {
19
- if (!ast.isHttpOperationNode(node)) return null
20
- const { resolver, driver, root } = ctx
21
- const { output, client, paramsCasing, group } = ctx.options
22
-
23
- const pluginTs = driver.getPlugin(pluginTsName)
24
-
25
- if (!pluginTs) {
26
- return null
27
- }
28
-
29
- const tsResolver = driver.getResolver(pluginTsName)
30
-
31
- const importedTypeNames = resolveOperationTypeNames(node, tsResolver, { paramsCasing, responseStatusNames: 'error' })
32
-
33
- const meta = {
34
- name: resolver.resolveHandlerName(node),
35
- file: resolver.resolveFile(
36
- { name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },
37
- { root, output, group: group ?? undefined },
38
- ),
39
- fileTs: tsResolver.resolveFile(
40
- { name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },
41
- {
42
- root,
43
- output: pluginTs.options?.output ?? output,
44
- group: pluginTs.options?.group ?? undefined,
45
- },
46
- ),
47
- } as const
48
-
49
- return (
50
- <File baseName={meta.file.baseName} path={meta.file.path} meta={meta.file.meta}>
51
- {meta.fileTs && importedTypeNames.length > 0 && (
52
- <File.Import name={Array.from(new Set(importedTypeNames)).sort()} root={meta.file.path} path={meta.fileTs.path} isTypeOnly />
53
- )}
54
- <File.Import name={['CallToolResult', 'ServerNotification', 'ServerRequest']} path={'@modelcontextprotocol/sdk/types'} isTypeOnly />
55
- <File.Import name={['RequestHandlerExtra']} path={'@modelcontextprotocol/sdk/shared/protocol'} isTypeOnly />
56
- <File.Import name={['buildFormData']} root={meta.file.path} path={path.resolve(root, '.kubb/config.ts')} />
57
- {client.importPath ? (
58
- <>
59
- <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={client.importPath} isTypeOnly />
60
- <File.Import name={'client'} path={client.importPath} />
61
- {client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={client.importPath} isTypeOnly />}
62
- </>
63
- ) : (
64
- <>
65
- <File.Import
66
- name={['Client', 'RequestConfig', 'ResponseErrorConfig']}
67
- root={meta.file.path}
68
- path={path.resolve(root, '.kubb/client.ts')}
69
- isTypeOnly
70
- />
71
- <File.Import name={['client']} root={meta.file.path} path={path.resolve(root, '.kubb/client.ts')} />
72
- {client.dataReturnType === 'full' && (
73
- <File.Import name={['ResponseConfig']} root={meta.file.path} path={path.resolve(root, '.kubb/client.ts')} isTypeOnly />
74
- )}
75
- </>
76
- )}
77
-
78
- <McpHandler
79
- name={meta.name}
80
- node={node}
81
- resolver={tsResolver}
82
- baseURL={client.baseURL}
83
- dataReturnType={client.dataReturnType || 'data'}
84
- paramsCasing={paramsCasing}
85
- />
86
- </File>
87
- )
88
- },
89
- })
@@ -1,149 +0,0 @@
1
- import path from 'node:path'
2
- import { findSuccessStatusCode, getOperationParameters } from '@internals/shared'
3
- import { ast, defineGenerator } from '@kubb/core'
4
- import { pluginZodName } from '@kubb/plugin-zod'
5
- import { File, jsxRenderer } from '@kubb/renderer-jsx'
6
- import { Server } from '../components/Server.tsx'
7
- import type { PluginMcp } from '../types.ts'
8
-
9
- /**
10
- * Default v5 server generator for `@kubb/plugin-mcp`.
11
- *
12
- * Uses individual zod schemas for each param (e.g. `createPetsPathUuidSchema`, `createPetsQueryOffsetSchema`)
13
- * and `resolveResponseStatusName` for per-status response schemas.
14
- * Query and header params are composed into `z.object({ ... })` from individual schemas.
15
- */
16
- export const serverGenerator = defineGenerator<PluginMcp>({
17
- name: 'operations',
18
- renderer: jsxRenderer,
19
- operations(nodes, ctx) {
20
- const { config, resolver, plugin, driver, root } = ctx
21
- const { output, paramsCasing, group } = ctx.options
22
-
23
- const pluginZod = driver.getPlugin(pluginZodName)
24
-
25
- if (!pluginZod) {
26
- return
27
- }
28
-
29
- const zodResolver = driver.getResolver(pluginZodName)
30
-
31
- const name = 'server'
32
- const serverFilePath = path.resolve(root, output.path, 'server.ts')
33
- const serverFile = {
34
- baseName: 'server.ts' as const,
35
- path: serverFilePath,
36
- meta: { pluginName: plugin.name },
37
- }
38
-
39
- const jsonFilePath = path.resolve(root, output.path, '.mcp.json')
40
- const jsonFile = {
41
- baseName: '.mcp.json' as const,
42
- path: jsonFilePath,
43
- meta: { pluginName: plugin.name },
44
- }
45
-
46
- const operationsMapped = nodes.filter(ast.isHttpOperationNode).map((node) => {
47
- const { path: pathParams, query: queryParams, header: headerParams } = getOperationParameters(node, { paramsCasing })
48
-
49
- const mcpFile = resolver.resolveFile(
50
- { name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },
51
- { root, output, group: group ?? undefined },
52
- )
53
-
54
- const zodFile = zodResolver.resolveFile(
55
- { name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },
56
- {
57
- root,
58
- output: pluginZod.options?.output ?? output,
59
- group: pluginZod.options?.group ?? undefined,
60
- },
61
- )
62
-
63
- const requestName = node.requestBody?.content?.[0]?.schema ? zodResolver.resolveDataName(node) : null
64
- const successStatus = findSuccessStatusCode(node.responses)
65
- const responseName = successStatus ? zodResolver.resolveResponseStatusName(node, successStatus) : null
66
-
67
- const resolveParams = (params: typeof pathParams) => params.map((p) => ({ name: p.name, schemaName: zodResolver.resolveParamName(node, p) }))
68
-
69
- return {
70
- tool: {
71
- name: node.operationId,
72
- title: node.summary || undefined,
73
- description: node.description || `Make a ${node.method.toUpperCase()} request to ${node.path}`,
74
- },
75
- mcp: {
76
- name: resolver.resolveHandlerName(node),
77
- file: mcpFile,
78
- },
79
- zod: {
80
- pathParams: resolveParams(pathParams),
81
- queryParams: queryParams.length ? resolveParams(queryParams) : null,
82
- headerParams: headerParams.length ? resolveParams(headerParams) : null,
83
- requestName,
84
- responseName,
85
- file: zodFile,
86
- },
87
- node: node,
88
- }
89
- })
90
-
91
- const imports = operationsMapped.flatMap(({ mcp, zod }) => {
92
- const zodNames = [
93
- ...zod.pathParams.map((p) => p.schemaName),
94
- ...(zod.queryParams ?? []).map((p) => p.schemaName),
95
- ...(zod.headerParams ?? []).map((p) => p.schemaName),
96
- zod.requestName,
97
- zod.responseName,
98
- ].filter((name): name is string => Boolean(name))
99
-
100
- const uniqueNames = [...new Set(zodNames)].sort()
101
-
102
- return [
103
- <File.Import key={mcp.name} name={[mcp.name]} root={serverFile.path} path={mcp.file.path} />,
104
- uniqueNames.length > 0 && <File.Import key={`zod-${mcp.name}`} name={uniqueNames} root={serverFile.path} path={zod.file.path} />,
105
- ].filter(Boolean)
106
- })
107
-
108
- return (
109
- <>
110
- <File
111
- baseName={serverFile.baseName}
112
- path={serverFile.path}
113
- meta={serverFile.meta}
114
- banner={resolver.resolveBanner(ctx.meta, { output, config, file: { path: serverFile.path, baseName: serverFile.baseName } })}
115
- footer={resolver.resolveFooter(ctx.meta, { output, config, file: { path: serverFile.path, baseName: serverFile.baseName } })}
116
- >
117
- <File.Import name={['McpServer']} path={'@modelcontextprotocol/sdk/server/mcp'} />
118
- <File.Import name={['z']} path={'zod'} />
119
- <File.Import name={['StdioServerTransport']} path={'@modelcontextprotocol/sdk/server/stdio'} />
120
-
121
- {imports}
122
- <Server
123
- name={name}
124
- serverName={ctx.meta.title ?? 'server'}
125
- serverVersion={ctx.meta.version ?? '0.0.0'}
126
- paramsCasing={paramsCasing}
127
- operations={operationsMapped}
128
- />
129
- </File>
130
-
131
- <File baseName={jsonFile.baseName} path={jsonFile.path} meta={jsonFile.meta}>
132
- <File.Source name={name}>
133
- {`
134
- {
135
- "mcpServers": {
136
- "${ctx.meta.title || 'server'}": {
137
- "type": "stdio",
138
- "command": "npx",
139
- "args": ["tsx", "${path.relative(path.dirname(jsonFile.path), serverFile.path)}"]
140
- }
141
- }
142
- }
143
- `}
144
- </File.Source>
145
- </File>
146
- </>
147
- )
148
- },
149
- })
package/src/index.ts DELETED
@@ -1,11 +0,0 @@
1
- export { McpHandler } from './components/McpHandler.tsx'
2
- export { Server } from './components/Server.tsx'
3
-
4
- export { mcpGenerator } from './generators/mcpGenerator.tsx'
5
- export { serverGenerator } from './generators/serverGenerator.tsx'
6
-
7
- export { default, pluginMcp, pluginMcpName } from './plugin.ts'
8
-
9
- export { resolverMcp } from './resolvers/resolverMcp.ts'
10
-
11
- export type { PluginMcp, ResolverMcp } from './types.ts'
package/src/plugin.ts DELETED
@@ -1,142 +0,0 @@
1
- import path from 'node:path'
2
- import { createGroupConfig } from '@internals/shared'
3
-
4
- import { ast, definePlugin } from '@kubb/core'
5
- import { pluginClientName } from '@kubb/plugin-client'
6
- import { source as axiosClientSource } from '@kubb/plugin-client/templates/clients/axios.source'
7
- import { source as fetchClientSource } from '@kubb/plugin-client/templates/clients/fetch.source'
8
- import { source as configSource } from '@kubb/plugin-client/templates/config.source'
9
- import { pluginTsName } from '@kubb/plugin-ts'
10
- import { pluginZodName } from '@kubb/plugin-zod'
11
- import { mcpGenerator } from './generators/mcpGenerator.tsx'
12
- import { serverGenerator } from './generators/serverGenerator.tsx'
13
- import { resolverMcp } from './resolvers/resolverMcp.ts'
14
- import type { PluginMcp } from './types.ts'
15
-
16
- /**
17
- * Canonical plugin name for `@kubb/plugin-mcp`. Used for driver lookups and
18
- * cross-plugin dependency references.
19
- */
20
- export const pluginMcpName = 'plugin-mcp' satisfies PluginMcp['name']
21
-
22
- /**
23
- * Generates a Model Context Protocol (MCP) server from an OpenAPI spec. Every
24
- * operation becomes a typed MCP tool that AI assistants (Claude Desktop, Claude
25
- * Code, MCP-compatible clients) can call directly.
26
- *
27
- * @example
28
- * ```ts
29
- * import { defineConfig } from 'kubb'
30
- * import { pluginTs } from '@kubb/plugin-ts'
31
- * import { pluginClient } from '@kubb/plugin-client'
32
- * import { pluginZod } from '@kubb/plugin-zod'
33
- * import { pluginMcp } from '@kubb/plugin-mcp'
34
- *
35
- * export default defineConfig({
36
- * input: { path: './petStore.yaml' },
37
- * output: { path: './src/gen' },
38
- * plugins: [
39
- * pluginTs(),
40
- * pluginClient(),
41
- * pluginZod(),
42
- * pluginMcp({
43
- * output: { path: './mcp' },
44
- * client: { baseURL: 'https://petstore.swagger.io/v2' },
45
- * }),
46
- * ],
47
- * })
48
- * ```
49
- */
50
- export const pluginMcp = definePlugin<PluginMcp>((options) => {
51
- const {
52
- output = { path: 'mcp', barrel: { type: 'named' } },
53
- group,
54
- exclude = [],
55
- include,
56
- override = [],
57
- paramsCasing,
58
- client,
59
- resolver: userResolver,
60
- transformer: userTransformer,
61
- generators: userGenerators = [],
62
- } = options
63
-
64
- const clientName = client?.client ?? 'axios'
65
- const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)
66
-
67
- const groupConfig = createGroupConfig(group)
68
-
69
- return {
70
- name: pluginMcpName,
71
- options,
72
- dependencies: [pluginTsName, pluginZodName],
73
- hooks: {
74
- 'kubb:plugin:setup'(ctx) {
75
- const resolver = userResolver ? { ...resolverMcp, ...userResolver } : resolverMcp
76
-
77
- ctx.setOptions({
78
- output,
79
- exclude,
80
- include,
81
- override,
82
- group: groupConfig,
83
- paramsCasing,
84
- client: {
85
- client: clientName,
86
- clientType: client?.clientType ?? 'function',
87
- importPath: clientImportPath,
88
- dataReturnType: client?.dataReturnType ?? 'data',
89
- bundle: client?.bundle,
90
- baseURL: client?.baseURL,
91
- paramsCasing: client?.paramsCasing,
92
- },
93
- resolver,
94
- })
95
- ctx.setResolver(resolver)
96
- if (userTransformer) {
97
- ctx.setTransformer(userTransformer)
98
- }
99
- ctx.addGenerator(mcpGenerator)
100
- ctx.addGenerator(serverGenerator)
101
- for (const gen of userGenerators) {
102
- ctx.addGenerator(gen)
103
- }
104
-
105
- const root = path.resolve(ctx.config.root, ctx.config.output.path)
106
- const hasClientPlugin = ctx.config.plugins?.some((p) => p.name === pluginClientName)
107
-
108
- if (client?.bundle && !hasClientPlugin && !clientImportPath) {
109
- ctx.injectFile({
110
- baseName: 'client.ts',
111
- path: path.resolve(root, '.kubb/client.ts'),
112
- sources: [
113
- ast.createSource({
114
- name: 'client',
115
- nodes: [ast.createText(clientName === 'fetch' ? fetchClientSource : axiosClientSource)],
116
- isExportable: true,
117
- isIndexable: true,
118
- }),
119
- ],
120
- })
121
- }
122
-
123
- if (!hasClientPlugin) {
124
- ctx.injectFile({
125
- baseName: 'config.ts',
126
- path: path.resolve(root, '.kubb/config.ts'),
127
- sources: [
128
- ast.createSource({
129
- name: 'config',
130
- nodes: [ast.createText(configSource)],
131
- isExportable: false,
132
- isIndexable: false,
133
- }),
134
- ],
135
- })
136
- }
137
- },
138
- },
139
- }
140
- })
141
-
142
- export default pluginMcp
@@ -1,35 +0,0 @@
1
- import { camelCase, toFilePath } from '@internals/utils'
2
- import { defineResolver } from '@kubb/core'
3
- import type { PluginMcp } from '../types.ts'
4
-
5
- /**
6
- * Default resolver used by `@kubb/plugin-mcp`. Decides the names and file
7
- * paths for every generated MCP tool handler. Function names get a `Handler`
8
- * suffix so an operation `addPet` becomes `addPetHandler`.
9
- *
10
- * @example Resolve a handler name
11
- * ```ts
12
- * import { resolverMcp } from '@kubb/plugin-mcp'
13
- *
14
- * resolverMcp.default('addPet', 'function') // 'addPetHandler'
15
- * ```
16
- */
17
- export const resolverMcp = defineResolver<PluginMcp>(() => ({
18
- name: 'default',
19
- pluginName: 'plugin-mcp',
20
- default(name, type) {
21
- if (type === 'file') {
22
- return toFilePath(name)
23
- }
24
- return camelCase(name, { suffix: 'handler' })
25
- },
26
- resolveName(name) {
27
- return this.default(name, 'function')
28
- },
29
- resolvePathName(name, type) {
30
- return this.default(name, type)
31
- },
32
- resolveHandlerName(node) {
33
- return this.resolveName(node.operationId)
34
- },
35
- }))
package/src/types.ts DELETED
@@ -1,90 +0,0 @@
1
- import type { ast, Exclude, Generator, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver } from '@kubb/core'
2
- import type { ClientImportPath, PluginClient } from '@kubb/plugin-client'
3
-
4
- /**
5
- * Resolver for MCP that provides naming methods for handler functions.
6
- */
7
- export type ResolverMcp = Resolver & {
8
- /**
9
- * Resolves the base handler function name for an operation.
10
- *
11
- * @example Resolving handler function names
12
- * `resolver.resolveName('show pet by id') // -> 'showPetByIdHandler'`
13
- */
14
- resolveName(this: ResolverMcp, name: string): string
15
- /**
16
- * Resolves the output file name for an MCP module.
17
- */
18
- resolvePathName(this: ResolverMcp, name: string, type?: 'file' | 'function' | 'type' | 'const'): string
19
- /**
20
- * Resolves the handler function name for an operation.
21
- */
22
- resolveHandlerName(this: ResolverMcp, node: ast.OperationNode): string
23
- }
24
-
25
- /**
26
- * Where the generated MCP tool handlers are written and how they are exported, plus the optional
27
- * `group` strategy. The `group` option organizes `output.mode: 'directory'` output into per-tag or per-path subdirectories.
28
- *
29
- * @default { path: 'mcp', barrel: { type: 'named' } }
30
- */
31
- export type Options = OutputOptions & {
32
- /**
33
- * HTTP client used by each MCP handler to call the underlying API. Mirrors a
34
- * subset of `pluginClient` options.
35
- */
36
- client?: ClientImportPath & Pick<PluginClient['options'], 'clientType' | 'dataReturnType' | 'baseURL' | 'bundle' | 'paramsCasing'>
37
- /**
38
- * Rename parameter properties in the generated handlers. The HTTP layer still
39
- * uses the original spec names; Kubb writes the mapping for you.
40
- *
41
- * @note Must match the value of `paramsCasing` on `@kubb/plugin-ts`.
42
- */
43
- paramsCasing?: 'camelcase'
44
- /**
45
- * Skip operations matching at least one entry in the list.
46
- */
47
- exclude?: Array<Exclude>
48
- /**
49
- * Restrict generation to operations matching at least one entry in the list.
50
- */
51
- include?: Array<Include>
52
- /**
53
- * Apply a different options object to operations matching a pattern.
54
- */
55
- override?: Array<Override<ResolvedOptions>>
56
- /**
57
- * Override how handler names and file paths are built. Methods you omit fall
58
- * back to the default `resolverMcp`.
59
- */
60
- resolver?: Partial<ResolverMcp> & ThisType<ResolverMcp>
61
- /**
62
- * AST visitor applied to each operation node before printing.
63
- */
64
- transformer?: ast.Visitor
65
- /**
66
- * Custom generators that run alongside the built-in MCP generators.
67
- */
68
- generators?: Array<Generator<PluginMcp>>
69
- }
70
-
71
- type ResolvedOptions = {
72
- output: Output
73
- exclude: Array<Exclude>
74
- include: Array<Include> | undefined
75
- override: Array<Override<ResolvedOptions>>
76
- group: Group | null
77
- client: Pick<PluginClient['options'], 'client' | 'clientType' | 'dataReturnType' | 'importPath' | 'baseURL' | 'bundle' | 'paramsCasing'>
78
- paramsCasing: Options['paramsCasing']
79
- resolver: ResolverMcp
80
- }
81
-
82
- export type PluginMcp = PluginFactoryOptions<'plugin-mcp', Options, ResolvedOptions, ResolverMcp>
83
-
84
- declare global {
85
- namespace Kubb {
86
- interface PluginRegistry {
87
- 'plugin-mcp': PluginMcp
88
- }
89
- }
90
- }