Repository navigation
fix(mcp): annotate get_file_outline and ingest_traces as read-only (#2118) - #2404
Merged
Merged
Conversation
…2118) v0.11.0 corrected the ten query tools reported in #2118, but two entries in TOOL_ANNOTATIONS still advertised the wrong behaviour in tools/list: - get_file_outline was {readOnlyHint:false, destructiveHint:true}. It was added after the read-only split and kept a conservative default, yet it reads through the same non-mutating resolve_store() query path as search_graph and friends and never writes. - ingest_traces was {readOnlyHint:false, idempotentHint:false}. Its handler only parses and counts the traces array (edge creation is not implemented), so it writes nothing and is idempotent. Clients that gate auto-approval on these hints prompted for, or skipped, two safe tools. Both are now read-only, non-destructive and idempotent. The handlers that write user-visible state (index_repository, manage_adr, delete_project) keep their annotations unchanged. A new test walks the registered tool list (cbm_mcp_tool_count / cbm_mcp_tool_name) rather than a mirrored table and asserts that only an explicit mutator allowlist may clear readOnlyHint and only its destructive subset may set destructiveHint, so a newly added tool cannot inherit a wrong default unnoticed. The exact-value table test is updated to match. Refs #2118 Signed-off-by: Martin Vogel <[email protected]>
|
Thanks @DeusData, and for the fast turnaround across v0.11.0 and this PR. The new test that only allows writable/destructive hints for an explicit list of mutating tools is a great addition, since it stops a new tool from shipping with the wrong default. Appreciate the credit! |
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.
v0.11.0 already fixed the ten query tools from the report. This PR fixes the last two:
get_file_outlinewasreadOnlyHint:false, destructiveHint:true. It reads through the same non-mutatingresolve_store()query path as the other query tools, so it is now read-only and non-destructive.ingest_traceswasreadOnlyHint:false, idempotentHint:false. Its handler only parses and counts thetracesarray, because edge creation is not implemented yet, so it is now read-only and idempotent. When real ingestion lands, the new test forces it back to writable.index_repository,manage_adr,delete_project) are unchanged.Test: the new
mcp_tool_annotations_only_mutators_are_writable_issue2118walks the registered tool list. It allowsreadOnlyHint:falseonly for an explicit list of tools that write, anddestructiveHint:trueonly for the destructive ones, so a newly added tool can no longer ship with a wrong default. The old test compared against a copy of the table with the same wrong values. The new test fails before the fix, passes after it, and fails again on revert. The mcp suite (321 tests) andmake -f Makefile.cbm lint-cipass.Proof (
tools/listfrom the dev binary):get_file_outline: readOnly False→True, destructive True→False.ingest_traces: readOnly False→True, idempotent False→True.All other tools are unchanged.
Thanks to @vishalhabib99 for the precise report.
Fixes #2118