Repository navigation
Description
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
developing-today commentedon Nov 5, 2026
CODE-1762
dezren39 commentedon Nov 5, 2026
Intake review
~/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).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.executetool 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.Merge pull request #6265 from developing-today/fix/mcpx-6116-readonly…
dezren39 commentedon Nov 5, 2026
Fixed — merged in PR #6265 (merge commit
4e6cdb92fd), pending coordinator deploymentWhere 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.writedefaults to ask (internal/defaults/defaults.json). A call is a write unless its tool is annotatedreadOnlyHint: true, read with the MCP specification's defaults.confirmDestructive— theelicit.confirmDestructivefloor (off by default).fff-mcp publishes no annotations at all (verified live against the running binary:
find_files/grep/multi_grepall returnannotations: 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
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 theconfirmDestructivefloor, and is exempt from the unknown-outcome write ledger.ErrNotConfirmednow answers HTTP 403 (was 502), and call error bodies carry a machine-readablecode:confirmation_requiredfor an unconfirmed call,write_policy_deniedfor a policy denial. Genuine tool failures keep 502 +upstream, nocode.fff,fff-nix,fff-worktreedeclarefind_files,grep,multi_grepread-only inhome/common/mcpx-settings.nix(the production daemon config) and the project.mcpx.json.mcpx-block keys — an older binary refuses to parse a config containingreadOnlyTools. 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 atdezren39-nix/mcpx.config.nixin the main checkout should get the same one-linemcpx.readOnlyToolsdeclaration for the darwin fff servers when it is next edited (the tracked rootmcpx.config.nixderives 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-mcpover a scratch tree containingsub/zz6116proof-target.txtwith contentunique-6116-proof-content:mcpx call fff.find_files {"query":"zz6116proof"}→ genuine result:sub/zz6116proof-target.txt.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}}.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"}.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"}.origin/mainbinary 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; configTestResolveCarriesReadOnlyTools,TestReadOnlyToolsFromJSONConfig; e2eTestDeclaredReadOnlyToolRunsHeadless,TestUndeclaredUnannotatedToolStaysGatedHeadless. Fullinternal/daemonsuite passes; the full e2e suite's 6 failures and the settings/cli/config/api guard failures (7) were diffed against a cleanorigin/mainworktree 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.dezren39 commentedon Nov 5, 2026
🤖 Agent note · done
dezren39 commentedon Nov 5, 2026
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
home/common/mcpx-settings.nix(the unit's--configand~/.config/mcpx/config.jsonboth 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 amcpx upgradehandover, which by design hands over the process but keeps the running config.dezren39-nix/mcpx.config.nixor the checkout.mcpx.json; it comes frommcpx-settings.nixvia the module render above.Fault found during activation: the switch itself took production mcpx down
ExecStartbinary 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-hitat 12:37:10. Production mcpx was down from 12:37 until this activation. (A plainsystemctl restart mcpx.servicewould have caused the same outage at any earlier point — the trap was armed since gen 541.)~/.config/systemd/user/mcpx.service.d/override.conf) points the unit'sExecStart/ExecReloadat the current merged binary (/nix/store/1x31j1023inpz925hhi4yqvcxfvcqn9q-mcpx-0.1.0, the/run/current-systembuild of this repo'spkgs/mcpxat current main) with the unit's own config (ar8zv).reset-failed+startbrought 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 allowses_e5e5376ae54ffeqVcEV9KOyJ48ranmcpx settings set policy.write allowandmcpx restartwhile 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 resolvespolicy.write = askfrom default, and every other setting likewise resolves from default (elicit.confirmDestructive = false, its documented default posture — see the note indezren39-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'smcpx restartis 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)
GET /v1/health→{"pid":2128378,"status":"ok","version":"0.1.0",...}HTTP 200.mcpx status: running, config = ar8zv render.POST /v1/call {"server":"fff-nix","tool":"find_files","args":{"query":"mcpx-settings"}}→ HTTP 200, genuine result:20/166 matches, first hithome/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).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.writedefault ask. Closing as production-verified.