Repository navigation
mcpx: operator-declared readOnlyTools + typed gate refusals (#6116) - #6265
Conversation
The write-policy gate (policy.write, default ask) classified tools from their annotations with the specification defaults: an unannotated tool is a possibly destructive write. fff-mcp publishes no annotations, so every projected fff call -- all searches -- was confirmation-gated, and in headless/API sessions the question has no answerer, so every call returned the gate error as its result. - config: new per-server mcpx.readOnlyTools (exact names). The operator's declaration in local config is trusted outright, as a locally declared stdio server's annotations are (#2191); a server cannot declare its own tools read-only this way. - daemon: a declared tool is classified read-only by the write policy gate in every mode, clears the elicit.confirmDestructive floor, and is exempt from the unknown-outcome ledger like an annotated read-only tool. Unlisted tools keep the defaults exactly, so the gate still fires for everything else. - daemon: gate refusals are typed (#6116 second ask): ErrNotConfirmed now answers HTTP 403 (was 502, indistinguishable from an upstream failure) and call error bodies carry a machine-readable code -- confirmation_required / write_policy_denied. - fleet config: declare fff/fff-nix/fff-worktree find_files, grep and multi_grep read-only in home/common/mcpx-settings.nix (the production daemon config) and the project .mcpx.json. - docs: configuration.md gains the readOnlyTools section; consumer.md notes the pre-authorization. Proof (scratch daemon, real fff-mcp, default ask policy + confirmDestructive on, nobody answering): fff.find_files and fff.grep return genuine results over the CLI and /v1/call; demo.wipe and undeclared fff.multi_grep return HTTP 403 {code: confirmation_required}. The unmodified origin/main binary against the same setup returns the audit's error verbatim: 'fff.find_files may be destructive and was not confirmed: nobody answered within 3s'.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 25 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f3b33dccc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "args" = [ ]; | ||
| "command" = "/home/user/.local/bin/fff-mcp"; | ||
| "mcpx" = { | ||
| "readOnlyTools" = [ "find_files" "grep" "multi_grep" ]; |
There was a problem hiding this comment.
Update the cascade binary alongside the new configuration
On the configured fleet deployment, services.mcpx.package deliberately uses the cascade's package rather than this checkout's build (home/common/default.nix:1163–1168). However, flake.lock still pins that cascade's mcpx-src to 031cde20f71c2fafa068c47b69e68175b72994a5, whose parser lacks ReadOnlyTools and rejects unknown mcpx keys using DisallowUnknownFields. A fleet switch therefore feeds this new configuration to an incompatible daemon, preventing it from starting. Update the cascade source pin alongside this configuration so the selected service binary includes the new parser support.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed by the cascade pin bump tracked in #6492: developing-today-forks/opencode#1911 bumped the fork mcpx-src pin 031cde2 → bcc0901 (the first code rev line whose parser carries ReadOnlyTools, via your finding PR #6265 merge 4e6cdb9), and #6750 bumped code's opencode pin to the fork merge rev, moving the transitive mcpx-src node to bcc0901. Verified on the laptop: the cascade build at the new pin parses the live rendered mcpx config, while the old-parser binary refuses the same file with server "fff": its "mcpx" block has no key "readOnlyTools". Full evidence on #6492.
| // destructive write and which is what gated manifestly | ||
| // read-only search tools (fff.find_files) in headless | ||
| // sessions, where the gate's question has no answerer. | ||
| class = policy.Classification{ReadOnly: true} |
There was a problem hiding this comment.
Honor read-only declarations when recording unknown outcomes
When an operator-declared read-only tool without readOnlyHint times out or loses its connection after dispatch, callWithLedger in registry.go still classifies it using only the annotation-based toolReadOnly helper. Consequently, a declared search such as fff.grep returns ErrUnknownOutcome and persists a server-wide block on subsequent non-read-only calls until manually cleared, despite the new declaration classifying it as read-only here. Apply the requested server's declaration to the post-dispatch ledger classification as well, not just the gate and existing-block exemption.
Useful? React with 👍 / 👎.
Fixes #6116.
Where the gate lives
The gate is in the mcpx daemon (
pkgs/mcpx, this repo) -- not OpenCode, not an OpenCode session permission or form. Two layers ininternal/daemon/consumer.go:applyWritePolicy:policy.writedefaults to ask (internal/defaults/defaults.json). A call is a write unless its tool is annotatedreadOnlyHint: true, read with the specification's defaults.confirmDestructive: theelicit.confirmDestructivefloor (off by default).fff-mcp publishes no annotations at all (verified live:
find_files/grep/multi_grepallannotations: null), so every fff call classifies as a possibly-destructive write and is gated under the default ask policy. Interactive callers can answer the broker question; headless/API sessions cannot, so every projected call returned… may be destructive and was not confirmed: nobody answered within 45s-- as a 502, indistinguishable from an upstream tool failure.Policy implemented
mcpx.readOnlyTools(exact tool names, no 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; remote annotations still clear nothing. A declared tool is classified read-only by the write-policy gate in every mode (ask/allow/deny), clears the destructive floor, and is exempt from the unknown-outcome write ledger.ErrNotConfirmednow maps to HTTP 403 (was 502) and call error bodies carry a machine-readablecode:confirmation_required(unconfirmed) /write_policy_denied(policy denial). Ordinary 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.mcpxblock keys (an older binary refuses a config containingreadOnlyTools), so the config change and the mcpx binary from this PR must land in the same switch -- which they do if the switch is built from merged main. Do not deploy the config ahead of the binary.Proof (headless, scratch daemon, real fff-mcp)
Scratch daemon (own state dir/socket/port; production untouched), default
policy.write=ask,elicit.confirmDestructive=true,askTimeout=3s, nobody answering questions:fff.find_files {"query":"zz6116proof"}(CLI)sub/zz6116proof-target.txtPOST /v1/call fff.grep(HTTP 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 demo.wipe(destructiveHint:true, undeclared){"error":"demo.wipe may be destructive and was not confirmed: the answer was cancel","code":"confirmation_required"}POST /v1/call fff.multi_grep(unannotated, undeclared in that config){"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 (no declaration) returns the audit's error verbatim:
mcpx: fff.find_files may be destructive and was not confirmed: nobody answered within 3s.Tests
New:
TestWritePolicyDeclaredReadOnlyPassesWithNoAnswerer,TestWritePolicyDeclarationDoesNotWidenToUnlistedTools,TestDeclaredReadOnlyClearsTheDestructiveFloor,TestGateRefusalsAreTyped(daemon),TestResolveCarriesReadOnlyTools,TestReadOnlyToolsFromJSONConfig(config),TestDeclaredReadOnlyToolRunsHeadless,TestUndeclaredUnannotatedToolStaysGatedHeadless(e2e, real daemon + fakemcp).internal/daemonfull suite: PASSinternal/policy,internal/refdoc: PASSTestADestructiveCallIsRefusedWhenNobodyConfirms/…ProceedsWhenSomebodyConfirms: PASSTestPluginOpsAreGenerated,TestServerKeysAnotherHostWritesAreRecordedNotRefused,TestTargetBearerTokenResolvesTheTargetDaemon,TestNoUndeclaredEnvRead,TestEverySettingHasAnEffectProbeOrAnExemption,TestTheScriptEnvironmentIsWhatTheCodeSets,TestTheEnvironmentDocIsCurrent.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.