Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@kubb/cli

Package Overview
Dependencies
Maintainers
1
Versions
1285
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kubb/cli

Official CLI for Kubb. Run kubb generate, kubb init, kubb validate, kubb mcp, and kubb agent to manage the full code generation lifecycle from OpenAPI/Swagger specs.

Source
npmnpm
Version
5.0.0-beta.8
Version published
Weekly downloads
108K
-15.61%
Maintainers
1
Weekly downloads
 
Created
Source

@kubb/cli

Kubb logo

npm version npm downloads Coverage License Sponsors

View Demo · Documentation · Report Bug · Request Feature

Official CLI for Kubb. Run kubb generate to transform OpenAPI/Swagger specs into TypeScript types, API clients, hooks, validators, and mocks. Includes interactive project setup (kubb init), spec validation, watch mode, MCP server, and agent server commands.

Installation

bun add -D @kubb/cli
# or
pnpm add -D @kubb/cli
# or
npm install -D @kubb/cli

Commands

kubb init

Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for an interactive setup wizard, or pass flags to skip the prompts.

npx kubb init

Options

FlagShortTypeDefaultDescription
--yes-ybooleanfalseSkip all prompts and use defaults
--input <path>-istring./openapi.yamlPath to the OpenAPI specification
--output <path>-ostring./src/genOutput directory for generated files
--plugins <list>stringComma-separated list of plugins to install

Available plugin values for --plugins: plugin-ts, plugin-client, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc.

Examples

# Interactive wizard
npx kubb init

# Accept all defaults
npx kubb init --yes

# Fully non-interactive
npx kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod

# Select specific plugins only
npx kubb init --plugins plugin-ts,plugin-client,plugin-react-query

The wizard will:

  • Detect or create a package.json if one does not exist
  • Prompt for your OpenAPI specification path (default: ./openapi.yaml)
  • Ask for the output directory (default: ./src/gen)
  • Let you choose which plugins to install
  • Install the selected packages using your package manager (npm, pnpm, yarn, or bun)
  • Generate a kubb.config.ts with your chosen configuration

kubb generate

Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads kubb.config.ts by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.

npx kubb generate

Options

FlagShortTypeDefaultDescription
[input]stringOpenAPI file path — overrides input.path in the config
--config <path>-cstringPath to the Kubb config file
--logLevel <level>-lstringinfoLog level: silent, info, verbose, or debug
--watch-wbooleanfalseRe-generate whenever the input file changes
--debug-dbooleanfalseOverride log level to debug
--verbose-vbooleanfalseOverride log level to verbose
--silent-sbooleanfalseOverride log level to silent

Examples

# Use kubb.config.ts in the current directory
npx kubb generate

# Override the input spec without editing the config
npx kubb generate ./openapi.yaml

# Point to a custom config file
npx kubb generate --config ./configs/kubb.config.ts

# Watch for changes and regenerate automatically
npx kubb generate --watch

# Debug output
npx kubb generate --debug

kubb validate

Parse and validate an OpenAPI/Swagger file for structural correctness. Reports schema errors, missing required fields, and malformed references. Use this before running generate to catch spec issues early.

npx kubb validate --input <path-or-url>

Options

FlagShortTypeRequiredDescription
--input <path>-istringPath or URL to the OpenAPI/Swagger file to validate

Examples

# Validate a local file
npx kubb validate --input ./openapi.yaml

# Validate a remote spec
npx kubb validate --input https://petstore3.swagger.io/api/v3/openapi.json

kubb mcp

Start a Model Context Protocol (MCP) server that exposes Kubb code generation as a tool for AI assistants. Once running, configure your AI client (Claude, Cursor, Windsurf, etc.) to connect — the assistant can then call kubb generate directly without leaving the chat.

Runs over stdio by default (compatible with all MCP clients). Pass --port to expose an HTTP server instead.

npx kubb mcp

Options

FlagShortTypeDefaultDescription
--port <number>-pstringPort for HTTP MCP server (omit for stdio)
--host <hostname>stringlocalhostHostname to bind to (HTTP mode only)

Examples

# stdio mode (recommended for Claude Desktop, Cursor, etc.)
npx kubb mcp

# HTTP mode
npx kubb mcp --port 3001

MCP client configuration

Add the following to your MCP client config (e.g. Claude Desktop's claude_desktop_config.json):

{
  "mcpServers": {
    "kubb": {
      "command": "npx",
      "args": ["kubb", "mcp"]
    }
  }
}

kubb agent start

Start the Kubb Agent HTTP server. Exposes a REST API that accepts a kubb.config.ts patch and returns generated code as a stream. Use --allow-write to also write files to disk.

npx kubb agent start

Options

FlagShortTypeDefaultDescription
--config <path>-cstringPath to the Kubb config file
--port <number>-pstring3000Port the HTTP server listens on
--host <hostname>string0.0.0.0Hostname the HTTP server binds to
--allow-writebooleanfalseWrite generated files to disk (otherwise output is streamed only)
--allow-allbooleanfalseGrant all permissions (implies --allow-write)

Examples

# Start with defaults
npx kubb agent start

# Custom port
npx kubb agent start --port 4000

# Allow writing files to disk
npx kubb agent start --allow-write

# Full permissions with custom config
npx kubb agent start --config ./kubb.config.ts --allow-all

See the @kubb/agent README for full environment variable reference, Docker setup, WebSocket API, and Studio integration.

Supporting Kubb

Kubb uses an MIT-licensed open source project with its ongoing development made possible entirely by the support of Sponsors. If you would like to become a sponsor, please consider:

My sponsors

Keywords

cli

FAQs

Package last updated on 12 May 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts