DEV Community

hao li
hao li

Posted on

I Bridged My Real Logged-In Browser to Chrome's New WebMCP API

I Bridged My Real Logged-In Browser to Chrome's New WebMCP API

Chrome's WebMCP proposal (W3C Community Group draft, origin trial from M149) lets a web page declare typed, callable tools via document.modelContext.registerTool() — so an in-browser AI agent can call them directly instead of scraping the DOM. The official demo shows toy tools like a "greet" function. Fun, but not something you can ship.

I wanted the real thing: my actual browser, with my real sessions and cookies, exposed as WebMCP tools. So I built webmcp-bridge — the first bridge from Browser Buddy (my tool that reads your logged-in Chrome through a native host, listed on awesome-mcp-servers) to the WebMCP API.

How it works

A tiny localhost server (stdlib-only Python, no dependencies) maps Browser Buddy's tools to WebMCP-style endpoints:

  • GET /webmcp/tools → tool manifests (name, title, description, inputSchema, annotations)
  • POST /webmcp/tools/call → forwards to the Browser Buddy native host over its Unix socket

A page-side JS shim (webmcp.js) fetches the manifests and registers each tool with document.modelContext.registerTool() (falling back to navigator.modelContext on Chrome 146-era preview builds). From there, any WebMCP-capable agent discovers and calls them like any other page tool.

Two tools ship out of the box:

  • read_active_tab — read the user's active Chrome tab (URL, title, cleaned text).
  • open_and_read_url — open a URL in a background tab with the real profile (cookies/sessions included), extract readable text, close the tab. Pages behind logins, paywalls-with-session, and bot checks become callable tools.

Why not just scrape?

Because login walls, 403s, and bot detection defeat server-side fetchers — and DOM scraping is fragile by design. The tools run in your browser as you, so what you can see, the agent can read.

Security, since this opens your real browser

  • The server binds 127.0.0.1 only; the shim is same-origin by design.
  • open_and_read_url enforces a domain allowlist (~/.config/webmcp-bridge/config.json, allowed_domains). Empty means everything is allowed — with a warning baked into the tool result so an agent can see it's wide open.

Try it

pip install webmcp-bridge
webmcp-bridge   # http://127.0.0.1:18765/ — demo page included
Enter fullscreen mode Exit fullscreen mode

Then on any page:

<script src="http://127.0.0.1:18765/webmcp.js"></script>
Enter fullscreen mode Exit fullscreen mode

15 smoke tests, all green. MIT licensed. Stdlib-only Python (the JS shim is allowed to exist — WebMCP is a browser-side API).

Repo: https://github.com/hahahahahahahahah6/webmcp-bridge
PyPI: https://pypi.org/project/webmcp-bridge/

Top comments (0)