Skip to content
Commands

kubb mcp

The mcp command starts a stdio Model Context Protocol server with a tool for every Kubb command except studio and mcp, such as kubb_generate, kubb_diff, kubb_add, and kubb_update, with each tool's parameters.

kubb mcp starts a Model Context Protocol server, so your AI client can run every kubb command except studio and mcp: validate a spec, write a kubb.config.ts, manage extensions, and generate code. It takes no options. Set up the MCP server shows how to add it to Claude Code, Cursor, VS Code, and other clients.

This feature is under active development. Use it with caution and expect breaking changes.
kubb mcp

The server uses the stdio transport, so the client starts it as a local process. Its own messages go to stderr, since stdout carries the protocol.

Tools

Each tool is named after its CLI command with a kubb_ prefix and underscores, so the names stay unique next to the tools of other servers.

ToolWhat it doesWrites
kubb_generateRuns the Kubb pipeline from the project's config.Yes, overwrites generated files
kubb_validateValidates an OpenAPI or Swagger document.No
kubb_diffShows what kubb_generate would change, without writing files.No
kubb_initWrites a kubb.config.ts without prompts.Yes, a new file only
kubb_addInstalls an extension from the registry and adds it to the config.Yes
kubb_updateUpdates installed extensions.Yes, replaces installed versions
kubb_removeRemoves an extension from the config and uninstalls it.Yes, removes
kubb_listLists installed extensions and available updates.No

kubb_diff, kubb_add, kubb_update, kubb_remove, and kubb_list 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. kubb_add, kubb_update, and kubb_remove pass --yes and accept dryRun. kubb studio has no tool, since its login needs a browser.

Annotations

Every tool sets the MCP tool annotations, so a client can run a read-only tool without asking and confirm a destructive one.

ToolreadOnlyHintdestructiveHintidempotentHintopenWorldHint
kubb_generatefalsetruetruetrue
kubb_validatetruetruetrue
kubb_difftruetruetrue
kubb_initfalsefalsetruefalse
kubb_addfalsefalsetruetrue
kubb_updatefalsetruetruetrue
kubb_removefalsetruetruetrue
kubb_listtruetruetrue

kubb_generate is destructive because it overwrites generated files and, with output.clean, empties the output folder first. openWorldHint is true for a tool that can fetch a spec URL or reach the registry.

Output size

A tool that runs the CLI returns 30,000 characters of text at most, which stays under the 10,000 tokens at which Claude Code warns about a tool response. Longer output is cut at a line break and ends with a notice, which counts toward the limit:

[Output cut: showing the first 29712 of 412090 characters. The diffs of the later files are missing. The out-of-date files are listed below.

2 generated files are out of date:
src/gen/types/Pet.ts (+4120 -3980)
src/gen/types/Order.ts (+12 -3)]

For kubb_diff, the notice lists the out-of-date files with their line counts, up to 5,000 characters of list. Set format to summary to get the whole list without the diffs.

kubb_generate

Runs the Kubb pipeline and returns the file count, warnings, and diagnostics. On failure, each diagnostic comes with its code, fix, and docs link. A config that exports an array runs its first entry.

configPath
string
Path to a .ts, .mts, .cts, .js, .mjs, or .cjs config file inside the working directory. Without it, the server searches the way kubb generate does.
inputPath
string
Spec path or URL. Overrides the config's input.
outputPath
string
Output folder. Overrides the config's output.path.
logLevel
'silent' | 'info' | 'verbose'
Passed to a config that exports a function. Default: info.

kubb_diff

Runs kubb generate --diff with the json reporter and returns the run log and the generated-file diff: a unified diff for each generated file that differs from what kubb_generate would write. It writes nothing, and it does not compare two versions of a spec. Exit code 0 means the files are up to date, and 1 means they are out of date. A failed run returns an error.

configPath
string
Path to a config file inside the working directory. Without it, the CLI finds the config the way kubb generate does.
format
'full' | 'summary'
full returns the unified diffs, cut at the output limit. summary runs kubb generate --check and returns one line per out-of-date file with its added and removed line counts, such as src/gen/pet.ts (+12 -3), under the run log and its warnings. Default: full.
lockfile
boolean
Set to false to compare with the generated text alone, as --no-lockfile does. Default: true.

kubb_validate

Validates an OpenAPI or Swagger document with the bundled OpenAPI adapter. It does not read the config, and it writes nothing. A $ref may read local files only inside the working directory, and fetch URLs only on public hosts.

inputPath
string required
Path or URL of the spec.

kubb_init

Writes a kubb.config.ts with an empty plugins array to the working directory, and fails when one exists. It installs nothing. Its reply tells the agent to call kubb_add for each plugin.

inputPath
string
Spec path written to the config. Default: ./openapi.yaml.
outputPath
string
Output folder inside the working directory, written to the config. Default: ./src/gen.

kubb_add

Runs kubb add <id> --yes. It installs a plugin, adapter, or parser at the version the registry pins. A plugin or parser is added to the config with the plugins it needs, and an adapter comes back as a snippet to add by hand.

extensionId
string required
Registry id: owner/slug, or a slug such as plugin-zod for an official extension.
configPath
string
Path to a config file inside the working directory.
install
boolean
Set to false to only edit the config, as --no-install does. Default: true.
dryRun
boolean
Preview the change without installing or writing. Default: false.

kubb_update

Runs kubb update --yes. It updates extensions to the versions the registry pins and summarizes the install. It does not regenerate, so call kubb_generate afterwards to update the generated files.

extensionIds
string[]
Registry ids to update. Default: every installed extension. A major update is installed only for an extension you name here.
dryRun
boolean
Preview the updates without installing or writing. Default: false.

kubb_remove

Runs kubb remove <id> --yes. It removes a plugin or parser from the config and uninstalls its package. It leaves the files the extension generated, so call kubb_generate afterwards.

extensionId
string required
Registry id: owner/slug, or a slug such as plugin-zod for an official extension.
configPath
string
Path to a config file inside the working directory.
uninstall
boolean
Set to false to only edit the config, as --no-uninstall does. Default: true.
dryRun
boolean
Preview the change without uninstalling or writing. Default: false.

kubb_list

Runs kubb list and returns the installed extensions, their versions, and the available updates. It takes no parameters and changes nothing.

Working directory

The server runs in the folder the client starts it in:

  • kubb_generate looks for the config there, then in each parent folder.
  • kubb_generate rejects a configPath or outputPath outside that folder, and an inputPath outside it unless inputPath is an http: or https: URL. The check follows symlinks, and resolves outputPath and inputPath from the config's root.
  • kubb_generate also rejects a config whose own output.path is outside that folder, since output.clean empties it.
  • kubb_diff, kubb_add, and kubb_remove reject a configPath outside that folder too.
  • Every tool that runs the CLI runs it there.
  • kubb_init writes kubb.config.ts there, and rejects an outputPath outside that folder.

When the server cannot find your config, see Start it in your project.