Skip to content

fix(mcp): annotate get_file_outline and ingest_traces as read-only (#2118) - #2404

Merged
DeusData merged 1 commit into
mainfrom
fix/issue-2118
Sep 30, 2026
Merged

DeusData merged 1 commit into
mainfrom
fix/issue-2118

Conversation

@DeusData

Copy link
Copy Markdown
Owner

v0.11.0 already fixed the ten query tools from the report. This PR fixes the last two:

  • get_file_outline was readOnlyHint:false, destructiveHint:true. It reads through the same non-mutating resolve_store() query path as the other query tools, so it is now read-only and non-destructive.
  • ingest_traces was readOnlyHint:false, idempotentHint:false. Its handler only parses and counts the traces array, 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.
  • The three tools that really write (index_repository, manage_adr, delete_project) are unchanged.

Test: the new mcp_tool_annotations_only_mutators_are_writable_issue2118 walks the registered tool list. It allows readOnlyHint:false only for an explicit list of tools that write, and destructiveHint:true only 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) and make -f Makefile.cbm lint-ci pass.

Proof (tools/list from 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

…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]>
@vishalhabib99

Copy link
Copy Markdown

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!

@DeusData
DeusData merged commit 083bc99 into main Sep 30, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

13 of 15 tools annotated destructiveHint:true / readOnlyHint:false, but most are pure read/query operations

2 participants