Repository navigation
fix(cli): MCP read-only switch drops every tool not annotated read-only - #5191
Conversation
<PREFIX>_MCP_READ_ONLY=1 was consulted only by the cobratree mirror and <api>_execute, so typed endpoint tools, intents, the execute tool and mcp:local-write mirrors stayed registered. RegisterTools now removes each tool whose readOnlyHint is not true after every registration; an unannotated tool fails closed. Call-time refusals stay as a second layer. Closes mvanhorn#5175 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Merge Protections🟢 All 2 merge protections satisfied — ready to merge. Show 2 satisfied protections🟢 require-ready-label-and-ci
🟢 🚦 Auto-queueWhen all merge protections are satisfied and these conditions match, this pull request will be queued automatically.
|
[Medium impact] The PR appears safe to merge; no actionable defects were found. SummaryMakes the generated MCP read-only switch remove every tool without
No actionable issues found. Tests were not run during this review. DamienStevens explicitly described dropping unannotated recipe intents and ambiguous RPC-over-GET tools as intentional. DamienStevens also explicitly excluded device CLIs from this change.
|
Merge Queue Status
This pull request spent 58 minutes 31 seconds in the queue, including 22 minutes 26 seconds running CI. Required conditions to merge
|
Intent
<PREFIX>_MCP_READ_ONLY=1is documented as the operator kill switch, but typed endpoint tools, intent tools,<api>_execute, andmcp:local-writemirrors (teach,teach_playbook,playbook_amend,learnings_confirm, ...) stayed registered with it on.Issue: Closes #5175
Approach
After every registration,
RegisterToolsremoves each tool whosereadOnlyHintis not true (ListTools+DeleteTools). One rule covers typed, intent, mirror and code-orchestration tools, and an unannotated tool fails closed. The mirror's own filter and the call-time refusals are unchanged and stay as a second layer. Device CLIs are not touched: theirRegisterToolsregisters only the read-onlycontexttool plus the mirror, and they emit no learn writers.Scope
Primary area: generator templates, MCP surface (
mcp_tools.go.tmpl).Why this belongs in this repo: the switch is emitted into every printed CLI. Downstream (Servosity msp-skills) we carry the same rule as a hand-fix in two connectors.
Risk
Switch on:
<api>_executeand the learn writers are no longer offered;<api>_read,_search,_get,sql,search,contextand read-only mirrors remain. A GET that already fails closed as not read-only (RPC-over-GET without a read signal) is also dropped, which matches its existing annotation. Recipe-intent tools carry noreadOnlyHinttoday, so with the switch on they are dropped too, even when they wrap a read-only command (fail closed; annotating them is a separate change). The mirror's own filter still admitsmcp:local-writecommands before this pass removes them; left as is to keep this change to one rule. Switch off: no change.Output Contract
internal/mcp/tools.gogains the post-registration drop anddropNonReadOnlyTools; goldens updated for the six cases that rendermcp_tools.go.tmpl.TestGenerateMCPReadOnlySwitchDropsEveryNonReadOnlyToolgenerates and compiles two CLIs (endpoint mirror and code orchestration, learn loop on) and runs an emitted runtime test: switch off, the write tools are registered; switch on, every registered tool hasreadOnlyHint: trueand no read-only tool was dropped. AGENTS.md and phase 11 skill text describe the new scope.Verification
go build ./...go test -timeout 90m ./internal/generator/...: all pass except four that fail identically on unmodifiedmain(c601087) on this macOS host:TestGeneratedTLSTrustStock,TestGeneratedTLSTrustHTTP1Only,TestGeneratedTLSTrustBrowser(x509 trust of the test leaf certificate) andTestGeneratedDefaultDBPathStableOAuthScope. A first run under heavy machine load also hit timing and shared-GOCACHE flakes, all of which pass on rerunscripts/golden.sh update(6tools.gofixtures changed, all the same 19-line addition), thenscripts/golden.sh verify: pass (43 cases)scripts/verify-generator-output.sh(default cases): pass (15 cases)Negative control: with the drop disabled, the new runtime test fails listing
items_create,items_removeand six learn writers as registered under the switch.golangci-lintand lefthook are not installed on this machine;gofmt -landgo vet ./internal/generator/are clean.Generator/template change: verified generated output, including emitted-code assertions or compiled generated CLI output
Generator/template change: covered the affected fallback or variant shape, not only happy-path fixtures
Generator/template change: checked emitted definitions and call sites for matching gates
AI / Automation Disclosure
🤖 Generated with Claude Code