CNB CLI
About 538 wordsAbout 2 min
Overview
CNB CLI is the command-line tool for the CNB platform OpenAPI. A single cnb command lets you access the platform's full OpenAPI surface, covering source control, builds, registries, organizations and members, knowledge base and more.
When to use: when you want to operate CNB from the command line or a script — for example creating issues in bulk in a pipeline, checking build status, or manipulating artifacts, or letting an NPC call platform capabilities through it instead of crafting OpenAPI requests.
There are two ways to get it:
- npm package:
@cnbcool/cnb-cli - Docker image:
cnbcool/cnb-cli
Installation & Usage
Local install, Docker and pipeline usage are described below.
Local install (requires Node.js LTS)
npm install -g @cnbcool/cnb-cli
cnb --helpRun with Docker (no install required)
docker run --rm -v $(pwd):$(pwd) -w $(pwd) cnbcool/cnb-cli cnb users get-user-infoUse inside a .cnb.yml pipeline
The example below runs on a push event to the main branch. CNB_TOKEN is injected automatically — no login needed:
main:
push:
- docker:
image: cnbcool/cnb-cli
stages:
- name: get-user-info
script: cnb users get-user-infoAuthentication
For local terminals, OAuth2 device authorization is recommended:
cnb login
cnb status
cnb logoutYou can also provide a token via the CNB_TOKEN environment variable, which is auto-injected in CI scenarios.
Logging in to a specific host
Use --host to specify which CNB platform to log in to, so you can switch between different deployments. The value is a hostname, optionally with a port, and needs no scheme:
# Log in to the public CNB cloud
cnb login
# Log in to a self-hosted CNB, with an optional port
cnb login --host cnb.example.com
cnb login --host cnb.example.com:8080Without --host, the login target is inferred in the following order, using the first available value:
- The host in the current repository's
git remote; - The host from the
CNB_API_ENDPOINTenvironment variable; - If neither is available, the default host:
cnb.cool.
--host takes highest priority and overrides all of the above. Login sessions are stored per host in ~/.cnb/token and do not interfere with each other. cnb status and cnb logout also accept --host:
cnb status --host cnb.example.com
cnb logout --host cnb.example.com # without --host, log out of every hostExploring Available Commands
Platform capabilities are organized into modules. Use -s / --short to list the shortcut commands available in the current repository / event, or list all modules with cnb --help and drill down with cnb <module> --help and cnb <module> <tool> --help.
Exposing the CLI to AI Clients over MCP
cnb mcp starts an MCP server over stdio, so an AI client needs only one config entry to log in and run cnb commands without installing the CLI locally. See MCP Setup for the configuration, available tools, and login flow.
Learn More
For the full module list, parameter reference and advanced usage such as the Git Credential Helper, see the CNB CLI plugin documentation.