@kubb/plugin-mcp 5.1.0 → 5.1.2
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/README.md +2 -2
- package/dist/index.cjs +116 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +118 -63
- package/dist/index.js.map +1 -1
- package/docs/guides/server.md +95 -0
- package/docs/options.md +79 -0
- package/docs/overview.md +44 -0
- package/kubb-extension.json +10 -3
- package/package.json +7 -7
- package/OVERVIEW.md +0 -15
package/docs/overview.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# MCP
|
|
2
|
+
|
|
3
|
+
The MCP plugin turns each operation into a typed MCP tool that AI assistants can call. Each tool uses Zod schemas from `@kubb/plugin-zod` for its input and output.
|
|
4
|
+
|
|
5
|
+
Each tool handler calls the function a client plugin generates for that operation. The plugin writes `server.ts`, `start.ts`, and `.mcp.json` at the root of its `output.path`. `start.ts` calls the `startServer()` that `server.ts` exports, and `.mcp.json` runs `start.ts` to start a stdio server.
|
|
6
|
+
|
|
7
|
+
## Setup
|
|
8
|
+
|
|
9
|
+
- Add `@kubb/plugin-ts`, `@kubb/plugin-zod`, and a client plugin: `@kubb/plugin-fetch` or `@kubb/plugin-axios`. Leave `sdk` unset on the client plugin.
|
|
10
|
+
- Install `@modelcontextprotocol/server` v2 and `zod` 4.2 or a later v4 release in the app that runs the server. Add `axios` too when you use `@kubb/plugin-axios`.
|
|
11
|
+
- Install a TypeScript runner such as `tsx`. The generated `.mcp.json` runs `npx tsx`, which downloads `tsx` from npm when it is missing.
|
|
12
|
+
- Copy the server entry from the generated `.mcp.json` into the `.mcp.json` your MCP client reads, such as the one at the project root for Claude Code.
|
|
13
|
+
|
|
14
|
+
## Options worth knowing
|
|
15
|
+
|
|
16
|
+
- `client` picks `fetch` or `axios` when both client plugins are registered. A single client is detected automatically.
|
|
17
|
+
- `output.path` must be a folder name, such as the default `mcp`, because single-file output has no place for `server.ts`, `start.ts`, and `.mcp.json`.
|
|
18
|
+
|
|
19
|
+
The `args` path in `.mcp.json` points at `start.ts` relative to the Kubb `root`, because MCP clients start the command from their own working directory. Use an absolute path for a client that starts in another folder, or point it at your own entry file to run setup code before `startServer()`.
|
|
20
|
+
|
|
21
|
+
See [Options](https://kubb.dev/extensions/kubb-labs/plugin-mcp/options) for every option and its default.
|
|
22
|
+
|
|
23
|
+
## Example
|
|
24
|
+
|
|
25
|
+
The config below generates an MCP server whose tools call the Petstore API through `@kubb/plugin-fetch`.
|
|
26
|
+
|
|
27
|
+
```typescript [kubb.config.ts]
|
|
28
|
+
import { defineConfig } from 'kubb/config'
|
|
29
|
+
import { pluginTs } from '@kubb/plugin-ts'
|
|
30
|
+
import { pluginZod } from '@kubb/plugin-zod'
|
|
31
|
+
import { pluginFetch } from '@kubb/plugin-fetch'
|
|
32
|
+
import { pluginMcp } from '@kubb/plugin-mcp'
|
|
33
|
+
|
|
34
|
+
export default defineConfig({
|
|
35
|
+
input: './petStore.yaml',
|
|
36
|
+
output: { path: './src/gen' },
|
|
37
|
+
plugins: [
|
|
38
|
+
pluginTs(),
|
|
39
|
+
pluginZod(),
|
|
40
|
+
pluginFetch({ baseURL: 'https://petstore.swagger.io/v2' }),
|
|
41
|
+
pluginMcp({ output: { path: 'mcp', mode: 'directory' } }),
|
|
42
|
+
],
|
|
43
|
+
})
|
|
44
|
+
```
|
package/kubb-extension.json
CHANGED
|
@@ -11,9 +11,16 @@
|
|
|
11
11
|
"dark": "https://kubb.dev/feature/mcp-dark.svg"
|
|
12
12
|
},
|
|
13
13
|
"tags": ["mcp", "model-context-protocol", "ai", "claude", "llm", "codegen", "openapi"],
|
|
14
|
-
"docs": "https://kubb.dev/
|
|
14
|
+
"docs": "https://kubb.dev/extensions/kubb-labs/plugin-mcp",
|
|
15
|
+
"maintainers": [
|
|
16
|
+
{
|
|
17
|
+
"name": "Stijn Van Hulle",
|
|
18
|
+
"github": "stijnvanhulle"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"dependencies": ["plugin-ts", "plugin-zod"],
|
|
15
22
|
"compatibility": {
|
|
16
|
-
"kubb": ">=5.8.
|
|
23
|
+
"kubb": ">=5.8.3",
|
|
17
24
|
"node": ">=22"
|
|
18
25
|
},
|
|
19
26
|
"role": "consumer",
|
|
@@ -90,7 +97,7 @@
|
|
|
90
97
|
"key": "client",
|
|
91
98
|
"path": ["client"],
|
|
92
99
|
"label": "Client",
|
|
93
|
-
"description": "HTTP client the generated
|
|
100
|
+
"description": "HTTP client the generated handlers call. Only needed to disambiguate when both plugin-fetch and plugin-axios are enabled",
|
|
94
101
|
"type": "select",
|
|
95
102
|
"default": null,
|
|
96
103
|
"choices": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-mcp",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.2",
|
|
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",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"model-context-protocol",
|
|
15
15
|
"typescript"
|
|
16
16
|
],
|
|
17
|
-
"homepage": "https://kubb.dev/
|
|
17
|
+
"homepage": "https://kubb.dev/extensions/kubb-labs/plugin-mcp",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"author": "stijnvanhulle",
|
|
20
20
|
"repository": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"files": [
|
|
40
40
|
"dist",
|
|
41
41
|
"kubb-extension.json",
|
|
42
|
-
"
|
|
42
|
+
"docs",
|
|
43
43
|
"!/**/**.test.**",
|
|
44
44
|
"!/**/__tests__/**",
|
|
45
45
|
"!/**/__snapshots__/**"
|
|
@@ -63,20 +63,20 @@
|
|
|
63
63
|
"registry": "https://registry.npmjs.org/"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@kubb/plugin-ts": "^5.0.
|
|
67
|
-
"@kubb/plugin-zod": "^5.4.
|
|
66
|
+
"@kubb/plugin-ts": "^5.0.10",
|
|
67
|
+
"@kubb/plugin-zod": "^5.4.8"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@internals/client": "0.0.0",
|
|
71
71
|
"@internals/shared": "0.0.0",
|
|
72
72
|
"@internals/utils": "0.0.0",
|
|
73
73
|
"@modelcontextprotocol/server": "^2.3.1",
|
|
74
|
-
"kubb": "^5.8.
|
|
74
|
+
"kubb": "^5.8.3",
|
|
75
75
|
"zod": "^4.6.5"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@modelcontextprotocol/server": "^2.0.0",
|
|
79
|
-
"kubb": "^5.8.
|
|
79
|
+
"kubb": "^5.8.3",
|
|
80
80
|
"zod": "^4.2.0"
|
|
81
81
|
},
|
|
82
82
|
"peerDependenciesMeta": {
|
package/OVERVIEW.md
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# MCP
|
|
2
|
-
|
|
3
|
-
Generates a Model Context Protocol (MCP) server from your OpenAPI spec. Each operation becomes a typed tool that AI assistants can call.
|
|
4
|
-
|
|
5
|
-
The tool handlers call a function generated by a client plugin, and Zod schemas from `@kubb/plugin-zod` validate the tool input. The plugin writes `server.ts` and `.mcp.json` next to the handlers.
|
|
6
|
-
|
|
7
|
-
## Setup
|
|
8
|
-
|
|
9
|
-
- Add `@kubb/plugin-ts`, `@kubb/plugin-zod`, and a client plugin: `@kubb/plugin-fetch` or `@kubb/plugin-axios`.
|
|
10
|
-
- Install `@modelcontextprotocol/server` v2 or higher and `zod` 4.2 or higher in the app that runs the server.
|
|
11
|
-
|
|
12
|
-
## Options worth knowing
|
|
13
|
-
|
|
14
|
-
- `client` picks `fetch` or `axios` when both client plugins are registered. A single client is detected automatically.
|
|
15
|
-
- Keep `output.path` a folder name, such as the default `mcp`. Single-file output has no place for `server.ts` and `.mcp.json`.
|