WebMCP
navigator.modelContext is deprecated. Move to document.modelContext
The specification relocated the API in July 2026 and Chrome 150 deprecated the old position while the origin trial still serves it. A short migration with a long tail of quiet breakage if you skip it.
Last reviewed 27 August 2026
If you built anything against WebMCP before late July 2026, you wrote navigator.modelContext. That is no longer where the API lives.
What changed and why
On 21 July 2026 the specification moved the interface from navigator to document. The reasoning is sound: tools belong to a document, not to a browser. A tab showing your checkout and a tab showing your blog expose different capabilities, and navigator is shared across the whole browsing context in a way that made that awkward to express.
Chrome deprecated navigator.modelContext in version 150. The origin trial continues to serve it — which is the dangerous part, because your code keeps working right up until it does not.
The migration
// Before
await navigator.modelContext.registerTool({ /* … */ });
// After
await document.modelContext.registerTool({ /* … */ });
// During the overlap, resolve once and log when you land on the old path
function modelContext() {
if ("modelContext" in document) return document.modelContext;
if ("modelContext" in navigator) {
console.warn("[webmcp] falling back to the deprecated navigator.modelContext");
return (navigator as any).modelContext;
}
return null;
}
const mc = modelContext();
if (mc) await mc.registerTool({ /* … */ });Keep the warning. It is the only thing that will tell you which of your deployments is still on the old path once the trial stops serving it.
Everything to grep for
| Search for | Where it hides |
|---|---|
navigator.modelContext | Application source, obviously |
navigator?.modelContext | Optional-chained feature detection |
"modelContext" in navigator | Guards that will now take the wrong branch |
@mcp-b/ versions | Polyfills pinned before the move — see the polyfill page |
| Vendored snippets | Copied from tutorials written before July 2026 |
| Type definitions | A hand-written .d.ts that still augments Navigator |
| Documentation and READMEs | Where the next person on the team will read it |
We detect document.modelContext and navigator.modelContext separately. Finding the old location is not a pass — it is a partial with a migration note, because the code works today and will stop. This is one of the few findings that a source-level scan can give you before it becomes an incident.
Expect more of this
WebMCP is a Draft Community Group Report and is not on the standards track. A rename of this size in the same year the feature shipped experimentally is not an anomaly, it is what pre-standard means.
Two habits keep the cost bounded:
- Wrap the API once. A single
registerToolwrapper in your codebase turns the next relocation into a one-file change instead of a search-and-replace across a monorepo. - Define tools as data. Keep names, descriptions and schemas in a plain object, separate from the registration call. When the call signature moves, the definitions do not.
// lib/webmcp.ts — the only file that knows where the API lives
export type ToolDef = {
name: string;
description: string;
inputSchema: object;
annotations?: { readOnlyHint?: boolean; untrustedContentHint?: boolean };
execute: (args: any, ctx: { signal: AbortSignal }) => Promise<unknown>;
};
export async function register(tool: ToolDef, signal?: AbortSignal) {
const mc = "modelContext" in document ? document.modelContext : null;
if (!mc) return false;
await mc.registerTool(tool, signal ? { signal } : undefined);
return true;
}Sources
Primary documents, checked on 27 August 2026
- webmachinelearning.github.io/webmcp — W3C Web Machine Learning Community Group draft — WebIDL, annotations, permissions policy
- github.com/webmachinelearning/webmcp — Explainer repository, imperative and declarative API
- spronta.com — The State of WebMCP, July 2026 — Dates the navigator → document move to 21 July 2026 and the Chrome 150 deprecation
- developer.chrome.com/docs/ai/webmcp — Origin trial, flags, permissions policy directive
Keep reading
Check your own site against this
The Agent Readiness Score measures exactly what this article describes, and shows the evidence behind every finding.
Run the check →