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.79 MIT kubb >=5.0.0 node >=22

@kubb/plugin-mcp

Generate a Model Context Protocol (MCP) server from OpenAPI so AI assistants like Claude can call your API as tools.

mcpmodel-context-protocolaiclaudellmcodegenopenapi
Downloads
38.8k / mo
Stars
3
Bundle size
254.8 kB
Updated
today

@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

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 runs them before plugin-mcp so the handlers can import the generated types, Zod schemas, and the client functions they 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

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

See Also