mcp: advertise readOnlyHint so plan-mode clients stop prompting on every call - #699
Draft
poelzi wants to merge 1 commit into
Draft
mcp: advertise readOnlyHint so plan-mode clients stop prompting on every call#699poelzi wants to merge 1 commit into
poelzi wants to merge 1 commit into
Conversation
tools/list shipped no `annotations` at all, so every client that gates on readOnlyHint treats codedb's navigation tools as potentially side-effecting. In Claude Code's plan mode this is not just a prompt: the permission evaluator's MCP gate rewrites the decision to "ask" before the allow-rule lookup runs, so a configured `mcp__codedb__*` allow rule is never consulted and "don't ask again" has no persistence path. The gate's only escape is `annotations.readOnlyHint`. Net effect today: every codedb_search / codedb_symbol / codedb_read call prompts while planning. Annotate the 19 tools that only read the index. codedb_index rebuilds the on-disk index and codedb_bundle can dispatch it, so both stay unannotated. The profile builders (core/slim/mini) and the augmented bundle list all derive from this same static JSON, so the hint rides along on each — verified over a live stdio handshake on the default mini profile. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TqTyTJVJ4cd1MzFF54Hrbh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
tools/listships noannotationsat all, so every client that gates onannotations.readOnlyHinthas to assume codedb's navigation tools might have side effects.In Claude Code that is not just an extra prompt. In plan mode the permission evaluator applies an MCP-specific gate:
and then returns that
askbefore the allow-rule lookup runs. Deny and ask rules are consulted earlier, allow rules later — so in plan mode a configuredmcp__codedb__*allow rule is never reached. The gate's only escape isisReadOnly(), which is defined asannotations?.readOnlyHint ?? false."Don't ask again" does not stick either: the plan-mode branch replaces the decision object wholesale, dropping the
addRulessuggestions that MCP's owncheckPermissionsnormally attaches, so there is no persistence path.Probing the server directly confirms the input side:
Net effect today: every
codedb_search/codedb_symbol/codedb_readcall prompts while planning, and no configuration can silence it.Fix
Add
"annotations":{"readOnlyHint":true}to the 19 tools that only read the index.codedb_indexrebuilds the on-disk index, andcodedb_bundlecan dispatch it, so neither is annotated — they should keep prompting.The core / slim / mini profile builders and
buildAugmentedToolsListall derive from this same static JSON, so the hint rides along on every profile with no extra code.Verification
mcp: read-only tools advertise readOnlyHint on every profileasserts the hint acrossfull,core,slimandmini, and asserts thatcodedb_index/codedb_bundlenever claim to be read-only.zig build testpasses (the one unrelatedtest_indexissue-690inotify crash on this base is addressed in a separate PR).Every MCP client with a plan or read-only mode benefits, not just Claude Code.