claude --bg returns success but the session waits at the .mcp.json approval dialog; check pending project-server approval like workspace trust

Status Open
Reported on v2.1.281
Maintainer reply None cached
Activity 0 comments · opened Oct 9, 2026

Problem

Since 2.1.281, claude --bg checks workspace trust before it dispatches, and when no dialog can appear it exits with Workspace not trusted. It does not check project .mcp.json server approval.

In a trusted repository with unapproved .mcp.json servers, a scripted claude --bg "<task>" therefore prints backgrounded · <id> and returns success. The session then waits at the "N new MCP servers found in this project" selection dialog until someone attaches. The task never starts, and the caller can't tell from the launch result.

Repro (2.1.295, Windows 10, PowerShell; also seen on 2.1.289)

  1. A git repository whose root is trusted (hasTrustDialogAccepted: true for it in ~/.claude.json) and has a committed .mcp.json with two servers. Neither is approved: its projects entry has enabledMcpjsonServers: [] and disabledMcpjsonServers: [], and no settings file approves them.
  2. From a script in that root, run claude --bg --model haiku --name mcp-probe "Reply with the single word OK."
  3. It prints backgrounded · 9f327486 · mcp-probe and exits 0.
  4. claude logs 9f327486 shows the "2 new MCP servers found in this project … Space to select · Esc to reject all" dialog.
  5. claude agents --json reported "state": "working" 45 s after launch and "state": "blocked" about a minute later.

The same happens for a --bg session started in a linked worktree of that repository.

Expected / proposed

Treat pending project-server approval like the trust check that 2.1.281 added:

  • When --bg (or a restart) can't show a dialog, either exit with an error that names the pending servers and the folder to run claude in, or start the session with those servers left unconnected and a warning.
  • Report the waiting state as blocked (needs input) right away, not as working first.

A read-only way to ask "would this folder start unattended?" (trust plus pending MCP approvals) would also help orchestrators. #79707 asks for something similar for trust.

Notes

  • -p is no workaround, because it connects unapproved servers without asking (MCP project scope).
  • --strict-mcp-config avoids the wait only by dropping project servers entirely.
  • The docs mention background sessions waiting on approval only for the pre-2.1.246 --strict-mcp-config case.

Related: #98006 (pre-trust setting for scripted --bg), #79707.

View original on GitHub ↗