Context Over MCP: Build a WebMCP Tool From Scratch A developer has published a walkthrough for building a WebMCP tool from scratch, registering a "score_facts" tool directly on a web page via the native document.modelContext API in Chrome or a polyfill fallback. The guide emphasizes returning errors as data rather than throwing, validating input before execution, and marking tools with a readOnlyHint annotation so agents can recover cleanly. Part IV showed three tools already registered, already working, on someone else's page. This is the version where you register one on yours — a real tool, with the same failure modes any WebMCP tool has, fixed the same way. No build step, no bundler, no dependency you haven't chosen yourself. Save a blank index.html , serve it with python3 -m http.server , open http://localhost:8000 , and follow along. Opened straight from disk, the page has no origin and the tools won't run. document.modelContext exists natively in Chrome behind a flag chrome://flags/ enable-webmcp-testing . Everywhere else, a polyfill can provide the same surface. Check for the real thing first, fall back explicitly, and know which one you got — don't silently assume either: