talira

WebMCP polyfill

The W3C Community Group's polyfill for document.modelContext

open sourceApache-2.0free

The WebMCP polyfill adds document.modelContext, the WebMCP API that lets a web page register tools for browser agents, to browsers without native support. It follows the Web Machine Learning Community Group's draft and its webmcp-types, has no runtime dependencies, and covers tool registration, discovery, execution and cancellation, the tool change and activation events, frame exposure and origin filtering. Pages load it conditionally, only where the browser lacks the API, and it works only in secure contexts. It's a pilot project of the W3C Open Source Program, and changes as the draft does.

Problems it solves

  • add document.modelContext to browsers without native WebMCP support
  • let browser agents call tools on my web page before browsers ship WebMCP
  • the official WebMCP polyfill for my website

Features

  • document.modelContext in browsers without native WebMCP
  • registerTool, getTools and executeTool with cancellation
  • toolchange, toolactivated and toolcancel events
  • frame exposure and origin filtering
  • no runtime dependencies
  • conditional loading only where the API is missing

Limitations

  • Declarative tools (from HTML forms) aren't implemented yet1
  • Only fills in the page API: a browser agent still needs the browser itself to support WebMCP1

Alternatives

The same job

These do what WebMCP polyfill does.

  1. MCP-B WebMCP runtime and MCP bridge packages for websites

Compare WebMCP polyfill with the top 3