kubb mcp
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.
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.
| Tool | What it does | Writes |
|---|---|---|
kubb_generate | Runs the Kubb pipeline from the project's config. | Yes, overwrites generated files |
kubb_validate | Validates an OpenAPI or Swagger document. | No |
kubb_diff | Shows what kubb_generate would change, without writing files. | No |
kubb_init | Writes a kubb.config.ts without prompts. | Yes, a new file only |
kubb_add | Installs an extension from the registry and adds it to the config. | Yes |
kubb_update | Updates installed extensions. | Yes, replaces installed versions |
kubb_remove | Removes an extension from the config and uninstalls it. | Yes, removes |
kubb_list | Lists 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.
| Tool | readOnlyHint | destructiveHint | idempotentHint | openWorldHint |
|---|---|---|---|---|
kubb_generate | false | true | true | true |
kubb_validate | true | true | true | |
kubb_diff | true | true | true | |
kubb_init | false | false | true | false |
kubb_add | false | false | true | true |
kubb_update | false | true | true | true |
kubb_remove | false | true | true | true |
kubb_list | true | true | true |
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.
.ts, .mts, .cts, .js, .mjs, or .cjs config file inside the working directory. Without it, the server searches the way kubb generate does.input.output.path.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.
kubb generate does.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.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.
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.
./openapi.yaml../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.
owner/slug, or a slug such as plugin-zod for an official extension.false to only edit the config, as --no-install does. Default: true.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.
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.
owner/slug, or a slug such as plugin-zod for an official extension.false to only edit the config, as --no-uninstall does. Default: true.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_generatelooks for the config there, then in each parent folder.kubb_generaterejects aconfigPathoroutputPathoutside that folder, and aninputPathoutside it unlessinputPathis anhttp:orhttps:URL. The check follows symlinks, and resolvesoutputPathandinputPathfrom the config'sroot.kubb_generatealso rejects a config whose ownoutput.pathis outside that folder, sinceoutput.cleanempties it.kubb_diff,kubb_add, andkubb_removereject aconfigPathoutside that folder too.- Every tool that runs the CLI runs it there.
kubb_initwriteskubb.config.tsthere, and rejects anoutputPathoutside that folder.
When the server cannot find your config, see Start it in your project.
