Skip to main content

WebMcpShell

Client-side WebMCP (Web Model Context Protocol) integration that exposes browser-native tools to AI agents visiting the site.

Purpose

Registers structured tools via document.modelContext so browser agents can search content, fetch pages, navigate, and interact with Dex — without DOM scraping. All data tools proxy to the existing public REST API at /api/*.

When the native WebMCP API is missing, the site installs document.modelContext in two ways: an async /webmcp-polyfill.js in the root <head> (valid for React 19), and installWebMcpPolyfill() when tools register. Native Chrome 146+ modelContext is left untouched.

Components

ComponentRole
WebMcpShellRegisters tools on mount, tracks count, renders demo indicator
WebMcpDexBridgeSyncs Dex drawer callbacks when concierge is enabled
WebMcpIndicatorOptional bottom-left pill showing active tool count

Registered Tools

ToolRead-onlyDescription
content_searchYesSearch blogs, guides, livestreams, kickstarts via /api/content
content_getYesFetch full content by URL path
people_listYesList all people
people_get_profileYesGet person profile and authored content
search_typeaheadYesQuick search suggestions
get_site_infoYesDiscovery pointers (llms.txt, agents.md, OpenAPI, server MCP)
get_current_pageYesCurrent URL, path, and document title
navigate_toNoClient-side navigation to an internal path
open_dexNoOpen Dex assistant drawer (concierge enabled only)
ask_dexNoOpen Dex and send a question (concierge enabled only)

Environment Variables

VariableDefaultDescription
NEXT_PUBLIC_WEBMCP_ENABLEDtrueSet to false to disable all WebMCP registration
NEXT_PUBLIC_WEBMCP_DEMO_INDICATORtrue in dev, false in prodShow "WebMCP: N tools" indicator

Demo Instructions

  1. Use Chrome 146+ Canary with chrome://flags/#enable-webmcp-testing enabled.
  2. Visit the site over HTTPS (production or local with secure context).
  3. In development, confirm the bottom-left indicator shows registered tools.
  4. Browser agents discover tools via document.modelContext.
  5. Try: content_searchcontent_getask_dex.
  6. Compare with external server MCP at /api/mcp (same data, HTTP transport).

Usage

Mounted in app/layout.tsx:

<ConciergeProvider>
  <WebMcpDexBridge />
  ...
</ConciergeProvider>
<WebMcpShell />

Behavior Notes

  • Registration uses AbortSignal cleanup on unmount (per WebMCP best practices).
  • Dex tools register only when ConciergeProvider is active and the dex bridge is set.
  • Permissions-Policy: tools=(self) is set in next.config.ts.
  • Implementation lives in lib/webmcp/; this component is the client entry point.