Skip to content

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

Closed

Description

@mrsabath

sbx up writes enabledMcpjsonServers: ["sandbox"] into .claude/settings.json to pre-approve the sandbox MCP server, and sbx doctor checks that same key. On a fresh clone the key does not suppress Claude Code's trust prompt: the user is still asked, the highlighted default declines, and declining leaves the agent with no tools at all.

Observed on a first session, mocactl sbx up run from a clean clone of rossoctl/moca-experiments.

What up wrote (correct, per the user guide)

.mcp.json and .claude/settings.json, both at the git root, timestamped together:

$ ls -la .mcp.json .claude/
-rw-r--r--@ 1 sabath staff 130 Oct 21 20:39 .mcp.json
-rw-r--r--@ 1 sabath staff 429 Oct 21 20:39 .claude/settings.json
// .mcp.json
{ "mcpServers": { "sandbox": { "command": "mocactl", "args": ["sbx", "mcp"] } } }
// .claude/settings.json  (abridged)
{
  "permissions": { "allow": ["mcp__sandbox__*"], "deny": ["Bash", "Read", "Edit", "Write", "…"] },
  "enabledMcpjsonServers": ["sandbox"]
}

This matches agent-config.ts:976 and the up table in docs/sbx/user-guide.md.

What the user still sees

New MCP server found in this project: sandbox

  Use this MCP server
  Use this and all future MCP servers in this project
❯ Continue without using this MCP server

Claude Code did read the root config — the session was launched from a subdirectory with no .mcp.json or .claude/ of its own, so discovery traversed up to the root and found the file up wrote. The prompt appeared anyway.

Global state was empty, so nothing there caused it:

$ jq '.projects["/Users/sabath/workspace/rossoctl/moca-experiments"]
      | {enabledMcpjsonServers, enableAllProjectMcpServers, disabledMcpjsonServers}' ~/.claude.json
{ "enabledMcpjsonServers": [], "enableAllProjectMcpServers": null, "disabledMcpjsonServers": [] }

No prior approval, no prior rejection. The only pre-approval in play was up's key in .claude/settings.json, and it did not take effect. There are reports upstream that enabledMcpjsonServers in .claude/settings.json / settings.local.json is not consulted for servers defined in .mcp.json — anthropics/claude-code#24657 and #16402 — which matches this behaviour, though I have not confirmed the upstream mechanism from official docs.

Why this is more than an extra keystroke

The default is the decline. Accepting it writes a persistent rejection:

$ cat .claude/settings.local.json
{ "disabledMcpjsonServers": ["sandbox"] }

Combined with the permissions.deny list up writes, that is precisely the state writeAgentConfig refuses to create (agent-config.ts:915-921):

rejects the sandbox MCP server, so Claude Code would have no tools

So a user who presses Enter gets an agent with no sandbox tools and no local tools. settings.local.json is never rewritten by up, and the marker suppresses the prompt on subsequent runs, so the broken state is sticky and self-concealing. The recovery — delete .claude/settings.local.json — is not discoverable from any message the user sees.

