plugins: [pluginMcp()]OpenAPI to MCP server generator
@kubb/plugin-mcp
Generates a Model Context Protocol server from your OpenAPI spec, so AI assistants can call each operation as a typed tool.
- Downloads74.5K/ monthnpm, last 30 days
- GitHub stars12kubb-labs/plugins
- Unpacked size339.6kBv5.6.0 on npm
- Latest release1d agov5.6.0 · Nov 18, 2026
The MCP plugin turns each operation in your OpenAPI spec into a typed MCP tool that AI assistants can call, validated with @kubb/plugin-zod schemas.
Each tool handler calls the function a client plugin generates for that operation.
Next to the handlers, the plugin writes three files at the root of its output.path:
| File | Role |
|---|---|
server.ts | Registers one tool per operation and exports startServer(). |
start.ts | Calls startServer() to serve the tools over stdio. |
.mcp.json | A server entry that runs start.ts, ready to copy into your MCP client config. |
Installation
kubb add plugin-mcpbun add -d @kubb/plugin-mcppnpm add -D @kubb/plugin-mcpnpm install --save-dev @kubb/plugin-mcpyarn add -D @kubb/plugin-mcpkubb add installs the version the Kubb registry pins and adds pluginMcp() to kubb.config.ts. It needs a kubb.config.ts, so run kubb init first in a new project.
Setup
- Add
@kubb/plugin-zod, one client plugin (@kubb/plugin-fetch,@kubb/plugin-axios,@kubb/plugin-ky, or@kubb/plugin-client), and@kubb/plugin-ts.@kubb/plugin-tsis optional withpluginZod({ inferred: 'codec' }). Leavesdkunset on the client plugin. - Install
@modelcontextprotocol/serverv2 andzod4.2 or a later v4 release in the app that runs the server. Addaxiosorkytoo when you use@kubb/plugin-axiosor@kubb/plugin-ky. - Install a TypeScript runner such as
tsx. The generated.mcp.jsonrunsnpx tsx, which downloadstsxfrom npm when it is missing.
Options worth knowing
| Option | Default | What it does |
|---|---|---|
client | Detected | Picks 'fetch', 'axios', 'ky', or 'client' when several client plugins are registered. |
exclude | [] | Skips operations, such as one with a binary request body. An MCP client sends JSON and cannot send a file. |
output.path | 'mcp' | Must name a folder for server.ts, start.ts, and .mcp.json. |
Operations that stream their response get no tool.
See Streaming operations.
Example
This config generates an MCP server whose tools call the Petstore API through @kubb/plugin-fetch. The .mcp.json names the server after the spec's info.title:
import { defineConfig } from 'kubb/config'
import { pluginTs } from '@kubb/plugin-ts'
import { pluginZod } from '@kubb/plugin-zod'
import { pluginFetch } from '@kubb/plugin-fetch'
import { pluginMcp } from '@kubb/plugin-mcp'
export default defineConfig({
input: './petStore.yaml',
output: { path: './src/gen' },
plugins: [
pluginTs(),
pluginZod(),
pluginFetch({ baseURL: 'https://petstore.swagger.io/v2' }),
pluginMcp({ output: { path: 'mcp', mode: 'directory' } }),
],
}){
"mcpServers": {
"Swagger Petstore": {
"type": "stdio",
"command": "npx",
"args": ["tsx", "./src/gen/mcp/start.ts"]
}
}
}Next, run the server and connect Claude Code or Claude Desktop.
Dependencies
Extensions that must be in the same config as MCP.
Optional dependencies
Extensions MCP works with when they are in the config.
