Skip to content

Comments

feat: Add tool annotations for improved LLM tool understanding#142

Open
bryankthompson wants to merge 1 commit intoBrowserMCP:mainfrom
bryankthompson:feat/add-tool-annotations
Open

feat: Add tool annotations for improved LLM tool understanding#142
bryankthompson wants to merge 1 commit intoBrowserMCP:mainfrom
bryankthompson:feat/add-tool-annotations

Conversation

@bryankthompson
Copy link

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

  • Added ToolAnnotations type import to ToolSchema
  • Added readOnlyHint: true to read-only tools:
    • wait - Only pauses execution, no browser state changes
    • snapshot - Captures current page state without modification
    • getConsoleLogs - Reads existing console logs
    • screenshot - Captures image of current page state
  • Added destructiveHint: true to tools that interact with/modify the browser:
    • navigate - Changes current URL
    • goBack / goForward - Modifies browser history position
    • pressKey - Simulates keyboard input
    • click - Triggers element interactions
    • drag - Moves elements
    • hover - Can trigger hover events
    • type - Enters text into elements
    • selectOption - Changes form selection state
  • Added title annotations for human-readable display
  • Updated server.ts to include annotations in tools/list response

Why This Matters

  • Annotations provide semantic metadata that helps LLMs understand tool behavior
  • LLMs can make better decisions about when to use tools and in what order
  • readOnlyHint indicates tools safe to call without side effects
  • destructiveHint signals tools that modify browser state, requiring more careful consideration
  • Enables safer tool execution by distinguishing observation from action tools

Testing

  • TypeScript types verified against @modelcontextprotocol/sdk v1.25.1
  • Annotation values correctly categorize read-only vs destructive operations
  • Note: Full build requires monorepo setup (workspace dependencies)

Before/After Example

Before:

{
  name: "browser_snapshot",
  description: "Take a screenshot of the current browser state"
  // No semantic metadata
}

After:

{
  name: "browser_snapshot",
  description: "Take a screenshot of the current browser state",
  annotations: {
    title: "Snapshot",
    readOnlyHint: true
  }
}

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>
@bryankthompson
Copy link
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants