Skip to content

mcpx confirmation gate makes projected tools unusable in headless/API sessions — including read-only tools #6116

Closed

Description

@dezren39

mcpx confirmation gate makes projected tools unusable in headless/API sessions — including read-only tools

Found by the 2026-11-05 tool-call audit (evidence: ~/workspace/scratch/toolcall-audit-2026-11-04/live-tests.md).

Every mcpx projected-tool execution is confirmation-gated by the mcpx daemon: executions return "… may be destructive and was not confirmed: the answer was cancel" / "nobody answered within 45s" (HTTP 502). The confirmation is not an OpenCode session permission and not a session form (a form-answering harness answered 0 forms). In headless API-driven sessions — the fleet's normal mode — nothing can answer it, so every projected tool execution lands as an error result, including manifestly read-only tools (observed: fff.find_files gated identically).

Effect on the provider/tool-call layer: the call → result → next-turn loop completes, but the "result" is always the gate error, so models either report failure or (worse) quote the requested values as if they were results. The native execute tool is not gated, which makes the boundary invisible until a projected tool is actually needed.

Ask

  • A session-scoped (or policy-scoped) approval path for projected tools that a headless session can actually use: e.g. mcpx policy distinguishing read-only vs destructive tools (read-only execute without interactive confirmation), and/or a pre-authorized tool allowlist per session/project that the daemon honors.
  • Until then: the gate error should be distinguishable from a tool failure in the result the model sees (it currently reads as a generic execution error).

Acceptance: a headless API session can execute a read-only projected tool end-to-end and receive its genuine result; destructive tools still require a confirmation that has a real answerer in the session's mode.

Acceptance criteria

  • A headless API session can execute a read-only projected tool (e.g. fff.find_files) end-to-end and receive its genuine result — no interactive confirmation required for read-only tools under the policy.
  • Destructive projected tools still require a confirmation that has a real answerer in the session's mode (session/project allowlist or policy-scoped approval the daemon honors).
  • The gate error, when it does fire, is distinguishable from a generic tool execution failure in the result the model sees.

Activity

  1. developing-today commented on Nov 5, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    priority/highImportant and time-sensitive
    effort/mMedium: expected under 1 day of work
    meta/enrichedIntake review done: acceptance criteria, links, and normalized labels added
    on Nov 5, 2026
  3. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    Intake review

    • Related: the 2026-11-05 tool-call audit live tests (~/workspace/scratch/toolcall-audit-2026-11-04/live-tests.md); claude-code-proxy + commandcode-proxy cannot emit client tool calls — and degrade silently (finish_reason stop + prose) #6117 (the sibling silent-degradation finding from the same audit — here the loop completes but the 'result' is always the gate error).
    • Still live: verified at intake from the body's live evidence — every projected-tool execution, including read-only fff.find_files, returns the confirmation-gate error in headless sessions (45s no-answer / cancel), and the gate is neither an OpenCode permission nor a session form.
    • Notes: the boundary is invisible because the native execute tool is not gated — a session only discovers the gate when it actually needs a projected tool, and models may quote requested values as if they were results. Two separable asks: a headless-usable approval policy (read-only vs destructive), and a distinguishable gate error until then.
    • Risks: an allowlist that silently widens to destructive tools would trade a usability bug for a safety hole; the acceptance keeps destructive confirmation mandatory with a real answerer.
    • Suggested approach: ship the distinguishable error first (small, immediate), then the read-only/destructive policy split in mcpx with a per-session/project allowlist.
  4. added
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 5, 2026
  5. added a commit that references this issue on Nov 5, 2026
  6. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    Fixed — merged in PR #6265 (merge commit 4e6cdb92fd), pending coordinator deployment

    Where the gate lives

    In the mcpx daemon (pkgs/mcpx/internal/daemon/consumer.go), not in OpenCode and not in any session permission/form:

    • applyWritePolicy — policy.write defaults to ask (internal/defaults/defaults.json). A call is a write unless its tool is annotated readOnlyHint: true, read with the MCP specification's defaults.
    • confirmDestructive — the elicit.confirmDestructive floor (off by default).

    fff-mcp publishes no annotations at all (verified live against the running binary: find_files / grep / multi_grep all return annotations: null), so every fff call classified as a possibly-destructive write and was gated under the default ask policy. Interactive callers can answer the broker question; headless/API sessions have no answerer, so the call returned the gate error — as HTTP 502, indistinguishable from an upstream tool failure.

    Policy implemented

    • Operator-declared read-only tools execute with no gate. New per-server mcpx.readOnlyTools (exact tool names, never patterns). The declaration is the operator's own word in local config — trusted outright, the same trust mcpx conformance: annotation trust — untrusted upstream annotations must not decide the destructive-confirmation gate (split of #1957) #2191 gives a locally declared stdio server's annotations. A server cannot declare its own tools read-only this way, and a remote server's annotations still clear nothing. A declared tool is classified read-only by the write-policy gate in every mode (ask/allow/deny), clears the confirmDestructive floor, and is exempt from the unknown-outcome write ledger.
    • Everything not declared keeps the gate, exactly as before. Undeclared tools keep the specification's defaults (unannotated = possibly destructive write); destructive tools still require a confirmation. The list never widens silently: a tool a server adds later, under a new name, is gated until the operator lists it.
    • A gated call returns a clear, typed refusal — never a fake result. ErrNotConfirmed now answers HTTP 403 (was 502), and call error bodies carry a machine-readable code: confirmation_required for an unconfirmed call, write_policy_denied for a policy denial. Genuine tool failures keep 502 + upstream, no code.
    • Fleet config: fff, fff-nix, fff-worktree declare find_files, grep, multi_grep read-only in home/common/mcpx-settings.nix (the production daemon config) and the project .mcpx.json.

    ⚠️ Deployment sequencing: mcpx strictly validates mcpx-block keys — an older binary refuses to parse a config containing readOnlyTools. The config change and the new binary must land in the same switch (they do, if the switch is built from merged main). Do not deploy the config ahead of the binary. One loose end: the untracked local copy at dezren39-nix/mcpx.config.nix in the main checkout should get the same one-line mcpx.readOnlyTools declaration for the darwin fff servers when it is next edited (the tracked root mcpx.config.nix derives from .mcpx.json, so it inherits the declaration automatically).

    Proof (headless, scratch daemon, production untouched)

    Scratch daemon (own state dir/socket/port), default policy.write=ask, elicit.confirmDestructive=true, askTimeout=3s, nobody answering questions, real /home/user/.local/bin/fff-mcp over a scratch tree containing sub/zz6116proof-target.txt with content unique-6116-proof-content:

    • CLI: mcpx call fff.find_files {"query":"zz6116proof"} → genuine result: sub/zz6116proof-target.txt.
    • HTTP: POST /v1/call {"server":"fff","tool":"grep","args":{"query":"unique-6116-proof-content"}} → 200, {"result":{"content":[{"type":"text","text":"→ Read sub/zz6116proof-target.txt (only match)\nsub/zz6116proof-target.txt\n 1: unique-6116-proof-content"}],"isError":false}}.
    • HTTP: POST /v1/call {"server":"demo","tool":"wipe"} (fakemcp, destructiveHint: true, undeclared) → 403, {"error":"demo.wipe may be destructive and was not confirmed: the answer was cancel","code":"confirmation_required"}.
    • HTTP: POST /v1/call {"server":"fff","tool":"multi_grep"} (unannotated, deliberately undeclared in the proof config) → 403, {"error":"fff.multi_grep may be destructive and was not confirmed: nobody answered within 3s","code":"confirmation_required"}.
    • Control: the unmodified origin/main binary against the same setup returns the audit's error verbatim: mcpx: fff.find_files may be destructive and was not confirmed: nobody answered within 3s.

    Tests

    New: daemon TestWritePolicyDeclaredReadOnlyPassesWithNoAnswerer, TestWritePolicyDeclarationDoesNotWidenToUnlistedTools, TestDeclaredReadOnlyClearsTheDestructiveFloor, TestGateRefusalsAreTyped; config TestResolveCarriesReadOnlyTools, TestReadOnlyToolsFromJSONConfig; e2e TestDeclaredReadOnlyToolRunsHeadless, TestUndeclaredUnannotatedToolStaysGatedHeadless. Full internal/daemon suite passes; the full e2e suite's 6 failures and the settings/cli/config/api guard failures (7) were diffed against a clean origin/main worktree and are identical pre-existing failures, none introduced here.

    Acceptance: read-only projected tools now execute headless end-to-end with genuine results ✔; destructive tools still require a confirmation, and in a headless session that refusal is typed (403 + confirmation_required) ✔; gate errors are distinguishable from tool failures ✔. Leaving open until the coordinator deploys and re-verifies against production.

  7. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

  8. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    Production activation + proof — closing (2026-11-05)

    The #6265 fix (operator-declared readOnlyTools + typed gate refusals) is now live and proven on the production daemon. Getting there surfaced two production faults that are part of this record:

    Diagnosis: why the running daemon ignored the merged config

    • The merged config renders from home/common/mcpx-settings.nix (the unit's --config and ~/.config/mcpx/config.json both point at the render). Post-mcpx: operator-declared readOnlyTools + typed gate refusals (#6116) #6265 render: /nix/store/ar8zv80nyhfcl6wy8lwb21b5aypv99jp-mcpx-config.json (readOnlyTools ×3). The running daemon instead used /nix/store/khlyw5p69nfrr3yagzfkqj0bizv289pm-mcpx-config.json — byte-identical to the new render except exactly the three readOnlyTools declarations (verified by diff): it is the pre-mcpx: operator-declared readOnlyTools + typed gate refusals (#6116) #6265 render, preserved across a mcpx upgrade handover, which by design hands over the process but keeps the running config.
    • The untracked-in-spirit loose end is innocent: the daemon config does not come from dezren39-nix/mcpx.config.nix or the checkout .mcpx.json; it comes from mcpx-settings.nix via the module render above.

    Fault found during activation: the switch itself took production mcpx down

    • The unit's ExecStart binary is the fork-bundled mcpx build (/nix/store/pahg1lqscygyb912nk29w676k71pwawy-mcpx-0.1.0), which predates mcpx: operator-declared readOnlyTools + typed gate refusals (#6116) #6265 and cannot parse the new config. During the gen-542 switch (2026-11-05 12:36:33), home activation's mcpxDeploy handover terminated the old daemon and the unit start then failed verbatim: mcpx: parse config /nix/store/ar8zv...: server "fff": its "mcpx" block has no key "readOnlyTools"; it takes argumentRules, callTimeout, ... — restart loop → start-limit-hit at 12:37:10. Production mcpx was down from 12:37 until this activation. (A plain systemctl restart mcpx.service would have caused the same outage at any earlier point — the trap was armed since gen 541.)
    • Recovery/activation: a systemd drop-in (~/.config/systemd/user/mcpx.service.d/override.conf) points the unit's ExecStart/ExecReload at the current merged binary (/nix/store/1x31j1023inpz925hhi4yqvcxfvcqn9q-mcpx-0.1.0, the /run/current-system build of this repo's pkgs/mcpx at current main) with the unit's own config (ar8zv). reset-failed + start brought the daemon up as a real systemd child. Durable follow-up still owed: advance the fork's bundled mcpx pin so the generated unit's own ExecStart carries a post-mcpx: operator-declared readOnlyTools + typed gate refusals (#6116) #6265 build, then drop the override. The override is deliberately narrow (binary path only; config, environment and unit semantics unchanged).

    Side-effect check: the antigravity-retest session's mcpx settings set policy.write allow

    • Session ses_e5e5376ae54ffeqVcEV9KOyJ48 ran mcpx settings set policy.write allow and mcpx restart while clearing the gate. Finding: nothing persistent was widened. The set applied to that daemon instance only and died with it; no settings file on disk carries it. The production daemon now resolves policy.write = ask from default, and every other setting likewise resolves from default (elicit.confirmDestructive = false, its documented default posture — see the note in dezren39-nix/mcpx.config.nix: it stays off deliberately, reliability #6: mcpx — aws credentials, GitHub/Datadog write tools, destructive-call confirmation, plugin strays dezren39/darwin-nix#664). The session's mcpx restart is also what triggered the 10:34 upgrade handover that preserved the stale khlyw config (see diagnosis).

    Production proof (headless, production daemon pid 2128378, endpoint http://127.0.0.1:33253)

    • Health: GET /v1/health → {"pid":2128378,"status":"ok","version":"0.1.0",...} HTTP 200. mcpx status: running, config = ar8zv render.
    • Declared read-only executes: POST /v1/call {"server":"fff-nix","tool":"find_files","args":{"query":"mcpx-settings"}} → HTTP 200, genuine result: 20/166 matches, first hit home/common/mcpx-settings.nix git:clean (after the fresh fff child's index warmed; earlier calls already executed with HTTP 200 and empty-index results rather than gating).
    • Gate probe (undeclared tool, harmless if it had run): POST /v1/call {"server":"sequential-thinking","tool":"sequentialthinking", ...} → HTTP 403 in 0.7s with body code typed: {"error":"sequential_thinking.sequentialthinking may be destructive and was not confirmed: write policy: its annotations could not be read: ...","code":"confirmation_required"}. No 45s wait, no execution. (The annotations-unreadable detail is because that npx server cannot spawn under the unit's restricted PATH — spawn sh ENOENT, pre-existing for npx servers under this unit — the gate refused anyway, which is the designed behavior when read-only-ness cannot be established.)

    Posture: merged binary + readOnlyTools declarations + policy.write default ask. Closing as production-verified.

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

Metadata

Metadata

Assignees

Labels

effort/mMedium: expected under 1 day of workkind/bugSomething isn't working (prefixed form of the classic bug label)meta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/highImportant and time-sensitivestatus:donetask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions