Skip to content

feat: Add tool annotations for improved LLM tool understanding#73

Merged
jating06 merged 3 commits into
razorpay:mainfrom
bryankthompson:feat/add-tool-annotations
Dec 30, 2025
Merged

feat: Add tool annotations for improved LLM tool understanding#73
jating06 merged 3 commits into
razorpay:mainfrom
bryankthompson:feat/add-tool-annotations

Conversation

@bryankthompson

Copy link
Copy Markdown
Contributor

Summary

Adds MCP tool annotations (readOnlyHint, destructiveHint) to all 42 tools to help LLMs better understand tool behavior and make safer decisions about tool execution.

Changes

  • Added SetReadOnly method to the Tool interface for annotation support
  • Modified toolsets.RegisterTools to automatically set annotations based on read/write classification
  • 25 read-only tools: readOnlyHint: true, destructiveHint: false (all fetch_* operations)
  • 17 destructive tools: readOnlyHint: false, destructiveHint: true (create, update, capture, refund, etc.)

This leverages your existing AddReadTools/AddWriteTools categorization to automatically apply correct annotations without modifying individual tool definitions.

Why This Matters

  • Annotations provide semantic metadata that helps LLMs understand tool behavior
  • LLMs can make better decisions about when to use tools and in what order
  • Enables safer tool execution by distinguishing read-only from destructive operations
  • MCP clients like Claude Code can auto-approve read-only tools without user confirmation

Testing

  • Server builds successfully (go build ./...)
  • All tests pass (go test ./...)
  • Live verification: Started server and confirmed tools/list returns correct annotations
  • Annotation values match actual tool behavior (read-only vs destructive)

Verification Output

Total tools: 42 (25 read-only, 17 destructive)

Tool Name                           ReadOnly   Destructive
-------------------------------------------------------
capture_payment                     False      True      
fetch_all_orders                    True       False     
fetch_payment                       True       False     
create_order                        False      True      
update_payment                      False      True      
...

🤖 Generated with Claude Code

Add readOnlyHint and destructiveHint annotations to all 42 tools
to help LLMs better understand tool behavior and make safer decisions.

Changes:
- Added SetReadOnly method to Tool interface for annotation support
- Modified toolsets.RegisterTools to set annotations based on read/write classification
- Read-only tools (25): readOnlyHint=true, destructiveHint=false
- Destructive tools (17): readOnlyHint=false, destructiveHint=true

This leverages the existing AddReadTools/AddWriteTools categorization
to automatically apply correct annotations without modifying individual
tool definitions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov-commenter

codecov-commenter commented Dec 26, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.40%. Comparing base (8b76418) to head (10c5025).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #73      +/-   ##
==========================================
+ Coverage   94.38%   94.40%   +0.01%     
==========================================
  Files          24       24              
  Lines        3511     3521      +10     
==========================================
+ Hits         3314     3324      +10     
  Misses        134      134              
  Partials       63       63              
Flag Coverage Δ
unittests 94.40% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Add test coverage for:
- SetReadOnly method (true/false cases)
- Tool annotation generation (readOnlyHint, destructiveHint branches)
- Default annotation behavior

This brings patch coverage above 90% threshold.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jating06

jating06 commented Dec 29, 2025

Copy link
Copy Markdown
Contributor

@triepod-ai please fix linting errors. Lint / lint (pull_request)

Break long lines in tool_test.go to comply with 80-character limit:
- Split handler function signatures across multiple lines
- Wrap NewTool() calls
- Split long comments

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@bryankthompson

Copy link
Copy Markdown
Contributor Author

Fixed! I've broken the long lines in the test file to comply with the 80-character limit. The push should trigger the CI to re-run.

@jating06 jating06 merged commit 92b6d7f into razorpay:main Dec 30, 2025
6 of 8 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.

4 participants