ADR-046: Browser-Native WebMCP Pairing Server /mcp
Context
The site already serves remote and IDE assistants via a stateless Streamable HTTP MCP server at POST /mcp and /llms.txt (ADR-039). A second class of agents now runs inside the visitor’s active browser tab (Chromium built-in agents, co-browsing extensions, assistive tools) via the WebMCP standard (document.modelContext and Declarative Agentic Forms). Unlike remote HTTP clients, an in-tab agent shares the live DOM with the visitor and can navigate pages, switch theme or language, and run interactive analyzers visually on screen.
Decision
Pair server-side POST /mcp with progressive, zero-polyfill Browser-Native WebMCP gated by webMcp (FEATURE_WEBMCP, default-on):
1. Imperative SPA Tools (useWebMCP over document.modelContext): Register get-current-view-context (readOnlyHint: true, typed outputSchema), navigate-site (sections, ADRs, articles, and demo tabs), set-display-preferences (dark/light theme and ISO 639-1 display languages), and ask-concierge (opens the AI concierge when contactChat is enabled), with AbortSignal lifecycle cleanup and structured { error } validation responses.
2. Declarative Agentic Forms: Annotate semantic <form> elements on Job-Description Match (compare-job-fit), Live TLS Certificate Lookup (inspect-tls-certificate), and Architecture Review Board Round 1 (evaluate-architecture-proposal) with toolname, tooldescription, toolautosubmit, and toolparamdescription, returning structured results directly to browser agents via SubmitEvent.agentInvoked and respondWith(promise). High-impact communication forms (contact send, CV request) are deliberately excluded so real emails always require human confirmation and Turnstile.
3. Progressive Enhancement: Non-supporting browsers ignore tool* attributes and skip registration with zero polyfill overhead; active agent interactions highlight via @supports-guarded :tool-form-active and :tool-submit-active CSS rules.
Consequences
Benefits:
* Two-plane agentic coverage: stateless HTTP /mcp for headless/IDE agents and in-tab WebMCP for co-browsing browser agents.
* Preserves all backend guardrails: WebMCP actions flow through secureFetch, keeping Firebase App Check, per-IP rate limits, and the daily AI budget intact.
* Zero runtime cost or polyfill bloat on browsers without WebMCP.
Trade-offs:
* WebMCP is currently an Early Preview / Origin Trial in Chromium 146+; isolating hooks and attributes in WebMcpTools.tsx and src/utils/webmcp.ts behind FEATURE_WEBMCP keeps future spec updates contained.
Alternatives considered
1. Relying only on server-side POST /mcp: Rejected for co-browsing — a remote endpoint cannot drive the visitor’s live SPA view, theme, language, or on-screen demo scorecards.
2. Shipping a client-side WebMCP polyfill: Rejected — adds unnecessary bundle weight when native feature detection is free.
3. Auto-submitting contact or CV forms via WebMCP: Rejected — sending real messages or personal data requests must remain strictly human-confirmed.