Skip to content

Add MCP annotations (readOnlyHint/destructiveHint) to tool definitions #157

@ghost

Description

Summary

The Stagehand tool definitions don't include MCP annotations (readOnlyHint, destructiveHint, idempotentHint). These are optional hints in the MCP spec that help LLMs decide how to handle tools safely.

Suggested annotations

Tool Suggested annotation Reason
browserbase_stagehand_observe readOnlyHint: true Inspects page, no side effects
browserbase_stagehand_screenshot readOnlyHint: true Captures state, no side effects
browserbase_stagehand_extract readOnlyHint: true Extracts data, doesn't modify page
browserbase_stagehand_navigate idempotentHint: true Same URL = same result
browserbase_stagehand_act destructiveHint: false Interacts with page but typically not data-destructive

Example

In src/tools/observe.ts:

const observeSchema: ToolSchema<typeof ObserveInputSchema> = {
  name: "browserbase_stagehand_observe",
  description: "Observe the current page and return a list of actionable elements.",
  annotations: {
    readOnlyHint: true,
  },
  inputSchema: ObserveInputSchema,
};

Context

I ran a benchmark of tool definition quality across popular MCP servers. This server scores 94/100 (A grade) — the basics are solid. The main gap is missing annotations. Servers like Exa and Kubernetes MCP use annotations extensively.

Full benchmark: https://wildrunai.com/blog/mcp-quality-benchmark
Validation tool: https://wildrunai.com/tools/mcp-validator

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions