-
Notifications
You must be signed in to change notification settings - Fork 618
feat: Add tool annotations for improved LLM tool understanding #210
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 readOnlyHint and title annotations to all 13 tools to help LLMs better understand tool behavior and make safer decisions. Changes: - Added annotations property to Tool interface - Added readOnlyHint: true to all read-only tools - Added title annotations for human-readable display - Updated server.tool() call to pass annotations to MCP SDK All tools are read-only operations: - fetch_documentation / fetch_*_docs (fetches docs) - search_documentation / search_*_docs (searches docs) - search_code / search_*_code (searches code) - fetch_generic_url_content (fetches URL content) - match_common_libs_owner_repo_mapping (library lookup) - ThreeJS-specific tools (reference docs, content fetch) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
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 enhances tool definitions by adding MCP (Model Context Protocol) annotations to provide semantic metadata that helps LLMs better understand tool behavior. The changes add title and readOnlyHint properties to all 13 tools in the codebase.
Key changes:
- Extended the
Toolinterface to support optionalToolAnnotationsfrom the MCP SDK - Added
readOnlyHint: trueannotation to all tools to mark them as safe, read-only operations - Added human-readable
titleannotations to improve tool display in UIs - Updated tool registration logic to conditionally pass annotations to the MCP SDK's
server.tool()method
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| src/api/tools/repoHandlers/RepoHandler.ts | Added optional annotations property to the Tool interface |
| src/index.ts | Updated tool registration to conditionally pass annotations to server.tool() |
| src/api/tools/index.ts | Added annotations to the fetch_generic_url_content tool |
| src/api/tools/repoHandlers/DefaultRepoHandler.ts | Added annotations to 3 default tools (fetch, search documentation, search code) |
| src/api/tools/repoHandlers/GenericRepoHandler.ts | Added annotations to 4 generic tools (match library, fetch/search documentation, search code) |
| src/api/tools/repoHandlers/ReactRouterRepoHandler.ts | Added annotations to the React Router search documentation tool |
| src/api/tools/repoHandlers/ThreejsRepoHandler.ts | Added annotations to 4 Three.js-specific tools (reference docs, search, URL fetch) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| annotations: { | ||
| title: "Search Three.js Documentation", | ||
| readOnlyHint: true, | ||
| } as ToolAnnotations, |
Copilot
AI
Dec 21, 2025
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.
The type assertion as ToolAnnotations is unnecessary here. The object literal already satisfies the ToolAnnotations type, and explicit type casting can hide type mismatches. Remove the type assertion and let TypeScript infer the type naturally.
| annotations: { | ||
| title: "Fetch Three.js URLs Inside Docs", | ||
| readOnlyHint: true, | ||
| } as ToolAnnotations, |
Copilot
AI
Dec 21, 2025
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.
The type assertion as ToolAnnotations is unnecessary here. The object literal already satisfies the ToolAnnotations type, and explicit type casting can hide type mismatches. Remove the type assertion and let TypeScript infer the type naturally.
| annotations: { | ||
| title: "Match Library to Repository", | ||
| readOnlyHint: true, | ||
| } as ToolAnnotations, |
Copilot
AI
Dec 21, 2025
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.
The type assertion as ToolAnnotations is unnecessary here. The object literal already satisfies the ToolAnnotations type, and explicit type casting can hide type mismatches. Remove the type assertion and let TypeScript infer the type naturally.
| annotations: { | ||
| title: "Search Code", | ||
| readOnlyHint: true, | ||
| } as ToolAnnotations, |
Copilot
AI
Dec 21, 2025
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.
The type assertion as ToolAnnotations is unnecessary here. The object literal already satisfies the ToolAnnotations type, and explicit type casting can hide type mismatches. Remove the type assertion and let TypeScript infer the type naturally.
src/api/tools/index.ts
Outdated
| annotations: { | ||
| title: "Fetch URL Content", | ||
| readOnlyHint: true, | ||
| } as ToolAnnotations, |
Copilot
AI
Dec 21, 2025
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.
The type assertion as ToolAnnotations is unnecessary here. The object literal already satisfies the ToolAnnotations type, and explicit type casting can hide type mismatches. Remove the type assertion and let TypeScript infer the type naturally.
| } as ToolAnnotations, | |
| }, |
| annotations: { | ||
| title: "Fetch Generic Documentation", | ||
| readOnlyHint: true, | ||
| } as ToolAnnotations, |
Copilot
AI
Dec 21, 2025
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.
The type assertion as ToolAnnotations is unnecessary here. The object literal already satisfies the ToolAnnotations type, and explicit type casting can hide type mismatches. Remove the type assertion and let TypeScript infer the type naturally.
| annotations: { | ||
| title: "Search Generic Documentation", | ||
| readOnlyHint: true, | ||
| } as ToolAnnotations, |
Copilot
AI
Dec 21, 2025
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.
The type assertion as ToolAnnotations is unnecessary here. The object literal already satisfies the ToolAnnotations type, and explicit type casting can hide type mismatches. Remove the type assertion and let TypeScript infer the type naturally.
| annotations: { | ||
| title: "Search Generic Code", | ||
| readOnlyHint: true, | ||
| } as ToolAnnotations, |
Copilot
AI
Dec 21, 2025
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.
The type assertion as ToolAnnotations is unnecessary here. The object literal already satisfies the ToolAnnotations type, and explicit type casting can hide type mismatches. Remove the type assertion and let TypeScript infer the type naturally.
| annotations: { | ||
| title: "Fetch Documentation", | ||
| readOnlyHint: true, | ||
| } as ToolAnnotations, |
Copilot
AI
Dec 21, 2025
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.
The type assertion as ToolAnnotations is unnecessary here. The object literal already satisfies the ToolAnnotations type, and explicit type casting can hide type mismatches. Remove the type assertion and let TypeScript infer the type naturally.
| annotations: { | ||
| title: "Search Documentation", | ||
| readOnlyHint: true, | ||
| } as ToolAnnotations, |
Copilot
AI
Dec 21, 2025
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.
The type assertion as ToolAnnotations is unnecessary here. The object literal already satisfies the ToolAnnotations type, and explicit type casting can hide type mismatches. Remove the type assertion and let TypeScript infer the type naturally.
Remove explicit 'as ToolAnnotations' type casts that TypeScript can infer from the Tool interface. This follows best practices by letting TypeScript handle type checking naturally rather than using explicit assertions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Summary
Adds MCP tool annotations (
readOnlyHint,title) to all 13 tools to help LLMs better understand tool behavior and make safer decisions about tool execution.Changes
annotationsproperty toToolinterface (RepoHandler.ts)readOnlyHint: trueto all tools (all are read-only operations)titleannotations for human-readable displayserver.tool()call to pass annotations to MCP SDKTools Annotated
fetch_*_documentationsearch_*_documentationsearch_*_codefetch_generic_url_contentfetch_generic_documentationsearch_generic_documentationsearch_generic_codematch_common_libs_owner_repo_mappingget_threejs_reference_docs_listget_threejs_specific_docs_contentsearch_threejs_documentationfetch_threejs_urls_inside_docsWhy This Matters
Tool annotations provide semantic metadata that helps LLMs:
Testing
pnpm run build)npx tsc --noEmit)Before/After
Before:
After:
🤖 Generated with Claude Code