-
-
Notifications
You must be signed in to change notification settings - Fork 922
feat: add MCP tool annotations to 14 tools #375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: add MCP tool annotations to 14 tools #375
Conversation
Add `readOnlyHint: True` annotations to analysis tools to improve LLM decision-making about tool safety characteristics. Tools annotated: - analyze: code analysis workflow - apilookup: API documentation lookup (also openWorldHint: True) - challenge: critical thinking analysis - codereview: code review workflow - consensus: multi-model consensus building - debug: debugging and root cause analysis - docgen: documentation generation - planner: task planning workflow - precommit: git change validation - refactor: refactoring analysis - secaudit: security audit - testgen: test generation - thinkdeep: deep thinking analysis - tracer: code tracing All these tools perform read-only analysis without modifying files, making `readOnlyHint: True` appropriate. The `apilookup` tool also has `openWorldHint: True` since it searches external documentation sources. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Summary of ChangesHello @triepod-ai, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the metadata available for various tools by implementing MCP (Multi-Client Protocol) annotations. These annotations provide crucial hints to clients, such as Claude, enabling them to make more informed decisions regarding tool safety and operational characteristics. The changes are purely metadata-driven, ensuring no functional alterations to the tools themselves, and complete the annotation coverage for all existing tools. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds MCP tool annotations to 14 tools, which is a great enhancement for MCP clients. The changes are consistent and correctly implement the get_annotations method for each tool, adding readOnlyHint and openWorldHint where appropriate. The necessary Optional imports are also included.
I have one suggestion for a minor improvement regarding performance and code style, which I've detailed in a comment on tools/analyze.py. The suggestion is to define the annotation dictionary as a class-level constant to avoid its recreation on every method call. This pattern could be applied to all 14 modified tools for consistency.
tools/analyze.py
Outdated
| def get_annotations(self) -> Optional[dict[str, Any]]: | ||
| """Return tool annotations indicating this is a read-only analysis tool.""" | ||
| return {"readOnlyHint": True} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a minor performance optimization and to establish a consistent pattern for constants, you could define the annotation dictionary as a class-level constant. This prevents creating a new dictionary every time get_annotations() is called. While the performance impact is likely small, this pattern can improve code clarity and is a good practice, especially if this method is called frequently.
This suggestion applies to all 14 tools modified in this PR.
Here's how you could implement it for AnalyzeTool:
class AnalyzeTool(WorkflowTool):
_ANNOTATIONS = {"readOnlyHint": True}
# ... other methods ...
def get_annotations(self) -> Optional[dict[str, Any]]:
"""Return tool annotations indicating this is a read-only analysis tool."""
return self._ANNOTATIONSAddress Gemini Code Assist review feedback by defining annotation dictionaries as class-level constants rather than creating new dictionaries on each get_annotations() call. Changes: - Added _ANNOTATIONS class constant to all 14 tool classes - Updated get_annotations() to return self._ANNOTATIONS - Maintains same annotation values (readOnlyHint, openWorldHint) Benefits: - Avoids dictionary recreation on every method call - Establishes consistent pattern across tool classes - Improves code clarity with annotations visible at class level 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
Thanks for the feedback @gemini-code-assist! Great suggestion on using class-level constants. I've updated all 14 tools to define class AnalyzeTool(WorkflowTool):
_ANNOTATIONS: dict[str, Any] = {"readOnlyHint": True}
def get_annotations(self) -> Optional[dict[str, Any]]:
return self._ANNOTATIONSThis pattern:
All 14 files have been updated with this approach. |
|
That's an excellent implementation, @triepod-ai! Using class-level constants for |
Replace Optional[dict[str, Any]] with dict[str, Any] | None to comply with ruff linter UP045 rule. Both files already have `from __future__ import annotations`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Description
Add MCP tool annotations to 14 tools that were missing them. Tool annotations help MCP clients (like Claude) make better decisions about tool safety and behavior characteristics.
Changes Made
readOnlyHint: Trueannotations to 14 analysis toolsopenWorldHint: Truetoapilookup(searches external docs)Optionalimport where needed (consensus.py, planner.py, apilookup.py)Tools Annotated
analyzereadOnlyHint: TrueapilookupreadOnlyHint: True,openWorldHint: TruechallengereadOnlyHint: TruecodereviewreadOnlyHint: TrueconsensusreadOnlyHint: TruedebugreadOnlyHint: TruedocgenreadOnlyHint: TrueplannerreadOnlyHint: TrueprecommitreadOnlyHint: TruerefactorreadOnlyHint: TruesecauditreadOnlyHint: TruetestgenreadOnlyHint: TruethinkdeepreadOnlyHint: TruetracerreadOnlyHint: TrueAll these tools perform read-only analysis without modifying files, making
readOnlyHint: Trueappropriate.Testing
chat.py,version.py,listmodels.py,clink.pyNote: This is a metadata-only change that adds hints for MCP clients. The annotation infrastructure already exists in
server.pyand is used by existing tools.Related Issues
N/A - Enhancement to improve MCP client integration
Checklist
Additional Notes
This PR brings tool annotation coverage to 18/18 tools (100%), up from 4/18 (22%). Tool annotations are part of the MCP specification and help clients understand tool behavior without executing them.
🤖 Generated with Claude Code