This is also the first thing a reader does in the sbx/demo exercise (rossoctl/moca-experiments#16), so it lands on step one of the onboarding path.

doctor reports healthy

checkAgentConfig (agent-config.ts:1226-1234) accepts enabledMcpjsonServers containing sandbox as sufficient:

Claude Code: .claude/settings.json enabledMcpjsonServers does not list sandbox, so Claude Code asks before loading it

The diagnosis is exactly right and the remedy it validates does not work, so doctor passes while the prompt still fires. enableAllProjectMcpServers is read in the same check but never written by up (it appears nowhere else in the package), and up writes neither settings.local.json nor ~/.claude.json.

Suggested direction

Deferring to you on the approach — the options I can see:

  1. Write the approval where Claude Code reads it. If the project entry in ~/.claude.json (projects[<abs path>].enabledMcpjsonServers) is the effective location, up would need to write there. That is outside the working tree, so it breaks up's present "ordinary files in your working tree, which git status shows" property and needs a matching entry in takeBackAgentConfig / removeAgentConfig.
  2. Keep the key, fix the expectation. Leave settings.json as is, and have up's final output tell the user the prompt is coming, that the default declines, and which option to pick. Cheap, no new state, and the guide gains a line.
  3. Detect and repair. Have doctor flag disabledMcpjsonServers in settings.local.json as the actionable "delete this file" state. It already inspects that file (lines 1235-1242), so this may be a wording change rather than new logic.

(2) plus (3) looks like the smallest change that stops users landing in the toolless state. Happy to send a PR for whichever you prefer, including the user-guide wording — docs/sbx/user-guide.md documents the key in the up table but never mentions the trust prompt, its default, or the recovery.

Activity

  1. self-assigned this
    on Oct 22, 2026
  2. cwiklik commented on Oct 22, 2026

    @cwiklik
    Contributor

    Picked this up — PR #591 implements your (2) + (3). One correction to the diagnosis first, since
    it changes what the fix can say.

    enabledMcpjsonServers in .claude/settings.json is consulted, and it does work. I probed
    this against claude 2.1.263 with a stub stdio MCP server named sandbox, claude mcp list as
    the oracle (⏸ Pending approval vs ✔ Connected), isolated HOME, reset between cases. There
    are two independent gates and both must hold:

    folder trust (~/.claude.json → projects[cwd].hasTrustDialogAccepted) enable key prompt
    absent settings.json enabledMcpjsonServers: [sandbox] fires
    absent settings.local.json enabledMcpjsonServers fires
    absent settings.json enableAllProjectMcpServers: true fires
    absent projects[cwd].enabledMcpjsonServers fires
    accepted (none anywhere) fires
    accepted any one of the four above suppressed

    So the key is necessary but not sufficient. The other half is folder trust, and that lives in
    ~/.claude.json where only the user's own answer to the trust dialog puts it — no in-tree key
    grants it (hasTrustDialogAccepted, trustedFolder, trustFolder, autoApproveMcpServers in
    settings.json all still prompt). Also worth noting: the empty
    projects[...].enabledMcpjsonServers: [] in your jq output does not override a populated
    settings.json, so global state really was not the cause.

    The trigger is in your report already: you note the session was launched from a subdirectory.
    Both gates are keyed on the directory claude started in, while .mcp.json is found by
    searching upwards — so a subdirectory session finds the server and has no approval for it:

    case cwd prompt
    cwd is the dir holding the config git root suppressed (with trust)
    cwd is a subdir, trust on the subdir repo/pkg/deep fires
    cwd is a subdir, trust on subdir and root repo/pkg/deep fires
    cwd is a subdir, .mcp.json copied beside cwd repo/pkg/deep fires
    cwd is a subdir, projects[<git root>] trust + enable repo/pkg/deep suppressed
    cwd is its own git root, nested under another repo nested root suppressed

    A nested directory that is its own git root works fine, so the discriminator is "cwd is not the
    directory holding the config", not nesting depth. up writes at the git root, so whatever it
    writes cannot help a session started below it. Incidentally, the upstream issues you cite
    (anthropics/claude-code#24657, #16402) are both closed as duplicates of #5037 (completed) and are
    about settings.local.json — they do not describe this.

    That rules out your option (1): the missing half is folder trust, so "write the approval where
    Claude Code reads it" means recording a trust decision on the user's behalf, outside the tree.
    That is a security decision rather than a config fix, and I did not want up making it.

    So #591 is (2) + (3), plus one bug your writeup did not mention. doctor's fix line was
    mocactl sbx up merges it again (anything it names as a conflict is for you to fix by hand) —
    a dead end for exactly this state, because up never writes settings.local.json and
    writeAgentConfig throws rather than merge over the rejection. doctor diagnosed the toolless
    state and then pointed at a remedy guaranteed to fail. It now carries the recovery itself:

    Claude Code: .claude/settings.local.json disabledMcpjsonServers rejects the sandbox MCP server,
    so the agent has neither the sandbox's tools nor its own; delete .claude/settings.local.json
    (mocactl sbx up never writes it) and answer "Use this MCP server" the next time Claude Code asks
    

    up now also warns, right after writing the config, that the first session will ask, that the
    highlighted default declines, which option to pick, and to start claude in the root. The user
    guide's "why" is corrected and the subdirectory case documented — thanks for flagging that the
    guide never mentioned the prompt, its default or the recovery.

    The prompt still appears once on a first session; it cannot be suppressed from inside the tree.
    Accepting the folder trust and the server once ends it.

  3. added a commit that references this issue on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions