@kubb/plugin-mcp
@kubb/plugin-mcp turns your OpenAPI spec into a Model Context Protocol server. Each operation becomes one MCP tool. AI assistants like Claude Desktop and Claude Code call those tools to reach your API. The plugin generates the tool handlers and the Zod schemas that validate each call.
Each handler calls a registered client plugin, so you must add @kubb/plugin-axios or @kubb/plugin-fetch alongside @kubb/plugin-ts and @kubb/plugin-zod. Without a client plugin, the build stops with a setup error.
This plugin generates an MCP server from your spec. It is not the same as the built-in kubb mcp server that exposes the Kubb CLI itself, which is documented under AI / MCP.
The Connect Claude to a remote MCP server guide explains how to register the generated server with an assistant.
Installation
bun add -d @kubb/plugin-mcp@betapnpm add -D @kubb/plugin-mcp@betanpm install --save-dev @kubb/plugin-mcp@betayarn add -D @kubb/plugin-mcp@betaDependencies
This plugin needs three other plugins. Kubb runs them before plugin-mcp so the handlers can import the generated types, Zod schemas, and the client functions they call.
@kubb/plugin-tsfor the request and response types.@kubb/plugin-zodfor the schemas that validate each tool call.@kubb/plugin-axiosor@kubb/plugin-fetchfor the HTTP client the handlers call.
A client plugin is required. The handlers call its generated functions, so the build stops with a setup error when no client plugin is registered. Register one of them and set client only when both are present.
Example
import { } from 'kubb'
import { } from '@kubb/plugin-ts'
import { } from '@kubb/plugin-axios'
import { } from '@kubb/plugin-zod'
import { } from '@kubb/plugin-mcp'
export default ({
: { : './petStore.yaml' },
: { : './src/gen' },
: [
(),
({ : 'https://petstore.swagger.io/v2' }),
(),
({
: { : 'mcp', : { : 'named' } },
: 'axios',
: {
: 'tag',
: ({ }) => `${}Handlers`,
},
}),
],
})