plugins: [pluginMcp()]MCP
@kubb/plugin-mcp
Generates a Model Context Protocol server from your OpenAPI spec, so AI assistants can call each operation as a typed tool.
- Downloads40.1K/ monthnpm, last 30 days
- GitHub stars8kubb-labs/plugins
- Unpacked size262.8kBv5.1.2 on npm
- Latest release10h agov5.1.2 · Oct 13, 2026
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.
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.
Installation
bun add -d @kubb/plugin-mcppnpm add -D @kubb/plugin-mcpnpm install --save-dev @kubb/plugin-mcpyarn add -D @kubb/plugin-mcpOr run kubb add plugin-mcp to install the version the Kubb registry pins and add pluginMcp() to kubb.config.ts.
Setup
- Add
@kubb/plugin-ts,@kubb/plugin-zod, and a client plugin:@kubb/plugin-fetchor@kubb/plugin-axios. Leavesdkunset on the client plugin. - Install
@modelcontextprotocol/serverv2 andzod4.2 or a later v4 release in the app that runs the server. Addaxiostoo when you use@kubb/plugin-axios. - Install a TypeScript runner such as
tsx. The generated.mcp.jsonrunsnpx tsx, which downloadstsxfrom npm when it is missing. - Copy the server entry from the generated
.mcp.jsoninto the.mcp.jsonyour MCP client reads, such as the one at the project root for Claude Code.
Options worth knowing
clientpicksfetchoraxioswhen both client plugins are registered. A single client is detected automatically.output.pathmust be a folder name, such as the defaultmcp, because single-file output has no place forserver.ts,start.ts, and.mcp.json.
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().
See Options for every option and its default.
Example
The config below generates an MCP server whose tools call the Petstore API through @kubb/plugin-fetch.
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' } }),
],
})Dependencies
Extensions that must be in the same config as MCP.