-
Notifications
You must be signed in to change notification settings - Fork 162
feat: add MCP tool annotations to all 6 tools #46
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?
Conversation
Add MCP tool annotations per specification to help AI assistants understand tool behavior and capabilities. Tools annotated: - ask-gemini: readOnlyHint=true, openWorldHint=true (Gemini API) - brainstorm: readOnlyHint=true, openWorldHint=true (Gemini API) - Help: readOnlyHint=true, openWorldHint=true (runs gemini CLI) - ping: readOnlyHint=true, idempotentHint=true (echo utility) - fetch-chunk: readOnlyHint=true, idempotentHint=true (cache retrieval) - timeout-test: readOnlyHint=true (test utility) Changes: - Added ToolAnnotations interface to registry.ts - Extended UnifiedTool interface with optional annotations - Updated getToolDefinitions() to include annotations in output - Added annotations to all 6 tool definitions Annotations follow MCP spec: https://spec.modelcontextprotocol.io/specification/2025-03-26/server/tools/#annotations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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 integrates Model Context Protocol (MCP) tool annotations across all defined tools. The primary goal is to provide AI assistants with richer metadata about each tool's characteristics, such as whether it's read-only, interacts with external systems, or is idempotent. This enhancement improves the AI's ability to reason about and effectively utilize the available tools, leading to more accurate and reliable tool selection and execution. 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.
Pull request overview
This PR adds MCP (Model Context Protocol) tool annotations to all 6 tools in the codebase, following the MCP specification. The annotations provide metadata that helps AI assistants understand tool behavior and capabilities, specifically marking tools as read-only, idempotent, or open-world (interacting with external entities).
Key changes:
- Added
ToolAnnotationsinterface to define the structure of MCP annotations - Extended
UnifiedToolinterface to support optional annotations - Annotated all 6 tools with appropriate hints based on their behavior
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/tools/registry.ts | Added ToolAnnotations interface with MCP spec fields and updated getToolDefinitions() to include annotations in tool output |
| src/tools/ask-gemini.tool.ts | Added annotations marking the tool as read-only and open-world (external API access) |
| src/tools/brainstorm.tool.ts | Added annotations marking the tool as read-only and open-world (external API access) |
| src/tools/simple-tools.ts | Added annotations to both ping (read-only, idempotent) and help (read-only, open-world) tools |
| src/tools/fetch-chunk.tool.ts | Added annotations marking the tool as read-only and idempotent (cache retrieval) |
| src/tools/timeout-test.tool.ts | Added annotations marking the tool as read-only |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 effectively adds MCP tool annotations to all six tools, enhancing their discoverability and usability for AI assistants. The changes are well-structured, with a new ToolAnnotations interface and updates to UnifiedTool and getToolDefinitions. The annotations applied to each tool appear correct and align with their functionalities. I have one suggestion in src/tools/registry.ts to make the code slightly more concise.
src/tools/registry.ts
Outdated
| const toolDef: Tool = { | ||
| name: tool.name, | ||
| description: tool.description, | ||
| inputSchema, | ||
| }; | ||
|
|
||
| // Include annotations if defined | ||
| if (tool.annotations) { | ||
| toolDef.annotations = tool.annotations; | ||
| } | ||
|
|
||
| return toolDef; |
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 improved conciseness and readability, you can construct and return the tool definition object in a single statement. Since tool.annotations is already optional, you can assign it directly. If it's undefined, it will be handled correctly upon serialization (usually omitted from JSON output). This avoids the need for a temporary variable and a conditional block.
| const toolDef: Tool = { | |
| name: tool.name, | |
| description: tool.description, | |
| inputSchema, | |
| }; | |
| // Include annotations if defined | |
| if (tool.annotations) { | |
| toolDef.annotations = tool.annotations; | |
| } | |
| return toolDef; | |
| return { | |
| name: tool.name, | |
| description: tool.description, | |
| inputSchema, | |
| annotations: tool.annotations, | |
| }; |
Address code review feedback from Gemini Code Assist: - Replace conditional block with direct object return - Leverages undefined values being omitted in JSON serialization - Results in cleaner, more concise code 🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
Thanks for the review feedback! Great suggestion - I've applied the refactor to simplify the object construction: return {
name: tool.name,
description: tool.description,
inputSchema,
annotations: tool.annotations,
};This is cleaner and leverages undefined values being omitted during JSON serialization. Commit: debfa37 |
Summary
ToolAnnotationsinterface and updatedUnifiedToolinterfaceChanges
Infrastructure
ToolAnnotationsinterface toregistry.tswith all MCP-spec fieldsUnifiedToolinterface with optionalannotationspropertygetToolDefinitions()to include annotations in Tool outputTools Annotated
ask-geminibrainstormHelppingfetch-chunktimeout-testAll tools are read-only - they query external services or return cached data but don't modify state.
Test plan
openWorldHint: trueidempotentHint: true🤖 Generated with Claude Code