diffx registers its review tools with a compatible browser through the
current WebMCP document.modelContext API. This lets a browser agent work with
the page without learning its DOM or clicking controls.
WebMCP is a draft browser API. diffx uses the current standard directly and does not load a polyfill or expose a legacy API. In browsers without WebMCP, the page continues to work normally and registers no tools.
A browser agent runs with a browser implementing WebMCP. The open page calls
document.modelContext.registerTool, and the browser decides when the agent may
invoke the registered tools. The page must remain open, and its normal browser
origin and lifecycle rules apply.
Codex, Claude Code, and OpenCode running on a local machine are coding
harnesses, not inherently browser agents. They can work with diffx without
opening its page when they support MCP 2026-07-28: configure the diffx
/mcp/contexts/{id} endpoint. A harness cannot obtain WebMCP tools merely from a
page URL unless it is driving a WebMCP-capable browser.
When the selected context's review-comments capability is enabled, the page registers:
get_review_comments: returns open comments from all enabled scopes; optionalinclude_resolved: trueincludes resolved comments.resolve_review_comment: idempotently resolves the comment identified bycomment_id.
The tools have the same input and behavior as their MCP counterparts. Results use real server comment IDs and identify every comment's lifecycle status, applicability, and whether it is currently actionable. Stale comments are returned and may be resolved by ID.
The getter is marked read-only and its comment content is marked untrusted. The resolver is marked mutating and idempotent. Both operate only against the open diffx context. They do not access unrelated contexts, websites, or external services. A worktree and a piped capture expose the same review tools when their capabilities permit them.
- The page checks for
document.modelContext.registerTool. - It registers the two tools while review comments are enabled.
- A browser agent invokes a tool through the browser, subject to browser UX and permission policy.
- The page calls diffx's same-origin, context-scoped REST API.
- The Go server reads or updates the authoritative comment store.
- A successful resolution updates the visible review state immediately.
- Tool registrations are removed when the page unmounts, its context changes, or the capability becomes unavailable. An invocation retains its original context binding; it cannot be redirected by a later switch.
Closing or navigating away from the page removes access to these WebMCP tools. Comments themselves remain on the server and are still available through the UI or MCP endpoint.
- Start diffx and open its printed URL in a WebMCP-capable browser.
- Open that browser's agent interface.
- Ask it to inspect the diffx review comments and address them.
- Confirm that only handled comments were resolved.
Example prompt:
Get the open review comments from this diffx page. Check the current code for each one, apply valid fixes, and resolve only comments you completed.
Exact invocation and confirmation UI belongs to the browser implementation.
Feature support may require a secure context; loopback localhost and
127.0.0.1 are treated as trustworthy by modern browsers.
Comment text and preserved code may contain misleading or adversarial content. They are returned as untrusted data, and agents should treat them as review evidence rather than privileged instructions.
The diffx API is unauthenticated. WebMCP does not add authentication: anyone who can reach the server can access its review data through the available HTTP interfaces. Keep the default loopback binding, or use only a trusted network.
Authentication remains outside this version. The private CLI control listener does not authenticate browser requests.
See the WebMCP specification for the current browser API.