Skip to content

feat(sbx): add mocactl sbx claude, a launcher that asks nothing - #656

Merged
pdettori merged 2 commits into
rossoctl:mainfrom
pdettori:fix/577-sbx-claude-launcher
Oct 28, 2026
Merged

pdettori merged 2 commits into
rossoctl:mainfrom
pdettori:fix/577-sbx-claude-launcher

Conversation

@pdettori

Copy link
Copy Markdown
Member

Closes #577.

The problem

mocactl sbx up writes enabledMcpjsonServers: ["sandbox"] into .claude/settings.json, but that cannot suppress Claude Code's first-session trust prompt: the approval state lives in ~/.claude.json keyed on the working directory, and the prompt's highlighted default declines — writing disabledMcpjsonServers: ["sandbox"] into .claude/settings.local.json, which combined with up's deny list leaves the agent with no tools at all. #591 mitigated (warning in up, recovery in doctor) 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-config registers a server flag-scoped — no approval, no folder trust, nothing written anywhere. Verified interactively with a stub stdio server, an isolated CLAUDE_CONFIG_DIR, and a /mcp oracle:

scenario bare claude --mcp-config + --strict-mcp-config
first session in the repo prompt fires, default declines no prompt, server connected
from a subdirectory prompt fires every session no prompt, server connected
past decline (disabledMcpjsonServers) server silently dropped no prompt, server connected

The sticky toolless state heals just by starting the session this way. (Also probed and rejected: --settings with enabledMcpjsonServers does not load the server in a live session.)

mocactl sbx claude [-- CLAUDE_ARGS ...] mirrors sbx codex (#593): spawns claude --mcp-config <inline JSON> --strict-mcp-config ...user args, forwards an explicit --sandbox/--control-plane-url into the server's argv, propagates claude's exit code, and on ENOENT prints the install hint plus a copyable hand-run command. --json is 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

  • New sbx-claude.test.ts (8 tests) mirrors sbx-codex.test.ts: server registration, --sandbox forwarding, pass-through args, exit-code propagation, ENOENT message, --json refusal, --control-plane-url forwarding/omission, config JSON shape — each new assertion watched RED first (TDD)
  • sbx-up.test.ts / sbx-agent-config.test.ts assert the launcher is named in the warning and the recovery
  • Full mocactl suite: 1597 passed, 5 failed — all five (TUI overlays, push, cortex) pass in isolation, touch no changed code, and match the known full-parallel timing flakiness on this machine
  • tsc --noEmit and Prettier clean
  • Real-spawn check: a claude shim recorded the exact argv verified above and propagated the exit code

Assisted-By: Claude Code

…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]>
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Oct 28, 2026

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment thread docs/sbx/user-guide.md Outdated
(`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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@pdettori
pdettori merged commit b4b0e1b into rossoctl:main Oct 28, 2026
16 checks passed
@pdettori
pdettori deleted the fix/577-sbx-claude-launcher branch October 28, 2026 19:59
mrsabath added a commit that referenced this pull request Oct 29, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sbx up's enabledMcpjsonServers does not suppress Claude Code's trust prompt — the default declines and leaves the agent with no tools

2 participants