Using devhub with agents
When an agent such as Claude Code or Codex needs to restart servers to test during implementation, it calls the devhub CLI directly instead of asking someone to operate the UI. The CLI is only a thin client of the management API (zero dependencies, local connections only); all validation and conflict protection lives in the server.
Install as an agent plugin
Recommended: install from the repo, so the skill and CLI arrive together and you don’t need npm link. The repo is public on GitHub.
One-command install: npx @vantist/devhub install looks for claude, codex and agy on PATH and runs the install commands in the table below for each one it finds, skipping the rest; --claude/--codex/--agy limits it to those agents, --dry-run only lists the commands, and update and uninstall run the update and removal commands from the table. It reads and writes no agent config file, it only runs the official commands; the source is in packages/installer/, published at the same version as the plugin with npm provenance.
| Claude Code | Codex | Antigravity | |
|---|---|---|---|
| Install | claude plugin marketplace add vantist/DevHubclaude plugin install devhub@devhub |
codex plugin marketplace add vantist/DevHubcodex plugin add devhub@devhub |
agy plugin install https://github.com/vantist/DevHub |
| Update | claude plugin marketplace update devhubclaude plugin update devhub@devhub |
codex plugin marketplace upgrade devhubcodex plugin add devhub@devhub (reinstall to apply the new version) |
Run the same install command again |
| Remove | claude plugin uninstall devhub@devhubclaude plugin marketplace remove devhub |
codex plugin remove devhub@devhubcodex plugin marketplace remove devhub |
agy plugin uninstall devhub |
- The
owner/reposhorthand always means github.com; to pin a branch or tag usevantist/DevHub#<ref>(Claude Code) orvantist/DevHub@<ref>(Codex). - In Claude Code you can also use
/plugin marketplace add vantist/DevHuband/plugin install devhub@devhubinside a session. - Antigravity’s CLI clones the GitHub URL directly and doesn’t install from Releases;
agy plugin install <local directory>works too. - Installing and updating inside a Claude Code session goes over HTTPS; if that fails because you have no GitHub SSH key, set
CLAUDE_CODE_PLUGIN_PREFER_HTTPS=1. - After installation the agent sees the
devhubskill automatically; Claude Code additionally gets the commands/devhub:restart,/devhub:status,/devhub:logs,/devhub:start,/devhub:stopand/devhub:update, and a SessionStart hint (by default it only says whether devhub is running and starts nothing; it starts devhub only when autostart is on, see the next section); Antigravity turns the commands into skills and also gets a SessionStart hint (see the table below). - The plugin contains the CLI (
bin/devhub.mjs, zero dependencies, only Node needed), and when invoked from the plugin it always uses the plugin’s own copy: Claude Code’s commands and skill runnode "${CLAUDE_PLUGIN_ROOT}/bin/devhub.mjs"; Codex and Antigravity, which have no such variable, use../../bin/devhub.mjsrelative to the skill’s directory; only manual use from a clone uses the globaldevhub. - Per-platform config files:
.claude-plugin/and.mcp.json(Claude Code), the rootplugin.jsonandmcp.json,.codex-plugin/and.agents/plugins/(Codex),.antigravity-plugin/,mcp_config.jsonandhooks.json(Antigravity). There is only one copy of the skill and commands (skills/,commands/), shared by all three; the version is authoritative inpackage.json, and a test checks that all five config files’ versions match.
| Auto-loaded after install | Claude Code | Codex | Antigravity |
|---|---|---|---|
| skill | ✔ | ✔ | ✔ |
| MCP server | ✔ .mcp.json |
✔ root mcp.json |
✔ mcp_config.json |
| SessionStart hint | ✔ hooks/hooks.json |
✘ | ✔ root hooks.json |
/devhub:* commands |
✔ | ✘ (the skill covers them) | converted to skills |
- None of the three needs manual MCP registration, no
codex mcp addoragy mcp add. Verified on real installs: Codex 0.172.0 (isolatedCODEX_HOME, skill and MCP status checked through the app-server) and Antigravity 1.5.16 (after installing, a session received the SessionStart hint and loaded the 13 MCP tools). - Codex: MCP needs the root
plugin.json(Agent Plugins format; Codex-specific settings go underextensions.com.openai) plus the rootmcp.json, which is what makes the path expand (${PLUGIN_ROOT}); the old.codex-plugin/plugin.jsonwith.mcp.jsonexpands no variable at all (not even${CLAUDE_PLUGIN_ROOT}), so the server fails to start. The format is supported from about Codex 0.147.0; older Codex reads only.codex-plugin/plugin.json(kept as a fallback, and a test keeps the two in sync): the skill works, but MCP needs manual registration:codex mcp add devhub -- node <plugin directory>/bin/devhub.mjs mcp. The Agent Plugins format doesn’t load hooks, so Codex has no SessionStart hint (Codex plugin hooks also require the user to review and trust each one). - Antigravity: reads
mcp_config.json(${PLUGIN_ROOT}) and the roothooks.json(a SessionStart hook must print JSON, hence the--agyflag);.antigravity-plugin/plugin.jsontakes precedence over the rootplugin.json, which is safely ignored, and the “never loaded” warningsagy plugin validateprints for.mcp.json,mcp.json,hooks/hooks.jsonandcommands/are expected (those files are for other agents). - Codex and Antigravity start the MCP server with the plugin directory as cwd, not the project directory: pass the
cwdparameter when usinghere(see MCP server).
Migrating from the old source
Up to 0.6.x the plugin was installed from a private GitLab, which no longer receives updates; the 0.6.x version check can’t reach the new releases and shows no notice. If you installed from there, switch to GitHub; your config, services and audit log (~/.config/devhub) are not affected:
# Claude Code: applies after a restartclaude plugin marketplace remove devhubclaude plugin marketplace add vantist/DevHubclaude plugin install devhub@devhub
# Codexcodex plugin marketplace remove devhubcodex plugin marketplace add vantist/DevHubcodex plugin add devhub@devhub
# Antigravity: just install againagy plugin install https://github.com/vantist/DevHub- From 0.7.0 on,
devhub plugin checkand the SessionStart hook look at the sources registered in Claude Code’ssettings.json(extraKnownMarketplaces.devhub) andplugins/known_marketplaces.json; if the source isn’tvantist/DevHub(a local directory doesn’t count) they append the Claude Code commands above, also when the remote can’t be reached. - If you ever turned
autoUpdateon,extraKnownMarketplaces.devhubinsettings.jsonstill holds the old source; after migrating rundevhub plugin autoupdate on(oroff) once more and the old source is replaced byvantist/DevHub, with everything else kept.
Automatic updates
| How | |
|---|---|
| Claude Code | Third-party marketplaces are not auto-updated by default, and marketplace.json can’t turn it on by default; run /devhub:update in Claude Code (equivalent to devhub plugin autoupdate on plus plugin check), after which updates happen in the background when Claude Code starts and apply after a restart |
| Codex | Git-based marketplaces upgrade automatically when Codex starts (there is no setting to toggle it); to update right now use the commands in the table above |
| Antigravity | No auto-update; run agy plugin install https://github.com/vantist/DevHub again |
# plugin-only users have no global devhub: use /devhub:update, or node "<plugin directory>/bin/devhub.mjs" plugin ...devhub plugin autoupdate on [--dry-run] # writes ~/.claude/settings.json (or CLAUDE_CONFIG_DIR if set)devhub plugin autoupdate # shows the current state; off is written explicitly as falsedevhub plugin check # compares the remote and local versions now; failures show the reason; lists what changed in each newer versiondevhub plugin check --lang en # the changes in English (default Traditional Chinese); `changes` in --json has the full textautoupdate onis idempotent: if it is already set, nothing is written; before writing, the original is backed up assettings.json.devhub-bak-<time>; onlyextraKnownMarketplaces.devhub.autoUpdateis touched, and other settings, the existingsourceand indentation are preserved; if the file isn’t valid JSON it aborts without overwriting. Without a devhub CLI (it has never been started), you can add"autoUpdate": truetoextraKnownMarketplaces.devhubby hand.- Updates are decided by
versionin.claude-plugin/plugin.json: if the version hasn’t changed, nothing updates (observed: changing only content without a version bump makesplugin updatereport already at the latest version). So every release must bump the version, see Release and versioning. - New-version notice: the SessionStart hook compares the plugin version on the remote
mainwith the local one, and when a new version exists asks the agent to tell you the update command, notifying only and never changing anything automatically. The version files are read withfetchfromraw.githubusercontent.com(.claude-plugin/plugin.jsonandpackage.json, no git needed); only if that fails (offline, blocked by a proxy) does it fall back to a git shallow fetch. The hook reads only the cache (at most one network access per hour, in the background, with a 15-second timeout), so the new-version notice appears in the next session; a git clone (a developer) isn’t checked;DEVHUB_NO_UPDATE_CHECK=1turns it off. - The admin UI notifies too: the devhub server checks in the background (sharing the hook’s cache and hourly throttle), and a “New version x.y.z” pill appears in the header (its popover lists what changed in each version, read from the CHANGELOG of the installed version directory or of the background check’s cache; the running version is also always shown as a tag next to the title); its popover explains the steps for your install method (plugin:
/devhub:updateor the update command, thendevhub server restartafter restarting Claude Code only if the popover says the core changed; clone:git pull, likewise), with “Check now” (the same check doesn’t hit the network again within 10 seconds). Only after 3 consecutive failures does it show an unobtrusive “Version check failed” with the reason (credentials in URLs are masked).GET /api/updateandPOST /api/update/checkprovide the data; withDEVHUB_NO_UPDATE_CHECK=1the page doesn’t check either. Unlike the hook, clones are checked too.
- A failed background update gives no notice (common causes: GitHub is unreachable (network or proxy), or the environment variable
DISABLE_AUTOUPDATERorCLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFICis set; both also disable plugin auto-update). A single offline remote check doesn’t bother you, and after 3 consecutive failures the hook says why; you can always rundevhub plugin checkto see the actual error. - If devhub is already running after an update, run
devhub server restartto switch to the new version (the SessionStart hint tells you).
Updating plugins from the admin UI
The popover of the “New version x.y.z” pill lists the devhub installed for each agent on this computer (Claude Code, Codex, Antigravity, and the git clone when devhub runs from one): the version, whether it is “used by the server” (which plugin directory this devhub server was started from), and whether it is “outdated”. Antigravity has no auto-update and often sits on an old version, so it shows up here too; the popover of the version tag in the header has the same list.
- Agents that are outdated and have an update command found are ticked by default; press “Update and restart” (the button reads “Update selected” when the source the server uses is not ticked).
- The page asks for confirmation first, listing the commands that will run; after you confirm it shows each step’s progress and an output summary.
- Once the source the server uses is updated and the new version is ready, it goes straight into the existing “restart devhub server now” confirmation (only devhub restarts; managed services are not affected); if the source did not change no restart is needed and a page refresh is enough.
| Agent | Commands run on your behalf |
|---|---|
| Claude Code | claude plugin marketplace update devhub, claude plugin update devhub@devhub |
| Codex | codex plugin marketplace upgrade devhub, codex plugin add devhub@devhub |
| Antigravity | agy plugin install https://github.com/vantist/DevHub (replaces the installation in place) |
| git clone | git -C <clone directory> pull --ff-only (fails with the reason when there are local changes and it cannot fast-forward; nothing is merged or overwritten) |
- The commands are located by absolute path (PATH plus common install locations). With only the Claude app installed there is no
claudecommand: that row says “update in the Claude app with/plugin”; whencodex,agyorgitis missing, the commands to run by hand are listed. - No agent settings file is modified and nothing is elevated; only the agents you tick are updated, and only one update job runs at a time.
- Each agent is independent: one failing does not affect the others. A failure shows the reason (exit code, or the 180-second timeout), an output summary and the manual steps, and leaves no lock behind; a command that succeeds but leaves the version unchanged (the source has no newer version yet) is called out.
- Like the other admin operations it only accepts local origins (and the token when enabled), and is written to the audit log (
plugin.update, with each agent’s result). - CLI and MCP:
devhub plugin listshows the list;devhub plugin update claude --yes(or--allfor every outdated one;--dry-runonly previews); in MCP,devhub_pluginlistandupdate(needsconfirm: true). The skill tells agents to use it only when the owner asks to update devhub, after saying which agents will be updated; when the result’srestartServeristrue, ask whether to rundevhub server restart.

