Skip to content

feat: add WebMCP tool discovery support#8

Open
pyyush wants to merge 5 commits intomainfrom
feat/webmcp-support
Open

feat: add WebMCP tool discovery support#8
pyyush wants to merge 5 commits intomainfrom
feat/webmcp-support

Conversation

@pyyush
Copy link
Contributor

@pyyush pyyush commented Feb 23, 2026

Summary

  • Adds discovery/discover protocol method that bridges BAP with the W3C WebMCP standard
  • Detects tools exposed by websites via declarative HTML attributes (form[toolname]) and the imperative navigator.modelContext API
  • WebMCP tools also available through existing agent/observe flow via opt-in includeWebMCPTools parameter
  • New discover_tools MCP tool for AI agents to discover page-exposed tools
  • New browser tools decision guide comparing BAP with Playwright MCP and Playwright CLI

Changes

Protocol (packages/protocol)

  • New discovery.ts types: WebMCPToolSource, WebMCPToolSchema, DiscoveryDiscoverParams/Result
  • Extended AgentObserveParams with includeWebMCPTools and AgentObserveResult with webmcpTools
  • Added discovery/discover to BAPMethodSchema enum

Server (packages/server-playwright)

  • discoverWebMCPTools() helper with progressive feature detection (declarative + imperative, try-catch, graceful degradation)
  • handleDiscoveryDiscover() handler + dispatch case
  • Extended handleAgentObserve() to optionally include WebMCP tools

Client SDK (packages/client)

  • discoverTools(pageId?, options?) method on BAPClient

MCP Bridge (packages/mcp)

  • discover_tools tool definition + handler
  • includeWebMCPTools param added to observe tool

Docs

  • docs/browser-tools-guide.md — fact-based decision guide: BAP vs Playwright MCP vs Playwright CLI with reproducible benchmark data, architecture overview, and recommendation flowchart
  • docs/webmcp-comparison.md — full BAP vs WebMCP comparison + "Decision Guide: When to Use What" section
  • README: added discover_tools to tools table, "Choosing a Browser Tool" section, WebMCP decision guide link
  • README: fixed CLI command count (26→23), replaced unverified "40x fewer tokens" claim with benchmark-backed "73% fewer tool calls"
  • TODO-ADOPTION.md — adoption plan with messaging guide; marked benchmark table item as done

Tests (5 new test files, all passing)

  • Protocol schema validation, agent observe extensions, client methods, MCP tool definitions, server structure

Test plan

  • pnpm build — all 7 packages build cleanly
  • pnpm typecheck — no type errors (10 tasks)
  • pnpm test — 450 tests pass, 0 failures
  • pnpm lint — 0 errors (3 pre-existing warnings)
  • All benchmark claims cite reproducible benchmark suite with exact scenario source files
  • CLI command count (23) and MCP tool count (23) verified against source code
  • Manual: run MCP server, call discover_tools on a regular page → empty array
  • Manual: test on a page with WebMCP declarative attributes → tools returned

Bridge BAP with the W3C WebMCP standard by adding a discovery/discover
protocol method that detects tools exposed by websites via declarative
HTML attributes (form[toolname]) and the imperative navigator.modelContext
API. WebMCP tools are also available through the existing observe flow
via an opt-in includeWebMCPTools parameter.

- New protocol types: WebMCPTool, DiscoveryDiscoverParams/Result
- Server: progressive feature detection with graceful fallback
- Client SDK: discoverTools() method
- MCP bridge: discover_tools tool + observe integration
- Docs: BAP vs WebMCP comparison, README section, adoption guide update
Add docs/browser-tools-guide.md — a fact-based decision guide comparing
BAP with Playwright MCP and Playwright CLI, including reproducible
benchmark data, architecture overview, and recommendation flowchart.

- README: add discover_tools to tools table, add "Choosing a Browser Tool" section
- docs/webmcp-comparison.md: add "Decision Guide: When to Use What" section
- TODO-ADOPTION.md: mark benchmark table item done, add comparison framing anti-pattern
- README "Why BAP?" now cites benchmark result (73% fewer calls) instead
  of unverified "40x fewer tokens"
- README CLI docs link: 26 commands → 23 commands
- webmcp-comparison.md ecosystem row: 26 → 23 commands
Replace inflated "73% fewer tool calls" and "40x token reduction" claims
with verified numbers from the reproducible benchmark suite.

Three-variant model: BAP Standard (observe-first, apples-to-apples) uses
~15% fewer calls than Playwright. BAP Fused (optimization layer) uses ~37%
fewer. Add "Where Playwright Wins" section covering latency, element
disambiguation, setup simplicity, and ecosystem.
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.

1 participant