Skip to content

feat(webmcp): call the tools a page registers through WebMCP - #30

Merged
compnew2006 merged 2 commits into
mainfrom
feat/webmcp-support
Oct 12, 2026
Merged

compnew2006 merged 2 commits into
mainfrom
feat/webmcp-support

Conversation

@compnew2006

Copy link
Copy Markdown
Owner

What

This PR adds two tools, browser_webmcp_list and browser_webmcp_call. Some sites expose their own actions to agents through WebMCP, using document.modelContext.registerTool(...) or a <form toolname>. On those sites, an agent can now list the tools and call one by name with an input object, instead of clicking through the UI. Pages without WebMCP behave exactly as before.

How

  • Transport. A self-contained page runner (extension/lib/webmcp-page.js) is evaluated in the page's main world over CDP.
    • The call is an awaited expression, because REPL mode does not unwrap a returned promise.
    • The runner returns a JSON string, and the handler (extension/handlers/webmcp.js) validates every field of it.
  • Safety gates, checked against the live tool at call time:
    • consequentialHint tools and toolautosubmit forms need confirm: true.
    • A form that waits for the user's submit returns DECLARATIVE_NEEDS_USER; the agent shield would otherwise block that submit.
    • Declarative forms are found in the light DOM, in open and closed shadow roots, and in same-origin frames, via DOM.performSearch. If that scan fails, calls fail closed with FORM_SCAN_FAILED.
    • browser_shortcuts refuses to save confirm: true.
  • Untrusted content. Tool names, descriptions, schemas and output are page-authored. The handler sets untrustedContent: true on them; the flag is never taken from the page.
  • Timeouts and navigation. A timeout aborts the tool page-side, so it is never mistaken for a frozen tab. A navigation during a call returns a non-error status: "unknown".
  • Frames. Tools with the same name in different frames are told apart by frame / frameUrl.

The design and its review history are in specs/webmcp-support/:

Stage Verdict
Independent plan review REJECT, then APPROVE WITH CHANGES
Independent audit FAIL, then PASS WITH FINDINGS, then PASS

Verification

Check Result
npm run build / typecheck / lint exit 0
npm test 629 passed, 44+ of them new for WebMCP
npm run test:coverage thresholds pass
git diff --check clean
npm run smoke:webmcp 15/15

npm run smoke:webmcp runs the real handlers against an isolated headless Chrome 155 (temporary profile, --enable-features=WebMCP). It needs a local Chrome 149 or newer, so it is not part of npm test or CI.

Not done here

  • An end-to-end run through a live daemon and extension in a daily-use Chrome. That needs chrome://flags/#enable-webmcp-testing, an extension reload, and npm run daemon:restart.
  • No version bump.
  • Closed-shadow-root detection relies on DOM.performSearch, an experimental CDP command. Re-run npm run smoke:webmcp after Chrome upgrades.

🤖 Generated with Claude Code

Add browser_webmcp_list and browser_webmcp_call. Pages that adopt WebMCP
register tools with document.modelContext.registerTool() or
<form toolname>; agents can now list those tools and call them by name
with an input object, instead of driving the page's UI.

- Runner (extension/lib/webmcp-page.js) is stringified and evaluated in
  the page over CDP as an awaited expression (replMode does not unwrap a
  returned promise), and returns a JSON string.
- Safety gates: consequentialHint tools and toolautosubmit forms need
  confirm:true; forms that wait for a user submit return
  DECLARATIVE_NEEDS_USER. Declarative forms are found in the light DOM,
  open and closed shadow roots and same-origin frames (DOM.performSearch);
  if that scan fails, calls fail closed (FORM_SCAN_FAILED).
- Page-authored content is flagged untrustedContent by the handler,
  which also validates everything the page returns.
- Timeouts abort the tool page-side; navigation during a call is a
  non-error status:"unknown". browser_shortcuts refuses a saved
  confirm:true.
- npm run smoke:webmcp drives the real handlers against an isolated
  headless Chrome (15 checks); 629 unit tests pass.

Built through specs/webmcp-support (spec, plan, independent review,
tasks, implementation report, independent audit: PASS).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e3a99bd3-ff2a-4d2d-9dff-91c6e6130aa7

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

A "Sites with their own tools (WebMCP)" section under "Using it": how to
turn WebMCP on, the list → call → confirm workflow, the safety-gate and
result-code tables, and limits. Also a comparison row, the smoke:webmcp
command in Development, and an FAQ entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@compnew2006
compnew2006 merged commit 1e47bdd into main Oct 12, 2026
6 checks passed
compnew2006 pushed a commit that referenced this pull request Oct 15, 2026
…vements

Conflicts were only in the docs: the tool count is now 34 (31 + the two
WebMCP tools + browser_emulate), and the WebMCP lines sit next to the
updated console/network lines in AGENTS.md and llms.txt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@compnew2006
compnew2006 deleted the feat/webmcp-support branch October 16, 2026 14:25
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