MCP Setup
About 962 wordsAbout 3 min
MCP Setup explains how to hand CNB platform capabilities to an AI client as an MCP server.
When to use: when you would rather not install the local CNB CLI and Skills, and only want a single MCP config entry so an Agent can work with CNB — for example letting the AI view repositories, create issues, or query build status, or fetch platform guides such as how to write .cnb.yml.
cnb mcp starts a local MCP server over stdio and wraps every OpenAPI command of the CLI into a single cnb_run tool. Command usage (common commands, parameters, output conventions) ships inside the tool description and always matches the CLI version you run.
Configure the MCP Server
Add one entry to your client's MCP config:
{
"mcpServers": {
"cnb": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@cnbcool/cnb-cli@latest", "mcp"]
}
}
}Where common clients keep it:
- CodeBuddy: Settings → MCP, stored in
~/.codebuddy/mcp.json - Claude Desktop:
claude_desktop_config.json - Other clients that accept a
mcpServersstdio config work the same way
Two things you can change in args:
- Version:
@latestpulls the latest release on every start; pin the major version with@1 - Platform: append
"--host", "<platform domain>"to lock the platform, which is useful for private deployments or when the workspace is not a CNB repository. A port is allowed; no scheme prefix is needed
Available Tools
| Tool | Purpose | Parameters |
|---|---|---|
cnb_run | Runs any cnb command, covering all OpenAPI operations: issues, PRs, repositories, builds, artifact registries | args: argument array after cnb; cwd: absolute workspace path |
cnb_guide | Returns platform guides on demand: .cnb.yml syntax and CI troubleshooting, attachment uploads, how to query the official docs | query: search; name + path: topic and volume; cwd |
cnb_status | Shows login status and refreshes the token automatically when it expires | cwd |
cnb_login | OAuth2 device authorization login, returns an authorization link | cwd |
cnb_logout | Logs out and removes the local credentials for that platform | cwd |
cnb_run passes args to the CLI as an array, without a shell: multi-line bodies go in as a single element, for example ["issues","comment","--number","12","--body","line 1\nline 2"], with no quoting or escaping. The login and mcp subcommands are blocked; use cnb_login to log in.
cnb_guide fetches content on demand, so it does not occupy the context permanently. With no arguments it lists all topics; {"query":"cron job not triggered"} returns the most relevant excerpts with sources; {"name":"cnb-pipeline"} returns the main file plus its volumes, and {"name":"cnb-pipeline","path":"crontab.md"} returns one volume.
Platform and Repository Inference
- Platform: the
--hoststartup argument → the git remote ofcwd→ theCNB_API_ENDPOINTenvironment variable →cnb.cool. The resolved platform decides both the API domain and which credentials are read - Repository: when
--repois omitted, it is inferred from the git remote ofcwd(https://,ssh://, andgit@host:org/repo.gitare all supported); pass--repo org/repoexplicitly for cross-repository operations or whencwdis not a git repository - Precedence: an explicit
--repoalways wins over the inferred value
First Use: Log In
- Call
cnb_status(pass the workspace path) to check login status, then follow the returned hint - Call
cnb_loginand give the returned authorization link to the user; clients that support URL elicitation show the link directly - After the user confirms in the browser, call
cnb_statusagain to confirm the login
Once logged in, use cnb_run for your tasks without repeating the repository on every call:
{
"args": ["issues", "list-issues", "--state", "open", "--page-size", "5"],
"cwd": "/path/to/repo"
}For commands outside the quick reference, have the Agent call ["<module>","--help"] to look up the parameters first.
Authentication and Security
- The token lives in
~/.cnb/token(mode600) and is shared withcnb login; authorizations obtained through MCP are written there too cnb_loginuses the device code flow and never handles your password; the authorization link is valid for about 10 minutes- Credentials are stored per platform domain, and
cnb_status,cnb_login, andcnb_logoutall resolve the platform with the same rules
Relationship with Skills
MCP covers every CLI command, so it is equivalent to "the cnb-api Skill + the CLI" and you do not need to install Skills as well.
Platform guidance is built in as cnb_guide, whose content comes from cnb-pipeline, cnb-upload-attachment, and cnb-docs in the Skills repository, and follows the CLI version.
If you do not configure MCP and let an Agent work locally, or you need Skills that are not built in such as cnb-code-review or cnb-code-commit, install Skills as described.
FAQ
| Symptom | What to do |
|---|---|
cnb_status reports not logged in | Call cnb_login, confirm in the browser, then call cnb_status again |
| "Not a git repository, cannot infer repository" | cwd is not a git repository or has no remote: pass --repo org/repo explicitly, or point cwd at the workspace |
| Commands hit the wrong platform | Check the git remote of cwd, or add "--host", "<platform domain>" to the config |
unknown option on a parameter | The CLI suggests the correct spelling (for example --page-size) with full help; follow the hint |
| Output is truncated | Output over 100KB returns only the head and tail, with the full content written to a temp file; drop --verbose or page through the results |