Does an update need a restart?
Most updates don’t need the devhub server restarted; only core changes do. Each version declares devhub.coreVersion in package.json, and the update notices and devhub server status use it to tell you whether this update needs a restart and whether it will convert your config.
| Part | How it takes effect after an update | Restart? |
|---|---|---|
Admin UI (src/ui/ (index.html, front-end modules, locale files)) |
The server re-checks the installed plugin version directories every few seconds and serves from a newer one with the same core as soon as it appears; an open page notices and shows “UI updated” in the header, and a reload applies it | No |
| CLI, MCP server, SessionStart hook, skill, commands | Every call or session is a new process and uses the new plugin directory directly | No |
| Server core (process management, proxy, TLS, management API, config and state formats) | Already loaded in the running process; switching needs devhub server restart (this restarts only the devhub server) |
Yes |
The running version is always shown next to the devhub title; its popover shows the installed version, the core version and links to that version’s Release page and changelog; when the installed version differs from the running one it also offers “Restart devhub server now”, and when another agent’s plugin is outdated you can tick it and press “Update and restart”.
The popover of the “Restart server” pill also has a “Restart devhub server now” button: after an in-page confirmation it calls POST /api/server/restart, and the server spawns an independent process (via WMI on Windows) that runs the same flow as devhub server restart, switching to the latest installed version. Only devhub restarts and managed services are unaffected; the page polls and reloads by itself once the new server is ready. An instance not started by the devhub server command gets 409.

