browser-use-mcp-server icon indicating copy to clipboard operation
browser-use-mcp-server copied to clipboard

feat: Add tool annotations for improved LLM tool understanding

Open bryankthompson opened this issue 11 months ago • 0 comments

Summary

Adds MCP tool annotations (readOnlyHint, destructiveHint, openWorldHint) to all tools to help LLMs better understand tool behavior and make safer decisions about tool execution.

Changes

  • Added destructiveHint: true and openWorldHint: true to browser_use tool (performs browser actions, accesses external web pages)
  • Added readOnlyHint: true to browser_get_result tool (queries task status only)
  • Added title annotations for human-readable display
  • Bump MCP SDK dependency from >=1.3.0 to >=1.8.0 for annotation support

Why This Matters

  • Annotations provide semantic metadata that helps MCP clients understand tool behavior
  • Clients like Claude Code can auto-approve tools with readOnlyHint: true without user confirmation
  • Destructive tools trigger confirmation prompts for safer operation
  • openWorldHint: true indicates the tool accesses external resources (web pages)

Testing

  • [x] Syntax validation passes (python3 -m py_compile server/server.py)
  • [x] Linter passes (ruff check server/server.py)
  • [x] ToolAnnotations usage verified independently with MCP SDK 1.25.0
  • [x] Annotation values match actual tool behavior (read-only vs destructive)

Note: Full integration test was blocked by browser-use API changes (server imports browser_use.browser.browser which no longer exists in browser-use 0.11.x). This is a pre-existing issue unrelated to the annotation changes.

Before/After

Before:

types.Tool(
    name="browser_use",
    description="Performs a browser action...",
    inputSchema={...},
    # No annotations
)

After:

types.Tool(
    name="browser_use",
    description="Performs a browser action...",
    inputSchema={...},
    annotations=ToolAnnotations(
        title="Browser Use",
        destructiveHint=True,
        openWorldHint=True,
    ),
)

🤖 Generated with Claude Code

bryankthompson avatar Dec 23 '25 13:12 bryankthompson