mcp
v5.29.3MCP server for Kubb. Exposes code generation as a tool over the Model Context Protocol so AI assistants like Claude, Cursor, and other MCP-compatible clients…
[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![Stars][stars-src]][stars-href] [![License][license-src]][license-href] [![Node][node-src]][node-href] Documentation · Report Bug · Request Feature @kubb/mcp is the MCP server for Kubb. It exposes Kubb code generation as tools over the Model Context Protocol, so AI assistants such as Claude and Cursor can validate a spec and generate TypeScript types and API clients from the chat.
Summary extracted from the README.
npm version npm downloads Stars License Node
@kubb/mcp
Model Context Protocol server for Kubb
@kubb/mcp is the MCP server for Kubb. It exposes Kubb code generation as tools over the Model Context Protocol, so AI assistants such as Claude and Cursor can validate a spec and generate TypeScript types and API clients from the chat.
The server has a tool for every kubb command except studio and mcp. Each tool is named after its command with a kubb_ prefix. kubb_generate runs a full Kubb build from a kubb.config.ts and returns its build events when the build succeeds. A failed build returns its diagnostics instead. kubb_diff shows what kubb_generate would change, kubb_validate checks an OpenAPI spec, and kubb_init scaffolds a kubb.config.ts. kubb_add, kubb_update, kubb_remove, and kubb_list manage extensions from the Kubb registry.
The server only has tools for what the kubb CLI can do. A new tool comes with a new command or flag. Features beyond the CLI, such as run history, lookup in generated code, multiple agents, and team permissions, are in the Kubb Studio MCP server. See kubb studio to connect it.
Installation
Install as a dev dependency:
bun add -D @kubb/mcp
# or
pnpm add -D @kubb/mcp
# or
npm install -D @kubb/mcp
[!IMPORTANT] The
kubb mcpcommand comes from@kubb/cli, which thekubbpackage includes. Installkubbto use it.
Usage
Start the MCP server
Start the server using the Kubb CLI:
npx kubb mcp
Or run it directly as a standalone package:
npx @kubb/mcp
Both commands start the same server over stdio.
Configure an MCP client
Add one of these entries to your MCP client's config, such as claude_desktop_config.json for Claude Desktop.
Using kubb mcp:
{
"mcpServers": {
"kubb": {
"command": "npx",
"args": ["kubb", "mcp"]
}
}
}
Using the standalone package:
{
"mcpServers": {
"kubb": {
"command": "npx",
"args": ["@kubb/mcp"]
}
}
}
The server looks for kubb.config.* in the directory the client starts it in, and rejects a config path outside that directory. Claude Code starts it in the folder you run claude from, so register it from the project root:
claude mcp add kubb -- npx kubb mcp
Clients such as Claude Code ignore a cwd key in this config. When a client starts the server in another directory, change into the project first (macOS and Linux):
{
"mcpServers": {
"kubb-petstore": {
"command": "sh",
"args": ["-c", "cd '/path/to/your/project' && npx kubb mcp"]
}
}
}
Available tools
Every tool sets the MCP annotations: kubb_validate, kubb_diff, and kubb_list are read-only, and kubb_generate, kubb_update, and kubb_remove are destructive. kubb_generate and every tool that runs the kubb CLI return 30,000 characters at most. Longer output is cut and ends with an [Output cut: ...] notice.
kubb_generate
Runs a Kubb build from your config. A successful build returns the summary kubb generate prints, such as ✓ Generated 14 files · 11 unchanged and 3 modified · +11 −7, then the build events. A failed build returns its diagnostics. While it runs, a client that asks for progress gets a step for each plugin and one for the write. Claude Code gets the summary in color.
Parameters:
configPath(string, optional): Path to a config file inside the working directory. Defaults tokubb.config.ts(or.mts,.cts,.js,.mjs,.cjs) in the working directoryinputPath(string, optional): Path inside the working directory, or http(s) URL on a public host, of the OpenAPI/Swagger spec (overrides config file setting)outputPath(string, optional): Output directory path (overrides config file setting)logLevel(enum, optional): One of'silent','info','verbose'(default: 'info'), passed to a config that exports a function
Examples:
Using default config file:
{
"configPath": "./kubb.config.ts"
}
Overriding input and output:
{
"configPath": "./kubb.config.ts",
"inputPath": "./specs/petstore.yaml",
"outputPath": "./src/generated"
}
With verbose logging:
{
"configPath": "./kubb.config.ts",
"logLevel": "verbose"
}
kubb_validate
Validates an OpenAPI/Swagger specification from a path or URL.
Parameters:
inputPath(string, required): Path inside the working directory, or http(s) URL on a public host, of the OpenAPI/Swagger specification
kubb_init
Writes a kubb.config.ts in the working directory without prompts. It does not install packages, and it fails when kubb.config.ts already exists.
Parameters:
inputPath(string, optional): Path inside the working directory, or http(s) URL, of the OpenAPI spec (default:./openapi.yaml)outputPath(string, optional): Output directory inside the working directory (default:./src/gen)
kubb_diff, kubb_add, kubb_update, kubb_remove, and kubb_list
These tools run the kubb CLI and return its output and exit code. They use the project's own kubb, or the one that started the server when the project has none. The standalone npx @kubb/mcp server ships no CLI, so install it in the project with npm install -D kubb. kubb_add, kubb_update, and kubb_remove pass --yes.
kubb_diffrunskubb generate --diff --reporter jsonforfullandkubb generate --check --reporter jsonforsummary. It writes nothing. Parameters:configPath(string, optional),format(fullfor the unified diffs orsummaryfor one line per out-of-date file, defaultfull),lockfile(boolean, defaulttrue)kubb_addrunskubb add <id> --yes. Parameters:extensionId(string, required),configPath(string, optional),install(boolean, defaulttrue),dryRun(boolean, defaultfalse)kubb_updaterunskubb update --yes, which does not regenerate, so callkubb_generateafterwards. Parameters:extensionIds(string array, optional, default every installed extension. A major update is installed only for an extension named here),dryRun(boolean, defaultfalse)kubb_removerunskubb remove <id> --yes. Parameters:extensionId(string, required),configPath(string, optional),uninstall(boolean, defaulttrue),dryRun(boolean, defaultfalse)kubb_listrunskubb list. No parameters
An extensionId is owner/slug, or a slug such as plugin-zod for an official extension. A configPath must stay inside the working directory.
Configuration
The kubb_generate tool looks for kubb.config.ts in the working directory by default. Pass configPath to use another config file in that directory.
Example kubb.config.ts:
import { defineConfig } from 'kubb'
import { adapterOas } from '@kubb/adapter-oas'
import { pluginTs } from '@kubb/plugin-ts'
import { pluginAxios } from '@kubb/plugin-axios'
export default defineConfig({
input: './petstore.yaml',
output: {
path: './src/generated',
},
adapter: adapterOas(),
plugins: [pluginTs(), pluginAxios()],
})
Supporting Kubb
Kubb is an open source project, and its development is funded entirely by sponsors. If you would like to become a sponsor, please consider: