kubb agent
Manages the Agent server. The Agent exposes an HTTP/WebSocket API used by Kubb Studio for remote and live code generation.
IMPORTANT
@kubb/agent is an optional peer dependency. Install it before running this command:
shell
npm i @kubb/agentSubcommands
| Subcommand | Description |
|---|---|
start | Start the Agent server. |
Usage
Start the Agent on the default port:
shell
kubb agent startStart the Agent on a custom port and allow filesystem writes:
shell
kubb agent start --port 4000 --allow-writeOptions for kubb agent start
| Option | Default | Description |
|---|---|---|
--config=<path>, -c <path> | kubb.config.ts | Path to the Kubb config file the Agent should load. |
--port=<port>, -p <port> | 3000 | Port the Agent listens on. |
--host=<host> | localhost | Host the Agent binds to. |
--allow-write | false | Allow the Agent to write generated files to the filesystem. When not set, no files are written and config patches are not persisted. |
--allow-all | false | Grant all permissions (implies --allow-write). |
Environment variables
kubb agent start automatically loads variables from a .env file in the working directory using Node.js' built-in process.loadEnvFile() (Node.js ≥ 20.12). CLI flags take precedence over environment variables, which take precedence over the defaults listed below.
| Variable | Type | Default | Description |
|---|---|---|---|
PORT | number | 3000 | Port the Agent server listens on. Overridden by --port. |
HOST | string | localhost | Host the Agent server binds to. Overridden by --host. |
KUBB_AGENT_ROOT | string | process.cwd() | Project root the Agent treats as the working directory. |
KUBB_AGENT_CONFIG | string | kubb.config.ts | Path to the Kubb config file. Overridden by --config. |
KUBB_AGENT_ALLOW_WRITE | boolean | false | Equivalent to --allow-write. Set to true to allow filesystem writes. |
KUBB_AGENT_ALLOW_ALL | boolean | false | Equivalent to --allow-all. Implies KUBB_AGENT_ALLOW_WRITE=true. |
KUBB_AGENT_TOKEN | string | Optional authentication token required for every Agent request. | |
KUBB_AGENT_RETRY_TIMEOUT | number | 30000 | Retry timeout in milliseconds used by the Agent when connecting to Studio. |
KUBB_STUDIO_URL | string | https://kubb.studio | URL of Kubb Studio. Used for remote generation and live development features. |
TIP
Set KUBB_AGENT_TOKEN in your local .env to require an authentication token for every Agent request. This is recommended whenever the Agent is reachable beyond localhost.
See also
- Configuration:
kubb.config.tsreference - Kubb Studio: remote generation UI powered by the Agent