Skip to content

fix(#936): phase agents get an .mcp.json allowlist instead of the full Claude Desktop config - #952

Merged
admarble merged 5 commits into
mainfrom
feature/936-fix-mcp-phase-agents-receive-the-user-s-entire
Aug 20, 2026
Merged

admarble merged 5 commits into
mainfrom
feature/936-fix-mcp-phase-agents-receive-the-user-s-entire

Conversation

@admarble

@admarble admarble commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Phase agents (sequant run / /fullsolve) previously inherited the user's entire Claude Desktop config via getMcpServersConfig(), including capability over-grant and literal secrets serialized into the child process's --mcp-config argv (Claude Desktop configs can't use ${VAR} expansion).
  • Replaces the passthrough with an allowlist: getPhaseMcpServersConfig() in src/lib/mcp-config.ts unions the project's own .mcp.json (secret-free, committed to git) with a guaranteed sequant entry, and never reads claude_desktop_config.json by default. Wired at the single driver call site, claude-code.ts:119 — covers every phase path (sequant run, sequant ready, /fullsolve) since both ExecutionConfig producers funnel into this driver.
  • getMcpServersConfig() (desktop-reading) is kept for doctor's interactive diagnostics only; its docstring warns against reuse for phase execution.
  • settings.run.mcpAllowlist — the explicit per-server opt-in the issue itself proposed as a fallback — lets a project pass specific named Claude Desktop servers through to phases anyway, when a server genuinely has no .mcp.json home yet. A name not present in the desktop config is silently ignored; project .mcp.json entries and the sequant server always win over an allowlisted desktop entry of the same name.
  • doctor's "MCP Servers (headless)" check now calls getPhaseMcpServersConfig (the same builder phases use) instead of reading Claude Desktop config directly — it always passes (sequant is guaranteed) and reports the real server count/source.
  • Docs: rewrote the MCP Server Support section in run-command.md and the Installation section in mcp-integrations.md, added an "Allowlisting a Desktop-Only Server" section with the security caveat.

Pre-PR AC Verification

AC Source Description Status Evidence
AC-1 Original Phase agent MCP config excludes all servers beyond sequant + project .mcp.json entries ✅ Implemented mcp-config.ts:getPhaseMcpServersConfig (never reads desktop config by default); mcp-config.test.ts "excludes desktop servers…" + claude-code.test.ts "passes the phase allowlist to query()"
AC-2 Original No secret-bearing desktop env values appear in phase argv ✅ Implemented mcp-config.test.ts "never leaks secret-bearing desktop env values…" — asserts JSON.stringify(result) excludes a literal fake secret
AC-3 Original Docs describe run.mcp as sequant-server injection, not desktop passthrough ✅ Implemented run-command.md MCP Server Support section + mcp-integrations.md Installation section rewritten; settings.ts/system.ts docstrings updated
AC-4 Derived (docs coverage) mcp-integrations.md instructs declaring optional MCPs in project .mcp.json, not desktop config ✅ Implemented Installation section rewritten with .mcp.json examples; troubleshooting note added
AC-5 Follow-up (gap fix) settings.run.mcpAllowlist opt-in — a named server passes through only when explicitly allowlisted, and never overrides project .mcp.json/sequant ✅ Implemented mcp-config.test.ts "desktopAllowlist opt-in (#936)" (5 cases); threaded through config-resolver.ts, ready-gate.ts/ready.ts, claude-code.ts with dedicated tests at each hop
AC-6 Follow-up (gap fix) doctor's headless MCP check reports on the same source phases actually use ✅ Implemented doctor.ts now calls getPhaseMcpServersConfig; doctor.test.ts "MCP Servers (headless) check (#936)" (2 cases)

Test plan

  • npm run build — passes
  • npm run lint — passes (0 errors)
  • npm test — full suite: 268 files, 5512 passed, 1 expected fail (pre-existing), 2 skipped
  • Unit tests: mcp-config.test.ts (11 new cases total — 6 for the base allowlist, 5 for desktopAllowlist), claude-code.test.ts (3 new cases), doctor.test.ts (2 new cases), ready-gate.test.ts (2 new cases), ready.test.ts (1 new case), config-resolver.mcp-allowlist.test.ts (2 new cases, new file)
  • Mutation-verified all 6 gate-worthy claims (see markers below) — each mutation isolated to exactly its intended test(s), confirmed and restored

Known gaps

None outstanding. Both gaps disclosed in the original review pass (doctor drift, deferred mcpAllowlist) are now implemented above.

Closes #936

…cp.json allowlist for phase agents (#936)

Phase agents inherited the user's entire Claude Desktop config via
getMcpServersConfig(), including servers with literal secrets (desktop
configs cannot use ${VAR} expansion) that the SDK serializes into the
child process's --mcp-config argv.

Adds getPhaseMcpServersConfig() in mcp-config.ts, which unions the
project's own .mcp.json (secret-free, committed to git) with a
guaranteed sequant entry, and never reads claude_desktop_config.json.
Rewires the single driver call site (claude-code.ts). doctor.ts keeps
using getMcpServersConfig() for interactive diagnostics only.
…passthrough (#936)

Rewrites the MCP Server Support section in run-command.md and the
Installation section in mcp-integrations.md, which previously
instructed adding optional MCPs to Claude Desktop config for use with
sequant run. Notes the doctor headless check still reports on desktop
config and hasn't caught up with this change (tracked separately).
Addresses two gaps disclosed but deliberately deferred in the original
#936 fix:

1. settings.run.mcpAllowlist lets a project opt specific Claude Desktop
   MCP server names into phase execution, per the issue's own proposed
   fallback design. getPhaseMcpServersConfig gains a desktopAllowlist
   option; project .mcp.json entries and the sequant entry always win
   over an allowlisted desktop entry of the same name. Threaded through
   both ExecutionConfig producers (config-resolver.ts, ready-gate.ts via
   commands/ready.ts) into AgentExecutionConfig, matching the existing
   #914 model/effort producer-parity pattern.

2. doctor's "MCP Servers (headless)" check read Claude Desktop config
   directly (getMcpServersConfig) and could warn "not available" even
   though phase agents always get at least the sequant server post-#936.
   Now calls getPhaseMcpServersConfig — the same builder phases actually
   use — and always reports pass with an accurate server count/source.
…ucers

Closes the coverage gap between buildExecutionConfig / commands/ready.ts
reading settings.run.mcpAllowlist and ready-gate.ts's own downstream
forwarding test — without this, a producer that silently dropped the
field would go undetected.
…P check

Adds an "Allowlisting a Desktop-Only Server" section to run-command.md
with the security caveat (literal secrets, ps visibility), a settings
table row, a mention in mcp-integrations.md's Installation section, and
updates the earlier "doctor hasn't caught up" notes now that doctor's
headless check reads getPhaseMcpServersConfig instead of desktop config.
@admarble
admarble merged commit 1ae9cd1 into main Aug 20, 2026
5 checks passed
@admarble
admarble deleted the feature/936-fix-mcp-phase-agents-receive-the-user-s-entire branch August 20, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(mcp): phase agents receive the user's entire Claude Desktop config — capability over-grant + literal secrets in argv

1 participant