feat: Add tool annotations for improved LLM tool understanding#862
Merged
Merged
Conversation
Add readOnlyHint, destructiveHint, and title annotations to all tools to help LLMs better understand tool behavior and make safer decisions. Changes: - Added destructiveHint: true to tools that modify data - Added title annotations for human-readable display (e.g., "Find Symbol") - Fixed memory tools (WriteMemoryTool, DeleteMemoryTool, EditMemoryTool) to correctly inherit ToolMarkerCanEdit, ensuring they get destructiveHint: true This improves tool safety metadata for MCP clients by: - Helping LLMs distinguish read-only from destructive operations - Providing human-readable titles for tool display - Correctly categorizing all memory-modifying tools as destructive Co-Authored-By: Claude <noreply@anthropic.com>
Author
|
Hi maintainers, The CI test failures appear to be pre-existing issues unrelated to this PR's changes. This PR only adds MCP tool annotations (metadata hints like The failing tests are all in the Vue language server test suite:
These failures relate to Vue/TypeScript cross-file reference resolution, which my annotation-only changes don't touch. Happy to rebase if needed, but wanted to flag that these failures seem to be a separate issue in the test suite. |
Member
|
Thank you and sorry for the late review - I wanted to make sure everything still works by performing manual checks and hadn't found time for that. Now I did, everything does work. Merging |
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 tool annotations (
readOnlyHint,destructiveHint,title) to all tools to help LLMs better understand tool behavior and make safer decisions about tool execution.Changes
Enhanced Annotation Generation (
src/serena/mcp.py)destructiveHint: trueto tools that can modify data (those inheritingToolMarkerCanEdit)titleannotations with human-readable display names (e.g.,find_symbol→ "Find Symbol")readOnlyHint: truefor read-only tools,destructiveHint: truefor edit toolsFixed Memory Tools (
src/serena/tools/memory_tools.py)WriteMemoryTool,DeleteMemoryTool, andEditMemoryToolnow correctly inheritToolMarkerCanEditdestructiveHint: trueinstead of incorrectly being marked as read-onlyWhy This Matters
Before/After
Before:
After:
Testing
uv sync)pyright)ruff check)WriteMemoryTool.can_edit()→TrueDeleteMemoryTool.can_edit()→TrueEditMemoryTool.can_edit()→TrueReadMemoryTool.can_edit()→FalseListMemoriesTool.can_edit()→False🤖 Generated with Claude Code