Skip to content

fix(mcp): phase agents receive the user's claude.ai connectors (Gmail, Docs) outside the #936 allowlist #1396

Closed

Description

@admarble

Epic: graph-2026-10-freeze-b Tier: mechanical Execution: split (exec in sequant_run; AC-1 evidence from #1451, graph doc I-6)

Problem

Phase agents receive the user's claude.ai connectors, outside the #936 phase-MCP allowlist.

Measured 2026-10-10 in #1388's baseline run (stock sequant 2.19.0, Agent SDK 0.3.289, Claude Code 2.1.289, no plugin, committed skills). The phase agent's SDK system/init message listed:

sequant                    connected   source: dynamic    (passed by the driver, allowlisted)
claude.ai Claude Docs      connected   source: claudeai
claude.ai Gmail            connected   source: claudeai
claude.ai Google Drive     needs-auth  source: claudeai
claude.ai Google Calendar  needs-auth  source: claudeai
claude.ai Figma            needs-auth  source: claudeai

#936 restricted what the driver passes in options.mcpServers (getPhaseMcpServersConfig). The SDK adds the account's claude.ai connectors separately, so the allowlist never sees them.

Failure scenario: an issue body, which isn't trusted input, instructs the agent → a phase agent running permissionMode: "bypassPermissions" reads it → it calls a connected Gmail or Docs tool (send, read, share) on the user's account with no prompt. This is the over-grant #936 closed for Claude Desktop config, reached through a source #936 doesn't cover.

Lever (measured 2026-10-16, graph doc §4 and D-3)

query() aborted at system/init, settingSources: ["project"], one dynamic server passed, on an account with connectors:

Option CC 2.1.289 CC 2.1.296
none 5 claudeai servers 5 claudeai servers
strictMcpConfig: true passed server only passed server only
settings: { disableClaudeAiConnectors: true } passed server only passed server only

Use settings: { disableClaudeAiConnectors: true }. It gates only auto-fetched claude.ai connectors. strictMcpConfig would also drop project .mcp.json, plugin and agent-frontmatter MCP, which is wider than this bug and would change what #1397/#1398 can load. The driver has one query() call (drivers/claude-code.ts:130, the only SDK import in src).

Acceptance Criteria

Prior fixes / producers

May touch

src/lib/workflow/drivers/claude-code.ts, its tests, docs/guides/mcp-integrations.md, CHANGELOG.md.

Non-Goals

  • The Codex and opencode drivers; check them separately.
  • strictMcpConfig and project .mcp.json / plugin MCP sources (graph doc D-3).
  • Any edit under plugin/, .claude/skills/ or templates/skills/ (plugin freeze).

Related: #936, #1388 (where this was measured).

Activity

  1. added
    bug
    on Oct 10, 2026
  2. admarble commented on Oct 13, 2026

    @admarble
    ContributorAuthor

    A second lever to measure for AC-3, from the 2026-10-13 upstream triage. Claude Code v2.1.290: "Fixed disableClaudeAiConnectors and allowedMcpServers URL rules not being applied to some MCP entries declared in .mcp.json, plugins or agents."

    disableClaudeAiConnectors is a candidate way to drop the source: claudeai entries from phase agents, next to strictMcpConfig. Sequant sets neither today: the driver (src/lib/workflow/drivers/claude-code.ts:130-158) passes only mcpServers, settingSources: ["project"] and bypassPermissions.

    Caveat: phase agents run the Claude Code bundled in the agent SDK. The lockfile pins 0.3.289 (= CC 2.1.289), which predates this fix. Measure on the SDK after #1440 bumps it, or the result says nothing about current behaviour.

  3. added
    graph-2026-10-freeze-b
    on Oct 16, 2026
  4. admarble commented on Oct 16, 2026

    @admarble
    ContributorAuthor

    Runner context (graph-2026-10-freeze-b, tracker #1452), for the exec and qa phases:

  5. admarble commented on Oct 16, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (3 ACs, 3 directories)

    AC Quality Check


    Scope Assessment

    Non-Goals: present (Codex/opencode drivers, strictMcpConfig and project/plugin MCP, plugin freeze paths).

    Metric Value Status
    Feature count 1 ✅
    AC items 3 ✅
    Directory spread 3 (src/lib/workflow/drivers, docs/guides, CHANGELOG.md) ✅

    Verdict: ✅ SCOPE_OK


    Acceptance Criteria

    AC-1: No source: "claudeai" entry in a phase agent's init.mcp_servers; sequant and mcpAllowlist servers still listed

    Verification: Manual Test (external evidence from #1451)
    Scenario: Given a dist/ build of main on an account with connectors → When a phase agent runs → Then the system/init list shows only allowlisted servers.
    Assumptions: The SDK build the phase agents run honours disableClaudeAiConnectors (measured on CC 2.1.289 and 2.1.296). The Settings type already declares it (sdk.d.ts:7004). Exec and qa cannot observe this: MCP phases run the npm-pinned 2.19.0.

    AC-2: Driver passes settings: { disableClaudeAiConnectors: true } and nothing later overrides it

    Verification: Unit Test (declared evidence, so testgen is not needed)
    Scenario: Given the driver runs a phase, with MCP on and with MCP off → When query() is called → Then options.settings.disableClaudeAiConnectors === true.
    Assumptions: settings accepts an inline Settings object (sdk.d.ts:2231, string | Settings).

    AC-3: Docs say claude.ai connectors are off for phase agents, and how

    Verification: Manual Test (grep -n "disableClaudeAiConnectors" docs/guides/mcp-integrations.md)
    Scenario: Given the docs → When grepped → Then at least one line matches, inside the headless/phase-agent explanation.


    Implementation Plan

    Phase 1: Driver

    1. In src/lib/workflow/drivers/claude-code.ts (the query() options, ~line 134), add settings: { disableClaudeAiConnectors: true } as an unconditional key. Place it before any spread (...(mcpServers…), ...(config.model…)) or after only keys that cannot carry settings, so no later key replaces it (AC-2 clause 2). Add a short intent comment citing fix(mcp): phase agents receive the user's claude.ai connectors (Gmail, Docs) outside the #936 allowlist #1396 and fix(mcp): phase agents receive the user's entire Claude Desktop config — capability over-grant + literal secrets in argv #936. Do not add strictMcpConfig (Non-Goal).

    Phase 2: Test

    1. In src/lib/workflow/drivers/claude-code.test.ts, next to the existing callOptions.mcpServers tests (~line 109), add two cases. One has mcp: true, one has mcp: false. Each asserts callOptions.settings toEqual({ disableClaudeAiConnectors: true }). Run the file under timeout 600.
    2. Mutation: remove the option, confirm exactly those cases fail, restore. Record Mutation-verified: AC-2 — remove settings option from query() call; src/lib/workflow/drivers/claude-code.test.ts > ClaudeCodeDriver > <case> failed; restored. in the PR body with the SEQUANT_MUTATION marker. The failedTest starts with the file path.

    Phase 3: Docs and changelog

    1. In docs/guides/mcp-integrations.md, add a short paragraph after line 38's .mcp.json note (keep it local to ease the merge with PR docs(a11y): WCAG 2.1 AA fixes for the published docs #1438): phase agents also have the account's claude.ai connectors (Gmail, Docs, …) switched off through settings: { disableClaudeAiConnectors: true }; interactive Claude Code is unaffected. Name strictMcpConfig as not used.
    2. Add a CHANGELOG.md entry under Unreleased (check whether the repo uses fragments, improve(release): changelog fragments instead of a shared [Unreleased] block — 121/192 main commits touch CHANGELOG.md #1351, first).

    Design Review

    1. Where does this logic belong? In the driver's single query() call, the only SDK import in src. getPhaseMcpServersConfig only builds the mcpServers the driver passes, and the connectors come from a different source.
    2. Simplest correct approach? One constant option key. Rejected: strictMcpConfig, which also drops project .mcp.json, plugin and agent MCP and would change what investigation(run): verify a skills-only plugin view loads phase skills without hooks or MCP (ADR-0012 follow-up 1) #1397/feat(run): load phase skills from the installed package when the project doesn't commit them (ADR-0012 follow-up 2) #1398 can load. Also rejected: an env flag or a settings knob, since there is no case for leaving connectors on in a bypassPermissions agent.
    3. Existing pattern and re-patch count? The pattern is the fix(mcp): phase agents receive the user's entire Claude Desktop config — capability over-grant + literal secrets in argv #936 allowlist. git log -S'disableClaudeAiConnectors' shows only docs commits (docs: Upstream assessment for v2.1.296 #1437, docs(graph): graph-2026-10-freeze-b — freeze-safe fixes, second batch (tracker #1452) #1453). Prior fix issues on this artifact: fix(mcp): phase agents receive the user's entire Claude Desktop config — capability over-grant + literal secrets in argv #936 only (one), so this is not a ≥2 recurrence stop. The class is "SDK-side MCP sources", and this closes the claude.ai source. Project .mcp.json and plugin sources are unmeasured and tracked as Non-Goals.
    4. What would a senior reviewer challenge? "Why not strictMcpConfig?" (answered above). "Does the setting survive settingSources: ['project']?" That is measured in the issue table. "Can a project settings file turn connectors back on?" The inline settings flag layer sits above project settings, which AC-1 evidence from smoke(graph-2026-10-freeze-b): a main build's phase agent has no claude.ai connectors, runs CC ≥ 2.1.296, and starts a fresh-clone worktree from the PR branch #1451 covers.
    5. Producers and consumers. The producers of a phase agent's MCP set are the driver's mcpServers (the only query() call, claude-code.ts) and the SDK's own sources. Consumers are every phase agent. Codex and opencode drivers have their own paths (Non-Goal). Only one producer is touched here, so no parity test is needed.

    Feature Quality Planning

    All standard checks pass. Notable items:


    Open Questions

    1. Does a user ever need connectors in a phase agent? — Recommendation: no, ship unconditional. Impact if wrong: they would need a settings opt-out, which is a follow-up.
    2. Codex/opencode equivalents — Recommendation: separate follow-up check, as the issue says.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled
    Reasoning: one-line option plus a test and a docs paragraph. AC-2 declares unit-test evidence, but a two-case test does not need stubs, so testgen is skipped. No UI, so no test phase. The issue's Execution: split means exec runs in sequant_run.

    Label Review

    Current: bug, graph-2026-10-freeze-b
    Recommended: bug, graph-2026-10-freeze-b, planned
    Reason: no change beyond planned.
    Quality Loop: won't auto-enable (SCOPE_OK).

  6. added
    planned
    on Oct 16, 2026
  7. admarble commented on Oct 16, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

    AC coverage: 2/3 met

    Gaps:

  8. added a commit that references this issue on Oct 16, 2026
  9. admarble commented on Oct 16, 2026

    @admarble
    ContributorAuthor

    AC-1 is proven post-merge by #1451's smoke on a main build (main @ 9f1fb3f): the phase agent's system/init lists only [{"name":"sequant","status":"connected","source":"dynamic"}], with no claudeai connectors, on an account that has them (#1451 (comment)). The fix landed in PR #1464. Closed with owner consent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggraph-2026-10-freeze-bplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions