Skip to content
Commands

kubb mcp

The mcp command starts a stdio Model Context Protocol server with generate, validate, and init tools for AI clients, with each tool's parameters.

kubb mcp starts a Model Context Protocol server, so your AI client can validate a spec, write a kubb.config.ts, 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

ToolWhat it does
generateRuns the Kubb pipeline from the project's config.
validateValidates an OpenAPI or Swagger document.
initWrites a kubb.config.ts without prompts.

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.

config
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.
input
string
Spec path. Overrides the config's input.
output
string
Output folder. Overrides the config's output.path.
logLevel
'silent' | 'info' | 'verbose'
Passed to a config that exports a function. Default: info.

validate

Validates an OpenAPI or Swagger document with the bundled OpenAPI adapter. It does not read the config.

input
string required
Path or URL of the spec.

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 run kubb add <id> --yes for each plugin.

input
string
Spec path written to the config. Default: ./openapi.yaml.
output
string
Output folder written to the config. Default: ./src/gen.

Working directory

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

  • generate looks for the config there, then in each parent folder.
  • generate rejects a config path outside that folder.
  • init writes kubb.config.ts there.

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