feat(annotations): infer MCP tool annotations from naming convention#41
Merged
Conversation
Adds MCP `ToolAnnotations` (`readOnlyHint`, `destructiveHint`) to
every registered tool by inferring from the strict naming convention
the catalogue follows. Clients like Claude Desktop / Claude Code use
these hints for auto-approval — without them, users see a
confirmation prompt before every tool call.
Inference rules:
- Read prefixes (search_, filter_, get_, list_, show_, run_) →
{ readOnlyHint: true }. 49 tools.
- The 7 destructive tools (5 whole-record deletes + remove_track +
remove_additional_party) → { destructiveHint: true }. Same set the
existing schema-level `confirm: true` gate covers.
- All other writes (creates, updates, additive child writes, batches)
→ no annotation. Clients fall back to their default (prompt).
30 tools.
49 + 7 + 30 = 86 — verified at the catalog level by a new
aggregate-counts assertion in tests/tool-annotations.test.ts. A new
tool added without matching the convention will drift the counts and
trip the test, forcing an explicit annotation decision.
Wired through both `registerTool` and `registerToolTask` so the
annotations carry through tools/list responses for the 5 batch_*
tasks-augmented writes too. `get_attachment` (raw `server.tool()`)
gets an explicit `{ readOnlyHint: true }` matching the auto-inferred
behaviour for every other `get_*` tool.
Tests: 463 → 468 (+5 — pure-function inference checks plus a
round-trip integration test asserting tools/list responses carry
the right hints).
Bundle delta: dist/index.js 146.52 → 147.44 KB, dist/http.js 173.00
→ 173.91 KB (annotation literals).
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.
Summary
Adds MCP `ToolAnnotations` (`readOnlyHint`, `destructiveHint`) to every registered tool by inferring from the strict naming convention the catalogue already follows. Clients like Claude Desktop and Claude Code use these hints for auto-approval — without them, users see a confirmation prompt for every tool call (including the safe read tools).
Inference rules
49 + 7 + 30 = 86, asserted explicitly by a new aggregate-counts test in `tests/tool-annotations.test.ts`. A new tool added without matching the convention will drift the counts and trip CI, forcing an explicit annotation decision.
The destructive set matches the existing schema-level `confirm: true` gate — annotation is a separate, client-facing hint surfacing the same "needs confirmation" signal at the protocol layer.
What this changes for users
Test plan
🤖 Generated with Claude Code