WebMCP — Serverless AI Tool Calls in the Browser
- WebMCP is a W3C proposal co-developed by Google, Microsoft, and W3C — not yet a stable standard.
- Tools are JavaScript functions registered on your page via navigator.mcp.registerTool().
- Unlike backend MCP, WebMCP tools run in the live browser page — the user sees changes in real time.
Think of WebMCP as giving an AI assistant a remote control for your website. Instead of the AI fumbling through UI clicks blindly, it calls structured JavaScript functions you define — so it can filter products, submit forms, or update the UI directly inside your running page, while you stay in control and watch it happen live.
WebMCP is a W3C Web Machine Learning Working Group proposal co-developed by Google, Microsoft, and W3C. It defines a standard way for web pages to expose JavaScript-based tools that AI agents can call directly in the browser context — without a separate server, without custom middleware, and without breaking the user's live UI.
The key distinction from backend MCP: WebMCP tools run inside the running page. The user sees changes happen in real time. The human stays in the loop. This makes WebMCP ideal for human-in-the-loop workflows where an AI agent assists — rather than replaces — the user.
Setting Up the WebMCP Server Architecture
A WebMCP server typically operates over an HTTP transport layer using Server-Sent Events (SSE) for real-time communication. This allows the AI client to maintain a persistent connection to the server's toolset. We will implement a basic server structure that follows the standard protocol handshake.
The 4-step WebMCP flow works entirely inside the browser: the page loads as usual, the cloud LLM communicates with a browser-integrated agent, the agent uses the WebMCP JS API to call JavaScript functions in the live page, and those functions can update the UI or make HTTP calls to third-party services.
// Register tools on your page that the AI agent can call navigator.mcp.registerTool({ name: 'filter_products', description: 'Filter the product list by category and price range', parameters: { type: 'object', properties: { category: { type: 'string', description: 'Product category' }, maxPrice: { type: 'number', description: 'Maximum price in USD' } }, required: ['category'] }, handler: async ({ category, maxPrice }) => { // This runs directly in your live page context const products = await fetchProducts({ category, maxPrice }); renderProductGrid(products); // updates UI immediately return { count: products.length, category }; } }); console.log('WebMCP tools registered — AI agent can now use filter_products');
Exposing Tools to the AI Client
Tools are the core of WebMCP. They represent JavaScript functions registered on your page that the AI agent can discover and call. Unlike backend MCP which requires a separate server process, WebMCP tools live in your page's JavaScript context — meaning they have direct access to your DOM, your app state, and your existing frontend code.
This is the fundamental difference from backend MCP: when a WebMCP tool runs, the user sees the result immediately in the live UI. No separate agent-provided interface. No manual wiring. The human stays in control and in the loop.
// Tool definitions follow JSON Schema — same pattern as backend MCP // but handler runs in-browser, not on a server navigator.mcp.registerTool({ name: 'calculate_revenue_projection', description: 'Calculates quarterly growth and updates the dashboard chart', parameters: { type: 'object', properties: { current_arr: { type: 'number', description: 'Current Annual Recurring Revenue' }, growth_rate: { type: 'number', description: 'Expected quarterly growth rate (0-1)' } }, required: ['current_arr'] }, handler: async ({ current_arr, growth_rate = 0.1 }) => { const q1 = current_arr * (1 + growth_rate); const q2 = q1 * (1 + growth_rate); // Update the live chart in the page window.revenueChart.update([current_arr, q1, q2]); return { q1: q1.toFixed(2), q2: q2.toFixed(2) }; } });
// User sees the revenue projection rendered immediately
| Feature | WebMCP (Browser) | Backend MCP (Server) | Standard REST API |
|---|---|---|---|
| Where tools run | Inside live browser page | Separate server process | Server endpoint |
| UI integration | ✅ Live page updates | ❌ Agent provides own UI | ❌ No awareness |
| Human in loop | ✅ User sees changes live | ⚠️ Manual wiring needed | ❌ None |
| Tool discovery | ✅ Auto via navigator.mcp | ✅ Auto via tools/list | ❌ Manual (Swagger) |
| Setup required | JS in your page only | Separate MCP server | REST endpoints |
| Spec status | W3C Proposal (early) | Open standard (stable) | Mature standard |
🎯 Key Takeaways
- WebMCP is a W3C proposal co-developed by Google, Microsoft, and W3C — not yet a stable standard.
- Tools are JavaScript functions registered on your page via navigator.mcp.registerTool().
- Unlike backend MCP, WebMCP tools run in the live browser page — the user sees changes in real time.
- The human-in-the-loop model is WebMCP's core advantage over server-side AI integrations.
- Tool schema quality directly determines how accurately the AI agent selects and calls your tools.
⚠ Common Mistakes to Avoid
Interview Questions on This Topic
- QWhat is WebMCP and how does it differ from backend MCP?Reveal
- QWhy is the human-in-the-loop aspect important in WebMCP?Reveal
- QWhat organisations are behind WebMCP?Reveal
- QWhen would you choose WebMCP over backend MCP?Reveal
Frequently Asked Questions
Can I use WebMCP in production today?
Not in stable browsers — WebMCP is still a W3C proposal. Monitor the Web Machine Learning Working Group at github.com/webmachinelearning/webmcp for ratification updates.
Does WebMCP work with any AI model?
Yes, as long as the browser-integrated agent supports the WebMCP protocol. The tools you register are model-agnostic — the schema-driven approach works with any LLM that can call structured tools.
What is the difference between a WebMCP tool and a regular JavaScript function?
A WebMCP tool is a regular JavaScript function wrapped in a structured schema (name, description, parameters) and registered with the browser agent via navigator.mcp. The schema is what makes the function discoverable and callable by an AI agent.
Developer and founder of TheCodeForge. I built this site because I was tired of tutorials that explain what to type without explaining why it works. Every article here is written to make concepts actually click.