Junior 3 min · March 22, 2026

WebMCP — Serverless AI Tool Calls in the Browser

WebMCP is a W3C proposal from Google and Microsoft that lets AI agents call JavaScript functions directly in live pages — no separate server needed.

N
Naren · Founder
Plain-English first. Then code. Then the interview question.
About
Plain-English First

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.

webmcp-register-tools.jsJAVASCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// 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');
Output
WebMCP tools registered — AI agent can now use filter_products
Still a W3C Proposal
WebMCP is an early-stage specification. The navigator.mcp API is not yet available in stable browsers. Follow the W3C Web Machine Learning Working Group for ratification status before using in production.
WebMCP Browser Architecture Flow (Full Detail) Complete architecture showing 4 steps: Browser loads page, LLM in cloud communicates with browser-integrated agent, agent uses WebMCP JS to execute JavaScript functions in page context, WebMCP functions update UI and call HTTP APIs. WebMCP Browser Architecture Co-developed by Google, Microsoft & W3C — AI agents interact via JavaScript AI Platform LLM in the cloud (Claude, GPT, Gemini…) WEB BROWSER Browser Agent Mediates AI ↔ page navigator.modelContext WebMCP JS Running Page Context <index.html / App.tsx> Third-party Service APIs & Services 2 LLM communicates with browser-backed agent 3 Agent uses WebMCP API to execute JS functions directly in the running page context 4 WebMCP functions update UI & call HTTP APIs W3C Web Machine Learning Working Group Proposal THECODEFORGE.IO
Detailed WebMCP Architecture: From LLM Intent to Browser-Native API Execution.
thecodeforge.io
Webmcp Ai Tool Integration

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.

webmcp-tool-schema.jsJAVASCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// 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) };
  }
});
Output
// AI agent calls the tool → chart updates live in the browser
// User sees the revenue projection rendered immediately
Schema Integrity
The more descriptive your tool descriptions and parameter schemas are, the more accurately the LLM will select and use them. Write descriptions as if explaining to a junior developer what the function does and when to call it.
WebMCP vs Backend MCP Comparison Side-by-side comparison of WebMCP (browser-native, JS tools in page) vs traditional Backend MCP (server-side MCP server, no UI by default). WebMCP keeps the user in control with live UI updates; backend MCP requires the agent to provide its own UI. WebMCP vs Backend MCP Browser-native tool integration vs traditional server-side MCP ✓ WebMCP Browser-native · JS tools · UI stays live AI Platform LLM in the cloud WEB BROWSER Browser Agent Human in the loop WebMCP JS Exposes JS functions as AI tools in page <index.html> live ✓ User sees live UI changes as they happen Agent acts on the real running page — no separate UI needed Third-party Service (example.com) via HTTP ✗ Backend MCP Server-side · No UI by default · Manual wiring AI Platform LLM in the cloud Agent Frontends web/app — wired manually WEB BROWSER Browser-integrated agent (passive — no WebMCP JS) <index.html> MCP Server Separate process Agent interacts directly example.com ✗ No automatic UI — must be provided by agent Agent-service interaction takes place without an associated UI HTTP ✓ Live UI ✓ Human in loop ✓ JS native ✓ No server needed ✗ No UI ✗ Manual wiring ✗ Extra server ✗ Agent provides UI THECODEFORGE.IO
thecodeforge.io
WebMCP (browser-native) vs Backend MCP (server-side) — Architecture Comparison
Webmcp Ai Tool Integration
FeatureWebMCP (Browser)Backend MCP (Server)Standard REST API
Where tools runInside live browser pageSeparate server processServer 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 requiredJS in your page onlySeparate MCP serverREST endpoints
Spec statusW3C Proposal (early)Open standard (stable)Mature standard

Key takeaways

1
WebMCP is a W3C proposal co-developed by Google, Microsoft, and W3C
not yet a stable standard.
2
Tools are JavaScript functions registered on your page via navigator.mcp.registerTool().
3
Unlike backend MCP, WebMCP tools run in the live browser page
the user sees changes in real time.
4
The human-in-the-loop model is WebMCP's core advantage over server-side AI integrations.
5
Tool schema quality directly determines how accurately the AI agent selects and calls your tools.
INTERVIEW PREP · PRACTICE MODE

Interview Questions on This Topic

Q01JUNIOR
What is WebMCP and how does it differ from backend MCP?
Q02JUNIOR
Why is the human-in-the-loop aspect important in WebMCP?
Q03JUNIOR
What organisations are behind WebMCP?
Q04JUNIOR
When would you choose WebMCP over backend MCP?
Q01 of 04JUNIOR

What is WebMCP and how does it differ from backend MCP?

ANSWER
WebMCP is a W3C proposal that lets web pages expose JavaScript functions as AI-callable tools running directly in the browser. Backend MCP runs tools on a separate server process. The key difference: WebMCP tools execute in the live page context, so the user sees UI changes in real time and stays in the loop. Backend MCP requires the agent to provide its own UI separately.
FAQ · 3 QUESTIONS

Frequently Asked Questions

01
Can I use WebMCP in production today?
02
Does WebMCP work with any AI model?
03
What is the difference between a WebMCP tool and a regular JavaScript function?
🔥

That's Advanced JS. Mark it forged?

3 min read · try the examples if you haven't

Previous
Observables and RxJS
21 / 27 · Advanced JS
Next
Introduction to Angular: Components, Modules and Services