Repository navigation
feat(sbx): add mocactl sbx claude, a launcher that asks nothing - #656
Conversation
…octl#577) Claude Code's approval of a project-scoped .mcp.json server lives in ~/.claude.json keyed on the working directory, so sbx up's enabledMcpjsonServers cannot suppress the first-session prompt — and the prompt's highlighted default declines, which together with up's deny list leaves the agent with no tools (rossoctl#577, rossoctl#591). Add `mocactl sbx claude [-- CLAUDE_ARGS ...]`, mirroring `sbx codex` (rossoctl#593): it spawns claude with --mcp-config <inline JSON> and --strict-mcp-config, registering the sandbox's MCP server for that one run. Flag-scoped servers need no approval and write nothing, so no prompt fires from any directory, and a past decline's disabledMcpjsonServers cannot reject the server — the toolless state heals by just starting the session this way. Verified against claude 2.1.308 from the repo root, from a subdirectory, and over a sticky decline; --strict-mcp-config's prompt skip needs claude >= 2.1.246. The trade is the one up's deny list already makes: the session loads no MCP server but the sandbox's. An explicit --sandbox or --control-plane-url is forwarded into the server's argv; the env-var URL case needs no help, as Claude Code passes its whole environment to a stdio server. up's post-config warning and doctor's recovery now name the launcher, and the user guide documents it as the prompt-free way to start Claude Code. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Summary
Adds mocactl sbx claude [-- CLAUDE_ARGS …], which spawns claude --mcp-config '<inline JSON>' --strict-mcp-config … so the sandbox server is flag-scoped. Claude Code asks no MCP approval, nothing is written, and a past disabledMcpjsonServers decline no longer applies. It mirrors sbx codex exactly: an explicit --sandbox/--control-plane-url (normalized ctx.url) is forwarded into the server argv, the exit code is propagated, an ENOENT gives a copyable hand-run command, and --json is refused through NO_JSON. The CLI wiring (NO_JSON, TAKES_SANDBOX_FLAG, the command list, argsOk pass-through) matches codex's. Without --sandbox, the binding check still finds .sbx/sandbox.json upward from cwd before launching. User args come after --strict-mcp-config, so the variadic --mcp-config can't swallow them.
I probed claude 2.1.308 (the version the PR verified against) with a stub server. The MCP-approval removal holds: bare claude at a trusted root shows "New MCP server found in this project", and the launcher shows nothing. The folder-trust dialog is still asked in a folder that has never been trusted, though, so the docs/usage claim of "nothing asked" is too strong (inline). Not blocking.
Author: pdettori (MEMBER — maintainer)
Areas reviewed: TypeScript (mocactl sbx CLI), tests, docs
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing (all checks)
| (`bash`, `read`, `write`, `edit`, `grep`, `find`, `ls` and `sandbox_info`); its local tools are | ||
| denied. | ||
|
|
||
| Or start Claude Code through `mocactl` and skip the questions: |
There was a problem hiding this comment.
suggestion: The launcher skips the MCP-server approval question, but it doesn't skip Claude Code's folder-trust dialog. So "skip the questions" here, "nothing asked" at :119, and the usage text's "the first bare claude session's approval question and its folder trust are why this exists" (cli.ts:68-70) promise more than the flags do.
I probed this with an isolated CLAUDE_CONFIG_DIR (onboarding done, API key pre-approved) and a stub stdio server named sandbox in both --mcp-config and the repo's .mcp.json, on claude 2.1.308 and 2.1.284:
~/.claude.json state |
cwd | claude --mcp-config '…' --strict-mcp-config |
|---|---|---|
| folder never trusted | repo root | "Quick safety check: Is this a project you created or one you trust?" (default ❯ No, exit) |
| folder never trusted | subdirectory | same trust dialog |
| root trusted | subdirectory | no dialog at all ✔ |
| root trusted | root (bare claude, for contrast) |
"New MCP server found in this project" ✔ (the question the launcher removes) |
So the launcher does what matters for #577. It removes the MCP question and the sticky decline, and once the root is trusted it works from any subdirectory, because trust is inherited from the parent. But a brand-new machine or repo still gets one trust question, and pressing Enter on it exits. It's harmless (nothing is written, re-run and pick "Yes"), but the docs say there won't be a question at all.
Suggested wording: "…and skip the MCP server question (Claude Code still asks once whether you trust the folder, if you haven't already)". Mirror that in the usage text and in the claude.ts header (claude.ts:8-20, which says the trust gate is why the launcher exists).
There was a problem hiding this comment.
Fixed in 02b2a9a. My own early probes hit that same trust dialog (default "No, exit") and I seeded hasTrustDialogAccepted to get past it for the A/B tests — so the never-trusted-folder case was worked around rather than covered, and the wording inherited the blind spot.
Every "asks nothing" is now "asks nothing about the server" plus the trust caveat, in all five places: the usage text, the claude.ts header (which also no longer claims folder trust is why this exists), up's warning — now pinned by a test asserting it says "trust the folder" — and both user-guide sections. The §3 heading is "skip the MCP server question", and the closing section is "mocactl sbx claude asks none of this but the folder trust.", with your probe's shape spelled out: once per folder, default exits, answering yes records it and subdirectories inherit it. The doctor recovery already said only that the server loads without asking, so it was left as it was.
Verified: 174/174 across sbx-up, sbx-claude, sbx-agent-config; tsc --noEmit and Prettier clean.
…uestion (rossoctl#656) The launcher's flags remove the MCP approval question, not Claude Code's folder-trust dialog: a never-trusted folder gets it once whatever is passed, and its highlighted default exits. "Nothing asked" promised more than the flags do (rossoctl#656 review, probed on claude 2.1.308 and 2.1.284). Every message and doc now says "asks nothing about the server" and names the trust question: the usage text, the claude.ts header, up's warning (now test-pinned), and both user-guide sections. The doctor recovery already said only that the server loads without asking, so it stands. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Self-review of #662. The table listed Claude Code's wiring as only "`up` writes .mcp.json + .claude/settings.json", so a reader meeting it first would conclude Claude Code has no launcher while Codex does. `mocactl sbx claude` exists (#656) and the guide covers it twenty lines further down — and `up`'s own closing output recommends it as the way past the first session's approval prompt (#577), which makes the omission worse than a missing row: it hides the fix for the trap the surrounding text warns about. Also drops the "Four are supported" count. It is a maintenance trap: the next agent makes the prose wrong while the table silently stays right. And "The first two need nothing beyond `up`" now names them, since row order is no longer what makes that sentence true. check-links 212 files / 0 broken; prettier clean. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Mariusz Sabath <[email protected]>
Closes #577.
The problem
mocactl sbx upwritesenabledMcpjsonServers: ["sandbox"]into.claude/settings.json, but that cannot suppress Claude Code's first-session trust prompt: the approval state lives in~/.claude.jsonkeyed on the working directory, and the prompt's highlighted default declines — writingdisabledMcpjsonServers: ["sandbox"]into.claude/settings.local.json, which combined withup's deny list leaves the agent with no tools at all. #591 mitigated (warning inup, recovery indoctor) but the prompt itself remained unavoidable — and it refires from any subdirectory, after which the unapproved server is silently dropped.The fix
Re-probing against claude 2.1.308 (the #591 probe was 2.1.263) found the missing lever:
--mcp-config '<inline JSON>' --strict-mcp-configregisters a server flag-scoped — no approval, no folder trust, nothing written anywhere. Verified interactively with a stub stdio server, an isolatedCLAUDE_CONFIG_DIR, and a/mcporacle:claude--mcp-config+--strict-mcp-configdisabledMcpjsonServers)The sticky toolless state heals just by starting the session this way. (Also probed and rejected:
--settingswithenabledMcpjsonServersdoes not load the server in a live session.)mocactl sbx claude [-- CLAUDE_ARGS ...]mirrorssbx codex(#593): spawnsclaude --mcp-config <inline JSON> --strict-mcp-config ...user args, forwards an explicit--sandbox/--control-plane-urlinto the server's argv, propagates claude's exit code, and on ENOENT prints the install hint plus a copyable hand-run command.--jsonis refused (a TUI prints none). The env-var URL case needs no help — Claude Code passes its whole environment to a stdio server (#639 was Codex-specific).The trade is the one
up's deny list already makes: the session loads no MCP server but the sandbox's.--strict-mcp-config's prompt skip needs claude ≥ 2.1.246 (verified against 2.1.308); the user guide notes it.up's post-config warning and doctor's toolless-state recovery now name the launcher.Testing
sbx-claude.test.ts(8 tests) mirrorssbx-codex.test.ts: server registration,--sandboxforwarding, pass-through args, exit-code propagation, ENOENT message,--jsonrefusal,--control-plane-urlforwarding/omission, config JSON shape — each new assertion watched RED first (TDD)sbx-up.test.ts/sbx-agent-config.test.tsassert the launcher is named in the warning and the recoverytsc --noEmitand Prettier cleanclaudeshim recorded the exact argv verified above and propagated the exit codeAssisted-By: Claude Code