WebMCP, tools in the page script

There is also the case of a page already open in the browser that wants to offer, in its own script, the tools an agent can invoke there. That is the cut of WebMCP, in the protocols index.

What the document describes

The document published at https://webmachinelearning.github.io/webmcp/ describes the WebMCP API as a JavaScript interface that lets a developer expose web application functionality as tools: JavaScript functions with natural language descriptions and structured schemas, which can be invoked by agents, including the browser's own agents, and by assistive technologies. The same text states that web pages that use WebMCP can be thought of as Model Context Protocol servers that implement tools in client-side script instead of on the backend, and that WebMCP enables collaborative workflows in which users and agents work together within the same web interface, reusing existing application logic, with shared context and user control.

The official repository README phrases the cut in nearby terms: WebMCP lets developers expose functionality as tools designed for AI agent ingestion, invocable by agents in the browser, in iframes or in extensions, over content that was traditionally designed for human interaction.

Status and stewardship

The document presents itself, in its own header, as a Draft Community Group Report, with status CG-DRAFT. In the «Status of this document» section, it states that the specification was published by the Web Machine Learning Community Group, and that it is not a W3C Standard nor is it on the W3C Standards Track. I leave that explicit, with that attribution, for as long as the page still says so. The header of the published spec does not carry a protocol version number of the WebMCP 1.0 kind. The status is that of this Community Group report.

The editors listed in the header of the published report are Brandon Walderman (Microsoft), Khushal Sagar (Google), Dominic Farolino (Google) and Samuel Dallstream (Microsoft). Institutional stewardship, according to the document itself, sits with the Web Machine Learning Community Group, under the W3C Community Contributor License Agreement. The canonical repository is https://github.com/webmachinelearning/webmcp.

How a page registers a tool

In the published spec, each Document has document.modelContext. The ModelContext interface provides registerTool, getTools and executeTool, plus handlers for tool changes, activation and cancellation. Registration happens in a secure context. The permissions policy uses the "tools" feature.

The official ModelContextTool dictionary, in section 4.2.1 of the spec, includes name and description as required fields, title as a label for the UI, inputSchema and outputSchema as JSON Schema objects, execute as a required callback, and optional annotations, among them readOnlyHint, untrustedContentHint, consequentialHint and debugging. The normative rules for name, in the registerTool algorithm, reject an empty string, a length greater than 128, and characters outside ASCII alphanumeric, "_", "-" or ".". An empty description is also invalid.

The README describes the in-browser flow: the page registers tools; the browser agent invokes them; the page runs client-side logic and updates the interface. That cut is contrasted, in the same README, with backend integrations such as MCP or OpenAPI, which bypass the service's web UI. There is exploration of a declarative API based on an HTML form; that appears as future exploration, not as the current normative registration mechanism.

An official example

The example below comes from the official documentation, the repository README, at https://raw.githubusercontent.com/webmachinelearning/webmcp/main/README.md, in the section «Imperative Tool Registration: document.modelContext». It is the registration of the add-todo tool, copied as the source publishes it.

const controller = new AbortController();

await document.modelContext.registerTool({
  name: "add-todo",
  description: "Add a new item to the user's active todo list",
  inputSchema: {
    type: "object",
    properties: {
      text: { type: "string", description: "The text content of the todo item" }
    },
    required: ["text"]
  },
  async execute({ text }) {
    // Reuse existing client-side application logic and update UI.
    await addTodoItemToCollection(text);
    
    return {
      content: [
        {
          type: "text",
          text: `Added todo item: "${text}" successfully.`
        }
      ]
    };
  }
}, { signal: controller.signal });

// To unregister the tool later, abort the signal.
// controller.abort();

Relation to MCP

The published spec, in the introduction, says that pages with WebMCP can be thought of as MCP servers that implement tools in client-side script, and it references the MCP specification. The README records that the group considered adopting the full MCP spec directly in the browser, without creating a web-native API, and did not take that path. The official reasons are that MCP was built primarily for server-to-client and stdio/SSE process communication, and that it lacks native web concepts such as origins, standard browser permissions, DOM integration and tab-level lifecycle management; and that coupling a web API directly to an actively evolving backend protocol would hinder backward compatibility and platform stability. Instead, according to the same README, WebMCP derives direct inspiration and shares a common vocabulary with MCP, for example tools, schemas and parameters, in a solution designed natively for the web platform.

For as long as the Community Group document keeps that status, I read it as that group's draft, with the API living in the page script. The rest of the map is in the index.

Sources