- The three notice texts: when a new version isn’t installed yet, the pill and the SessionStart hint say “no restart needed, just reload the page” or “the devhub server needs a restart (your services are not affected)”; when a new version is installed but the running server is still the old one (its core differs, or the core is the same and only the UI has been swapped in), the pill shows “Restart server”; when the UI has already been swapped in it shows “UI updated”. If the remote doesn’t declare
coreVersion(an older version), a restart is assumed. When the update includes a config or state format upgrade, the notice adds “it is converted automatically on start (backed up as.bak-<time>first)”. - A restart doesn’t stop your services: managed processes start in their own process group with output written straight to the log file, and their pids are recorded in
state.json;devhub server stop/restartonly signals devhub itself, and the new server adopts them fromstate.json(same pid, same log); containers are managed by the engine anyway. Claims, the activity log, worktree choices and stack state all live in files and carry on after the restart. In testing, connections to services were not interrupted during a restart and the pid didn’t change. - What a restart briefly affects: the HTTPS proxy (443/80) and the admin UI are unreachable between the old server stopping and the new one being ready (usually a few seconds; only one process can listen on a port, so the new one can’t start before the old one closes); an in-progress stack-start summary and the health history live in memory and are recomputed after a restart; an in-progress prestart or image build is no longer tracked, so wait for it to finish before restarting.
- Windows: services don’t use process groups, and stopping devhub deliberately doesn’t take down the services it started (no
/T); adoption also relies on the pid instate.json. This flow has not been verified on a real Windows machine yet; see windows-acceptance.md for the acceptance items. - Compatibility with older versions: when a new server loads an older
services.jsonorstate.jsonit backs it up and converts it automatically (see Configuration reference); a format newer than itself is refused with an explanation; a new CLI against an old server and an old CLI against a new server both behave clearly (compatible, or a clear message to update or restart).
Starting the server and autostart
The plugin directory contains the complete server program, so after installing you can start it without cloning:
devhub server start # copies to ~/.config/devhub/runtime/ and starts in the background; without node_modules, runs npm ci --omit=dev inside the copydevhub server status # pid, sourceRoot, runtimeRoot, version, uptime; suggests a restart when this CLI or the source is newer than the running onedevhub server restart # required after a plugin update: rebuilds the copy and switches to the new versiondevhub server stop # stops only devhub itself; the services it manages keep runningThe server is not tied to the agent session: it keeps running after the session ends or closes, and you stop it with devhub server stop. It also doesn’t run directly from the plugin directory but from the copy at runtime/<version>-<short hash>/ in the config directory (~/.config/devhub/runtime on macOS/Linux, %APPDATA%\devhub\runtime on Windows), so neither a plugin update nor the old directory being cleaned up affects the running server. Only a plugin update that changed the core needs devhub server restart to switch to the new version (see Does an update need a restart?). For command details, the single-instance rule and file locations see getting-started.md.
By default it can only be started manually. To start it automatically when an agent session begins, turn on autostart (default false):
devhub server autostart on # or tick "Start devhub automatically when an agent session begins" in "Settings" in the admin UI headerdevhub server autostart offIt is the top-level field "server": { "autoStart": true } in ~/.config/devhub/services.json (%APPDATA%\devhub\services.json on Windows), and the UI switch and the CLI write the same place.
| autoStart | Behavior of the SessionStart hook (scripts/session-hint.mjs) |
|---|---|
false (default) |
Hints only. When devhub isn’t running it tells the agent to ask the user, who runs /devhub:start or devhub server start (or lets the agent run it after permission), and explains how to turn on autostart |
true |
When devhub isn’t running, runs devhub server start in the background (detached, waiting up to 8 seconds to confirm it is usable; the hook’s timeout is 12 seconds) and prints a line with the result; if it is already running it only hints |
- Any failure in the hook (loading, detection, reading the config, starting) only prints a hint and exits 0, so it never breaks a session.
- Claude Code and Antigravity have a SessionStart hook (the same script; Antigravity gets JSON via
--agy). Codex’s plugin format doesn’t load hooks, so there it can only be started manually (devhub server start); the skill still tells the agent to ask the user first when devhub isn’t running and not to start it on its own (except in a Claude Code or Antigravity session where autostart is on). - Even when several agents open sessions at once, only one server runs (single instance). After a plugin update the running one is still the old copy:
devhub server statusand the SessionStart hint tell you the source has been updated, anddevhub server restartswitches to the new one.
Environment cleanup
devhub server start, the SessionStart hook, and every time devhub starts a service, a prestart step, a container or an external command such as orca/git/glab, the agent session’s environment variables are not inherited:
- Removed: the prefixes
ORCA_,CLAUDE_,CLAUDECODE,CODEX_,ANTHROPIC_,AGY_,ANTIGRAVITY_, and*_TOKEN,*_SECRET,*_API_KEY. - Kept:
PATH,HOME,USER,LANG,TMPDIR,SHELL, proxies (HTTPS_PROXY,NO_PROXYand so on),NODE_*andDEVHUB_*; other variables that match none of the rules above are kept as usual. Variables a service sets inenvinservices.jsonare injected as usual. - Why: these values become invalid once the session ends, so inheriting them makes CLIs such as
orcafail; and tokens shouldn’t linger in a long-running daemon and every dev server it starts. ORCA_CLI_COMMAND,CLOUDFLARE_API_TOKENandDUCKDNS_TOKEN, which the devhub server itself needs to read, are kept in the server process but are still not passed to services and external commands.- To let specific variables through (for example a service needs
GITHUB_TOKEN, orglablogs in viaGITLAB_TOKEN): set"server": { "envPassthrough": ["GITHUB_TOKEN"] }inservices.json(names are case-insensitive); only servers and child processes started afterwards pick them up, and a running server needsdevhub server restart.
Plugin and npm link side by side
When a clone has had npm link run, the global devhub points to the clone, which is a different CLI from the plugin’s. Which one counts:
- An agent invoking through the plugin (commands, skill): always the plugin’s copy, unaffected by the global
devhub. - You typing
devhubin a terminal: the global copy (the clone). When it has the same version as the plugin,server statusshows only “different source” information and doesn’t suggest a restart;relationin the JSON issame. - Only
relation=newer(this CLI is newer) suggestsdevhub server restart;older(this CLI is older) warns not to restart with it, andserver restartrefuses too; add--force-olderonly if you really want to downgrade. - To make the terminal’s
devhubmatch the plugin:npm unlink -g devhub, or usenode <plugin directory>/bin/devhub.mjsdirectly.
Install the CLI and skill (without the plugin)
CLI:
cd <devhub directory> && npm link # afterwards devhub runs from any directorydevhub --helpIt connects to http://127.0.0.1:4999 by default, overridable with DEVHUB_URL (only http on 127.0.0.1/localhost is accepted). When devhub isn’t running it reports exit 4 and the start command (devhub server start).
The skill lives in the repo’s skills/devhub/SKILL.md; symlink it so each agent can read it (replace the path with your devhub directory):
ln -s <devhub directory>/skills/devhub ~/.claude/skills/devhub # Claude Codeln -s <devhub directory>/skills/devhub ~/.agents/skills/devhub # Codex and othersCommon commands
By category; each command has devhub <command> --help. For the full correspondence between UI features and the CLI (including deliberately excluded items) see cli-parity.md.
Service operations
devhub restart --here # inside a worktree directory: restart all services of that repo (backends first) and wait for ports to be readydevhub restart api --here # restart only the given service (--worktree <path> picks another worktree)devhub restart 5411 # a service can also be given by port (5411 or :5411), proxy path (/demoapi) or display name ("Demo API")devhub start|stop <service...> # --takeover takes over a port held by an external processdevhub stop <service> --force # force-end a service that is "stopping" (same as the UI's force stop)devhub rebuild api --restart # forces prestart (for container services, rebuilds the image); --rebuild can be added to start/restartProjects and stacks
devhub project list # project rows (the project grouping in the UI)devhub project start|restart|stop <project|repo> # batch operation; --worktree <path> or --here picks the worktreedevhub repo list|add|remove # repo list; add [path] [--name <name>] saves it to config reposdevhub stack list|show|start|stop|restart <name>devhub stack create <name> --members a,b,@other-stack # or --from-running (saves the running services as a stack), --file <path>devhub stack update <name> --members a,b devhub stack rename <old name> <new name> devhub stack delete <name> --yesWhen a stack or project wants a different worktree and conflicts with a running stack, the default is exit 3; --switch switches, and --keep-existing keeps what is there.
Service configuration
devhub service list|show <service> [--reveal] # show: state and full config; env values are masked as *** by default, --reveal shows the originaldevhub service add --set key=foo --set path=/foo --set port=3000 --set cwd=. --set cmd="npm run dev"devhub service update <service> --set env.PORT=3000 # with --set only: merges onto the current config; with --file/JSON on stdin: replaces the whole configdevhub service delete <service> --yesdevhub service select <service> --worktree <path> # changes only the selection, no start/stopdevhub service suggest [--here] [--json] # read-only: scan a project not in devhub yet and suggest services (see below)devhub service restart-at <service> [list|add|remove|set|clear] [HH:MM ...] # scheduled restart times (see the next section)devhub service containers # all containers on the enginedevhub service import-container <container name> [--key <key>] [--set key=value ...]--set can be repeated and a field can reach into nesting with a.b; a value is JSON if it parses as JSON, otherwise text; env.* is always text. Validation is the same as in the UI.
In service show and in the conf of GET /api/state, secret values of env, environment and build.args are masked as *** (postgres://u:***@h): what an agent reads ends up in the conversation record. For the original values add --reveal (API: ?reveal=1). Saving rejects fields whose value is *** (to avoid writing masked values back and overwriting real secrets), with an explanatory message; service update with only --set automatically builds on the original values and is unaffected; to replace the whole config with --file/stdin, first take conf from service show <service> --reveal --json. MCP’s devhub_service show and devhub_observe env always mask, with no --reveal.
worktree initialization
devhub worktree-init suggest --all --json > suggest.json # suggestions from the configured services (cwd/envFile scope) for every project that has services (paths only, contents never read); one project: suggest <project>devhub worktree-init suggest --service api # one service; write the service level: devhub service update api --set 'worktreeInit={"copy":[".env"],"deps":"auto"}'devhub worktree-init set --all --file suggest.json # review, drop what you don't want, then write them all; projects that already have settings are skipped unless --overwritedevhub worktree-init set my-app --file my-app.json # one project; --set 'copy=[".env*"]' changes a single field; --remove removes itdevhub worktree-init show [<project>] # settings, main checkout, whether each worktree is initializeddevhub worktree-init apply my-app --worktree <path> # redo manually for an existing worktree; --force also redoes recorded copies, links and run commands# Commands after initialization (run; once per worktree; env DEVHUB_MAIN_CHECKOUT, DEVHUB_WORKTREE; the service level adds DEVHUB_SERVICE, DEVHUB_SERVICE_CWD).# Example: next.config.ts is tracked by git and the main checkout hides local edits with skip-worktree; a new worktree needs them:devhub service update web --set 'worktreeInit={"run":["cp \"$DEVHUB_MAIN_CHECKOUT/src/frontend/next.config.ts\" next.config.ts","git update-index --skip-worktree next.config.ts"]}'It runs automatically only the first time a service starts in a new worktree (see configuration.md); suggest lets an agent set up every project in one pass: each project’s suggest.proposal is a project-level config ready for set (only items shared by several services or outside a service’s cwd; it may be empty), suggestions that belong to a single service are in suggest.serviceProposals (key → { copy, deps }, written with service update; the text output of suggest lists the ready-made commands), and configured: true means it already has settings.
Observing
devhub status [service|stack] # state, port, worktree, pid, uptime, whether externally held, whether its worktree was deleted (worktreeMissing)devhub logs api --tail 100 # default --tail 50; also --since <ISO>, --followdevhub worktrees [--repo <name>] [--refresh] [--details] # --refresh skips the cache and refetches immediately; --details (needs --repo) adds uncommitted changes and the last commit timedevhub audit # see "Audit" belowdevhub env api [--here|--worktree <path>] # environment snapshot: the actual cwd, environment variables (sensitive values masked), envFile, tool versions, readiness probe; look here first when it won't startThe CLI has no log “clear”: the UI’s “Clear” only empties the screen and leaves the log file alone.
Claims
devhub claim --here --reason "testing the login flow of PR #60" # claim and say why, see "Claims" belowdevhub release --here / devhub claimsdevhub release <service> --override --yes # manually release someone else's claim (written to the audit log)Proxy and certificates
devhub proxy status|rebind|logs [--tail N] [--follow]devhub proxy renew --yes # requests a certificate from Let's Encrypt; rate-limiteddevhub tls show # settings and whether a token is "set/not set" (never its content; adds where to enter it when not set)devhub tls test [--set key=value ...] [--set-ip --yes] # tells the cause apart when host name resolution fails; the DuckDNS A record is set automatically by default, --set-ip is a one-time set when automatic setting is off (changes public DNS, needs consent)devhub tls apply --yes [--set host=... --set dnsProvider=...] [--token-stdin | --token-file <path> | --clear-token] [--reissue]devhub tls apply --yes --set mode=local-ca --set host=dev.localhost # local self-signed CA, no domain or token neededdevhub ca path # root CA certificate pathdevhub ca trust # only prints each platform's trust-install commands, never elevates privilegesFields usable with --set: host, mode (letsencrypt|local-ca|custom), certFile and keyFile (for custom), dnsProvider, cfEnvFile, duckdnsEnvFile, certDir, duckdnsSetIp and txtResolvers (JSON). The DNS token is entered by the user in the management UI, see DNS provider tokens (for agents); --token-stdin (stdin) and --token-file (a file) are alternatives for the user to run in their own terminal, an agent must not run them for the user, and neither accepts a command-line argument (it would end up in shell history and process lists) or prints it; --clear-token clears the current provider’s token. In Let’s Encrypt mode, changing the host name or provider requests a new certificate and needs --reissue as well, otherwise exit 8; local-ca and custom request nothing externally and don’t need it. The commands from devhub ca trust must be run by the user (some need sudo); an agent shouldn’t install system trust for the user.
Container engine
devhub machine status # the Podman machine and running containersdevhub machine startdevhub machine stop --yes # stops every container in the machine; the affected containers are listed firstdevhub itself
devhub server start|stop|restart|status|autostart [on|off] # see the previous sectiondevhub server token [on|off|regenerate|url] # optional token for the management API, see "Admin API token" belowdevhub server proxy-admin [on|off] # the /devhub/ entry on the proxy domain (default on)devhub config path # config file locationdevhub config export # current config; values whose names contain token/secret/password/key/credential/auth are masked as ***devhub ai status|enable|disable|revoke|ask # AI suggestions (off by default), see "AI suggestions" belowdevhub mcp # stdio MCP server (see "MCP server" below; usually started by a client, not run by hand)config export can’t detect secrets written by hand inside a cmd string, so check before pasting it anywhere.
Operations that need the user’s consent
Without the user’s explicit consent, don’t run the following; the CLI always refuses without --yes and explains why (exit 8; an interactive terminal asks): proxy renew, service delete, stack delete, machine stop, tls apply (requesting a certificate again) and release --override.
--here maps the current directory (including subdirectories) to its repo and worktree (from git; a repo not yet in the list is discovered on the first call). --wait (on by default) waits until the port listens or it fails, --no-wait doesn’t wait, and --timeout <seconds> sets the timeout (default 120). Only --takeover touches a port held by an external process. On failure the last 50 lines of that service’s log are printed.
All commands support --json (a single JSON object for both success and failure):
$ devhub restart --here --json{"project":"acme-shop","ok":true,"state":"done","steps":[{"service":"shopApi","action":"restart","status":"up"},{"service":"shopWeb","action":"restart","status":"up"}],"claim":{"session":"s-5ec06e534b","expiresAt":1795679055152,"services":["shopApi","shopWeb"]}}$ devhub status shopApi --json{"ok":true,"services":[{"key":"shopApi","status":"running","port":5601,"external":false,"pid":75466,"uptimeSec":42,"worktreeBranch":"main","lastOp":{"actor":"agent:claude","op":"restart","at":1795677255152}, ...}]}Specifying a service
Every command that takes a service (status, start, stop, restart, logs, rebuild, claim, release) accepts a key (demoapi), a port (5411 or :5411; a purely numeric value is always treated as a port), a proxy path (/demoapi, case-insensitive, matched by the same rule as the proxy) or a display name ("Demo API", case-insensitive). When nothing is found or several services match, it returns exit 1 and lists the candidates; it can be combined with --here (devhub restart 3000 --here); container services can also be given by port. When a port doesn’t belong to any configured service, the process holding it is not touched.
Exit codes
| exit code | Meaning |
|---|---|
| 0 | Success |
| 1 | Failure (exited after starting, timed out, validation error, not found or matched several services and so on), with a readable error message |
| 2 | Usage error |
| 3 | Conflict: the service is in use by a running stack on another worktree; it never switches silently and returns the conflict, and after confirming you add --switch (old name --force-switch) or --keep-existing |
| 4 | Cannot reach devhub |
| 5 | The service is claimed by another session; --force-switch can’t override it; also returned when --wait-claim times out |
| 6 | devhub server: the management API’s port is held by a process that isn’t devhub (that process is never stopped); 6 is returned only when /api/server explicitly responds and isn’t devhub |
| 7 | devhub server: cannot confirm whether the port holds devhub (requests kept timing out or failing for about 3 seconds, possibly just started or busy); it is not “occupied”, so retry later, and start/stop touch no process |
| 8 | Confirmation needed: a destructive or outward-facing operation lacks --yes, or one that would request a certificate again lacks --reissue |
devhub server status returns exit 4 when devhub isn’t running (running is false in the JSON).
A restart on the same worktree proceeds directly even when the service belongs to a running stack; only switching to a different worktree counts as a conflict.
Verifying in your own worktree (for agents)
devhub manages the owner’s local servers, one instance per service. To verify a change, an agent switches the service to its own worktree; it does not open another port or start a second server by hand:
devhub status # worktree column: which worktree (or the main checkout) runs it nowdevhub restart --here # switch the service to this worktree, restart and claim it; when done:devhub release --here # so others can switch it back- Boundaries: a service claimed by another session (exit 5) or used by a stack on another worktree (exit 3) makes the agent stop and report; it does not take over or add
--force-switchitself. Exit 5 can be waited out with--wait-claim. - At session start, when devhub is running and the current project has services, the SessionStart hint lists each service key, port and the worktree it runs from, and reminds the agent to run
devhub restart --herebefore testing. Nothing is added when devhub is not running or cannot be queried. The check costs a single/api/statecall (the one the hook already made).
Adding a project that is not in devhub (for agents)
When a project has no service yet, the agent does not decide the config itself: detect → prefilled suggestion → ask the user → add after confirmation → verify.
devhub service suggest --here [--json] # read-only; works without a running devhub (no repo or conflict marks then)# after the user confirmed and decided on changes:echo '<candidate config JSON>' | devhub service adddevhub restart --here # verify- Each candidate has
config(JSON ready forservice add: key, label, repo, cwd, cmd, port, path, healthcheck, envFile, prestart…),evidence,confidence(high/medium/low) andnotes(key or port conflicts that were renamed, things to double-check). The agent shows the user every field value with its evidence; it must not add a service without the user’s confirmation. - Coverage: Node (
dev/start/servescripts inpackage.json; default ports and port flags of Vite, Next, Nuxt, Astro, SvelteKit, Angular, Remix, CRA, Express, Fastify, NestJS; theprestartinstall step from the lockfile), .NET (applicationUrlinProperties/launchSettings.json), Python (Djangomanage.py, FastAPI/uvicorn, Flask), compose files (published ports), theweb:process of a Procfile, andPORTin.env. It scans the root, the first-level subdirectories and one level undersrc,apps,packages,servicesand similar, with one candidate per app in a monorepo. It reads only small config files (from.envonlyPORT) and writes nothing. - SessionStart: when devhub is running, the current directory belongs to a known repo, the repo has no service and candidates are found, the hint tells the agent to run
service suggestwhen it needs a server to verify or to initialize, show the result to the user and ask whether to add it. Non-web projects get no hint. - MCP:
devhub_servicesuggest(here/worktree). Prefilling the admin UI’s add-service form from the same detection is not done yet and left for later.
Scheduled restart (for agents)
A service can be given times to restart automatically every day (for example a development server whose license expires daily). Agents can add, remove, list, replace or clear them through the CLI or MCP, with several times at once; a time is HH:MM (24-hour, local time of the devhub server). It takes effect immediately, with no need to restart the service or devhub.
devhub service restart-at api # list (operation omitted): the times and the next restartdevhub service restart-at api add 04:00 13:30 # add several; existing ones are ignored (idempotent), the result lists added/ignoreddevhub service restart-at api remove 13:30 # remove; ones that were not there are ignoreddevhub service restart-at api set 04:00 16:00 # replace the whole listdevhub service restart-at api clear # clear everything (turns scheduled restart off)MCP (devhub_service; op and times apply only to restart-at):
{"action": "restart-at", "service": "api", "op": "add", "times": ["04:00", "13:30"]}{"action": "restart-at", "service": "api", "op": "list"}--json/MCP result:restartAt(the current list),added,removed,ignored,nextRestartAt(millisecond timestamp;nullwhile the service isn’t running). A bad format (25:00,7pm) returns exit 1 with an explanation and changes nothing.- Rules: only running services are restarted (a stopped one is never started); a service held by a claim is skipped and recorded, with no catch-up; missed times (devhub not running, computer asleep) are not made up. Every automatic restart and skip is in the audit log (actor
system, actionschedule.restart/schedule.skip) and in a process service’s log. Changing the setting is audited too (service.restart-at). The full rules are in configuration.md. - No need to go through
service update:restart-atchanges only this field, needs no--reveal, and never touches env secrets.
Claims
When several agents each work in their own worktree, a claim prevents them from switching the same service away from each other: devhub restart --here first claims that repo’s services by default (--no-claim turns it off), held until the TTL (default 30 minutes, set with --ttl, up to 4 hours) or devhub release; the holder can extend it with devhub claim renew. For a claimed service, other sessions can’t stop, restart or switch its worktree (a 409 is returned, CLI exit 5, naming the holder and expiry); a start on the same worktree is unaffected. The session is derived from the actor and worktree by default, and can be set with --session or DEVHUB_SESSION. The data is stored in claims.json next to the config file and expires automatically.
Claim reason: --reason "<one sentence>" (MCP reason) says what you are doing and which PR or branch, e.g. --reason "testing the login flow of PR #60". It works on claim, claim renew (replaces the reason) and the automatic claim of start/restart --here. Sessions that get blocked see it in the message (api 被 agent:claude-code 保留至 14:30(原因:testing the login flow of PR #60)), and so do claims, status (claim.reason in JSON), the read-only MCP and the admin UI. MCP requires it on devhub_claim claim and on devhub_ops start/restart with here; the CLI and API still accept a claim without one so older clients keep working (shown as “No reason given”). A reason is at most 200 characters; the server removes control characters, collapses whitespace and truncates the rest. Claiming again from the same session without a reason keeps the earlier one.
Waiting for a claim: with --wait-claim <duration> (same format as --ttl: 90, 30m, 2h; max 30 minutes), being blocked by someone else’s claim doesn’t exit 5 immediately. The CLI waits until the holder releases or the claim expires, then acquires it and carries on with the original action; on timeout it still exits 5, saying how long it waited and who holds it now. Works with claim, start/stop/restart (including the automatic claim of --here), project and stack; without it nothing changes. Example: devhub restart api --here --wait-claim 5m.
- It is not a queue: every few seconds (with jitter, and right when the holder’s claim expires) the CLI re-sends the request and the server decides atomically who gets it; with several waiters, who wins is not guaranteed (first-come-first-served would need a FIFO queue). No devhub server restart is needed.
- Nothing is held while waiting, so Ctrl+C simply ends it; don’t write your own retry loop, and don’t grab the claim. In non-JSON mode stderr shows the holder and expiry;
--jsonprints a single JSON at the end with an extrawaitedMs(also on failure). - The option is
--wait-claimbecause--wait/--no-waitalready mean “wait until the service is ready”. The MCP parameter iswaitClaim, capped at 5 minutes (MCP clients often have a call timeout: keep it ≤ 120 seconds and below the client’s timeout; when the client cancels the call (notifications/cancelled) or disconnects, the wait stops at once: the original action is not run and no claim is left behind).
To manually release someone else’s claim: click the 🔒 on the service row in the UI twice, and in the CLI use devhub release <service> --override --yes (written to the audit log, marking the holder that was released). Manual actions in the UI aren’t restricted but first ask for confirmation in the page, “This service is claimed by agent: X until hh:mm; operate anyway?”, and after you confirm the claim becomes invalid and is written to the audit log. The service row shows a lock icon with an expiry countdown, and clicking twice releases it manually.
DNS provider tokens (for agents)
The Cloudflare and DuckDNS tokens, and any other setting that needs a user’s secret, are entered only by the user, in the management UI: an agent doesn’t ask for them, handle them or read them, and doesn’t ask the user to paste a token into the conversation (it would stay in the transcript and the agent’s environment).
- Where: open
https://<proxy host>/devhub/(orhttp://127.0.0.1:4999when there is no proxy orproxy-adminis off), then the “Settings” button at the top right → Certificate: “Let’s Encrypt” → DNS provider → that provider’s token field → “Apply”. The field is labeled “Enter it only here; agents don’t and shouldn’t handle it”, is write-only, and the screen shows only “set/not set”. - When it’s missing or wrong:
devhub tls show(MCPdevhub_tls show) adds this location note while a token is not set;tls test,proxy status/proxy logsand certificate-issuance failures (token not found, Cloudflare 401/403, DuckDNS rejection) carry the same guidance. Relay it to the user as is, wait until they say it’s entered, then confirm withtls test. --token-stdin/--token-file/--clear-token: kept as an alternative for the user to run in their own terminal (for example with no browser available). An agent must not run them for the user or ask the user for a token; MCP deliberately doesn’t provide them.- The admin API token (
devhub server token) is a different thing: it protects devhub’s own management API and is CLI-only; the CLI and MCP readadmin.tokenautomatically, and an agent likewise never shows or relays its content. See the next section.
Admin API token and proxy entry
This section’s token is the access token of devhub’s management API, unrelated to the DNS provider token (see the previous section). Both are off by default (behavior as before). On a shared host, or when you don’t want other processes on the machine to call the management API directly:
devhub server token on # creates a 0600 admin.token and enables server.requireTokendevhub server token url # web login URL (open it once; it becomes an HttpOnly/SameSite=Strict cookie)devhub server token regenerate # new token; the old one and cookies become invalid immediatelydevhub server token offdevhub server proxy-admin off # /devhub/ on the proxy domain returns 404; the admin UI is only at http://127.0.0.1:4999- Agents need no setup: the CLI, MCP (the same CLI) and the SessionStart hook read
admin.tokenautomatically (DEVHUB_TOKEN_FILEcan set the path) and sendX-Devhub-Token; without a token the error message explains how to get one. When calling with curl yourself, sendX-Devhub: 1andX-Devhub-Token. server token on/off/regenerateandproxy-adminedit the config file directly, and the server rereads it on every request, so they take effect immediately; the UI can’t enable the token (it would lock itself out), but the Settings panel can toggleproxy-admin.- For details and trade-offs see development.md.
AI suggestions
Off by default. Once the owner enables it, devhub calls a local agent CLI (Claude Code, Codex, Antigravity) to answer a config question and returns an explanation plus proposed service/stack changes. They are suggestions only; nothing is written.
devhub ai status # enabled?, agent in use, agent that started devhub, detected CLIs and versions, consentsdevhub ai enable [--agent claude|codex|antigravity] --yes # shows the consent terms; enables only after you agree. Switching to an agent without consent asks againdevhub ai disable # turn off (consents kept)devhub ai revoke [--agent …] # revoke a consent; revoking the active agent also turns the feature offdevhub ai ask "How do I add this project to devhub?" --here --yes # or scope with --service / --stack / --proxydevhub ai ask "Which port should it use then?" --history turns.json --yes # follow-up: earlier turns [{"question","answer"}] (- for stdin)- Consent: the terms say the agent CLI runs on this machine, it may read the project directory and system information, it uses that agent’s quota, and which data is sent. Consent is stored in
server.aiin the config file and can be revoked; a material change to the terms asks again. - The API enforces it too: when the feature is off or the agent has no consent,
POST /api/ai/askreturns 403 (aiDisabled/aiNotConsented); hiding the UI is not the only guard. Asking also needsconfirm: true. - What is sent: the question, the redacted service and stack config (env values are never sent; secret-looking fields and credentials in URLs are masked), the related project path, the candidates from
service suggest, and the service status and log tails the agent reads through the read-only MCP (common secret patterns in logs are masked). - Agent restrictions: Claude Code runs with
--print --permission-mode dontAsk, only Read/Grep/Glob allowed, Bash and write tools denied; Codex withexec --sandbox read-only. The working directory is only ever the related project (--here/--worktreemust be a known worktree), otherwise an empty temp directory. A CLI too old for the needed flags lists what is missing and asks you to update; not installed or not logged in is reported as such. - Only devhub’s read-only MCP: the agent gets
devhub mcp --read-only(connected to the same devhub) and every other MCP server is off. It can check service status, port holders, log tails, masked config, worktrees and repos, but cannot start, stop or change anything. Claude Code uses--strict-mcp-config --mcp-config; Codex uses--ignore-user-config(it skipsconfig.toml, so model and provider are Codex defaults) and disables plugins and apps. Antigravity gets--gemini_dirpointing at a temporary directory whosemcp_config.jsonholds only the read-only devhub, so the user’s MCP servers, plugins (including the full devhub) and hooks are not loaded; sign-in comes from the system keychain and no credentials are copied. It runs with--mode plan --sandbox, and--settingsallows only the read-only devhub tools, so writing files and running commands are denied.--gemini_diris not inagy --help, so detection runsagy mcp listagainst a temporary config; only when it lists just that config’s MCP server is Antigravity usable, otherwise it is marked “cannot isolate MCP” and refused (aiNoMcpIsolation). - Limits: one question at a time, at most 10 per 10 minutes, 5-minute timeout; cancellable (Ctrl-C in the CLI). The management API needs no token by default; turn on
devhub server token onwhen you enable AI suggestions. - Conversation: the UI chat panel and
ask --history(the MCPhistoryparameter) send the earlier turns along. The server keeps the last 6 turns, 2,000 characters per answer and about 8,000 in total, dropping the oldest first, and masks URL credentials and secret-lookingNAME=valuepairs. The conversation itself lives in the browser’s localStorage (not on the server); CLI and MCP callers keep their own. A question about a service also carries its current state (status, health check error, occupying pid and process name; logs are not attached, the agent reads them through the read-only MCP when needed). - Applying: the UI shows each suggestion as a diff; tick the ones you want, press “Apply” and confirm once more, and only then are they written through the existing APIs (
POST/PUT /api/services,/api/stacks) with full validation. The CLI and MCP only return suggestions; the agent applies them withservice add/updateorstack create/updateafter the user agrees. - The audit log records
ai.settingsandai.ask(agent, scope and result; never the question).
Audit
Every state-changing operation (start, stop, restart, takeover, rebuild, creating/editing/deleting stacks and services, proxy settings, renewal, and claim creation/extension/release/expiry/override) is appended to audit.jsonl next to the config file (JSON Lines, 600): time, actor (ui/agent:<name>/mcp:<client name>), source, action, target, worktree, a summary of parameters, result and reason, and duration. Tokens aren’t recorded, nor are env values (for service config only which fields changed are recorded); read-only queries aren’t recorded. The file rotates after 5000 entries or 30 days, keeping one audit.1.jsonl.
CLI: devhub audit [--actor ui|agent|mcp|agent:name] [--service <key>] [--since <ISO>] [--limit N]; API: GET /api/audit?limit&actor&target&since. For the UI’s activity log panel see usage.md.
MCP server
devhub mcp is a stdio MCP server: it groups the CLI’s operations by category into 16 tools, each with an action parameter that selects the sub-operation, for clients that support MCP to call directly. Each action just builds CLI arguments and calls main of the same src/cli/cli.mjs (--json), so behavior, exit codes and claim rules are exactly those of the CLI, with no separate logic. For the item-by-item mapping between the CLI and MCP see cli-parity.md (enforced by tests).
| tool | actions | Corresponding CLI | Notes |
|---|---|---|---|
devhub_ops |
start, restart, stop, rebuild |
start, restart, stop, rebuild |
services, here, worktree, wait, timeout, switch, keepExisting, takeover, rebuild, force |
devhub_observe |
status, logs, env, worktrees, audit |
same names | read-only; poll logs with since (no --follow) |
devhub_claim |
claim, renew, release, list |
claim, claim renew, release, claims |
omitted action = claim; claim requires reason (why you claim); override on release needs confirm; waitClaim on claim waits for someone else’s claim (max 5 minutes) |
devhub_worktree_init |
show, suggest, set, apply |
worktree-init … |
repo, service, all, here/worktree, set, json, remove, overwrite, initForce; suggest with all looks at every project at once and with service suggests for one service only, set with all writes several projects at once (project level; use devhub_service update for the service level) |
devhub_project |
list, start, restart, stop |
project … |
name is a project or repo |
devhub_repo |
list, add, remove |
repo … |
add takes path (default cwd) and name; when list returns current null or saved: false, ask the user whether to add it first |
devhub_stack |
list, show, create, update, rename, delete, start, restart, stop |
stack … |
members, fromRunning, json; delete needs confirm |
devhub_service |
list, show, add, update, delete, select, suggest, restart-at, containers, import-container |
service … |
set, json; restart-at takes service, op (list/add/remove/set/clear) and times (one or more HH:MM); show is always masked; delete needs confirm |
devhub_proxy |
status, rebind, renew, logs |
proxy … |
renew needs confirm |
devhub_tls |
show, test, apply |
tls … |
no DNS-token handling (the user enters it in the UI; show and error messages say where); apply needs confirm |
devhub_ca |
path, trust |
ca … |
read-only, prints commands only |
devhub_machine |
status, start, stop |
machine … |
stop needs confirm |
devhub_server |
status, start, stop, restart, autostart, proxy-admin |
server … |
restart needs confirm; no management-API token (CLI-only, unrelated to the DNS token) |
devhub_config |
path, export |
config … |
read-only |
devhub_plugin |
check, autoupdate |
plugin … |
autoupdate on/off only when the user says so |
devhub_ai |
status, enable, disable, revoke, ask |
ai … |
everything except status needs the feature enabled and consented; enable and ask need confirm |
- Parameters are in each tool’s
inputSchema, and the tool description lists the parameters and required ones of every action; a parameter that doesn’t apply to the action is rejected. Services are written as in the CLI (key, port, proxy path, display name);herefinds the worktree from the MCP server’s cwd (or thecwdparameter). When Claude Code starts a stdio server its cwd is the project directory; if another client doesn’t, passcwd. - Operations that need the user’s consent (deleting services and stacks,
proxy renew,tls apply,machine stop,overrideonrelease,switch,server restart): the CLI’s--yesbecomes a requiredconfirm: truein MCP. Without it the CLI isn’t called and the result isisError(needsConfirm: true,exitCode: 8); explain to the user and get explicit consent before passing it, never add it yourself. - Deliberately not provided: writing tokens (the token of
tls applyis entered by the user in the UI and never goes through an agent;server tokenstays CLI-only to keep it out of the conversation record),logs --follow(MCP can’t stream; poll withsince),service show --reveal(MCP always masks). Reasons in cli-parity.md. - Read-only mode:
devhub mcp --read-onlylists and accepts only reading tools and actions (devhub_observestatus/logs/worktrees,devhub_servicelist/show/suggest,devhub_stacklist/show,listofdevhub_project/devhub_repo/devhub_claim,statusofdevhub_proxy/devhub_server,showofdevhub_tls/devhub_worktree_init). Every other action, the old tool names anddevhub_aiare absent from tools/list and the schema, and calls to them are refused.devhub_observe env,devhub_config exportanddevhub_observe auditare left out because they reveal non-secret env values or operation parameters;logsoutput is masked for common secret patterns first. Internally the CLI also getsDEVHUB_READ_ONLY=1and sends only GET. AI suggestions give agents this mode; plaindevhub mcpis unchanged. - Annotations:
devhub_observe,devhub_caanddevhub_configcarryreadOnlyHint; tools that contain stop, delete, override and similar operations carrydestructiveHint. - Results:
structuredContentis the CLI’s--jsonoutput plusexitCode; when the CLI exits non-zero,isErroristrue, and the content still containserror,conflicts,claims(on exit 5 don’t grab it, report to the user) andlogTail. Invalid parameters also returnisErrorrather than a protocol error. - The actor is
mcp:<client name>(taken fromclientInfo.namein initialize), shown as “mcp: name” in the audit log and the UI. - Backward compatible: the old 9 tool names and parameters keep working (
devhub_status,devhub_env,devhub_logs,devhub_restart,devhub_start,devhub_stop,devhub_claim,devhub_release,devhub_claims) but are no longer listed intools/list(devhub_claimis still a grouped tool, and omittingactionbehaves as before). The one tightening: changing worktrees withswitchnow needsconfirm: true(it was already an operation that required consent first). - A single tool call is capped at 40 minutes (the CLI has its own
timeoutinternally); when devhub isn’t running it returns exit 4.
Registration
- Claude Code: the plugin’s
.mcp.jsonregisters it automatically (node "${CLAUDE_PLUGIN_ROOT}/bin/devhub.mjs" mcp), so it is there once the plugin is installed; check with/mcp. - Codex (from about 0.147.0): the plugin’s root
mcp.jsonregisters it automatically (${PLUGIN_ROOT}, together with the rootplugin.json); only older versions need it manually:codex mcp add devhub -- node <plugin directory>/bin/devhub.mjs mcp. - Antigravity: the plugin’s
mcp_config.jsonregisters it automatically (${PLUGIN_ROOT}), with tool names prefixed by the plugin; check withagy plugin list. - Codex and Antigravity start the stdio server with the plugin directory as cwd: pass the
cwdparameter when usinghere. - Other clients: add to their MCP settings the command
nodeand args["<plugin or clone directory>/bin/devhub.mjs", "mcp"]. - Without the plugin: after cloning,
npm link, then use the commanddevhuband args["mcp"].
Implementation trade-off: the server implements MCP’s stdio protocol itself (initialize, ping, tools/list, tools/call, about 200 lines) and doesn’t take the official @modelcontextprotocol/sdk as a runtime dependency, since it pulls in dozens of packages such as express, hono and zod, and a plugin installed from git doesn’t run npm install, so the CLI and plugin must stay zero-dependency and directly runnable. The official SDK is listed only as a devDependency, and test/mcp.test.mjs uses its client to call every grouped tool for real to confirm protocol compatibility.
Why the skill and MCP coexist
The skill plus the CLI works for every agent that can run a shell; MCP offers structured tool calls with a schema and now covers the same features as the CLI (exclusions above). Both go through the same CLI logic.
- Prefer MCP when the client has it (parameters have a schema, and errors and consent-gated operations have structured responses); keep the CLI as a fallback: the client has no MCP, MCP isn’t connected, or you need something MCP deliberately omits (
logs --follow,--reveal). - Don’t mix MCP and the CLI in the same agent: their actors differ (MCP is
mcp:<client>, the CLI isagent; with no name given it is labeledagent:claude-code,agent:codexand so on automatically, but the session is still derived fromagent), and a claim’s session is derived from the actor and worktree, so a service claimed through MCP is blocked (exit 5) when the same agent operates it through the CLI, and vice versa. If you must mix them, set the sameDEVHUB_SESSIONin the MCP server’s environment and for the CLI.