mcp
mcp copied to clipboard
feat: Add tool annotations for improved LLM tool understanding
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
ToolAnnotationstype import toToolSchema - Added
readOnlyHint: 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 state
- Added
destructiveHint: 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 state
- Added
titleannotations for human-readable display - Updated
server.tsto include annotations intools/listresponse
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
readOnlyHintindicates tools safe to call without side effectsdestructiveHintsignals tools that modify browser state, requiring more careful consideration- Enables safer tool execution by distinguishing observation from action tools
Testing
- [x] TypeScript types verified against
@modelcontextprotocol/sdkv1.25.1 - [x] 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
}
}
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.