feat: Add tool annotations for improved LLM tool understanding#142
Open
bryankthompson wants to merge 1 commit intoBrowserMCP:mainfrom
Open
feat: Add tool annotations for improved LLM tool understanding#142bryankthompson wants to merge 1 commit intoBrowserMCP:mainfrom
bryankthompson wants to merge 1 commit intoBrowserMCP:mainfrom
Conversation
Add readOnlyHint and destructiveHint annotations to all tools to help LLMs better understand tool behavior and make safer decisions. Changes: - Added ToolAnnotations type to ToolSchema - Added readOnlyHint: true to read-only tools (wait, snapshot, getConsoleLogs, screenshot) - Added destructiveHint: true to tools that interact with browser (navigate, goBack, goForward, pressKey, click, drag, hover, type, selectOption) - Added title annotations for human-readable display - Updated server.ts to include annotations in tools/list response This improves tool safety metadata for MCP clients. Co-Authored-By: Claude <noreply@anthropic.com>
Author
|
Friendly ping! 👋 Just checking if this PR is still on your radar. Happy to address any feedback or make adjustments if needed. No rush - just wanted to make sure it didn't slip through the cracks. |
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 13 tools to help LLMs better understand tool behavior and make safer decisions about tool execution.Changes
ToolAnnotationstype import toToolSchemareadOnlyHint: trueto read-only tools:wait- Only pauses execution, no browser state changessnapshot- Captures current page state without modificationgetConsoleLogs- Reads existing console logsscreenshot- Captures image of current page statedestructiveHint: trueto tools that interact with/modify the browser:navigate- Changes current URLgoBack/goForward- Modifies browser history positionpressKey- Simulates keyboard inputclick- Triggers element interactionsdrag- Moves elementshover- Can trigger hover eventstype- Enters text into elementsselectOption- Changes form selection statetitleannotations for human-readable displayserver.tsto include annotations intools/listresponseWhy This Matters
readOnlyHintindicates tools safe to call without side effectsdestructiveHintsignals tools that modify browser state, requiring more careful considerationTesting
@modelcontextprotocol/sdkv1.25.1Before/After Example
Before:
After: