Beta You're reading the docs for Kubb v5, which is currently in beta. View the stable v4 docs
Skip to content
Official v5.0.0-beta.85 MIT kubb >=5.0.0 node >=22

@kubb/plugin-mcp

Generates a Model Context Protocol server from your OpenAPI spec, so AI assistants can call each operation as a typed tool.

mcpmodel-context-protocolaiclaudellmcodegenopenapi
Downloads
35.2k / mo
Stars
3
Bundle size
256.2 kB
Updated
2d ago

@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 plus a server.ts and .mcp.json, and validates each call with the schemas from @kubb/plugin-zod.

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

shell
bun add -d @kubb/plugin-mcp@beta
shell
pnpm add -D @kubb/plugin-mcp@beta
shell
npm install --save-dev @kubb/plugin-mcp@beta
shell
yarn add -D @kubb/plugin-mcp@beta

Dependencies

This plugin needs three other plugins. @kubb/plugin-ts and @kubb/plugin-zod are declared dependencies, so Kubb runs them before plugin-mcp and the handlers can import the generated types and Zod schemas. The client plugin is resolved separately at setup.

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

typescript
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' } },
      : {
        : 'tag',
        : ({  }) => `${}Handlers`,
      },
    }),
  ],
})

See also