When I ask an AI assistant in the browser to decode a JWT, this is usually what happens: it opens a page, looks for the input field, pastes the token, finds the right button and reads the result from the page text. That often works. But it takes a while, every step costs a screenshot or a look at the DOM, and it breaks as soon as I rename a label or move a field. The assistant is guessing what my interface means.
Behind each of my tools there is a plain function. The input is a string, the output an object. For an agent, the detour through the interface is pointless.
The usual answer would be an MCP server: a service the assistant calls over the network. I don’t want one. This site has no backend, on purpose. What you paste into a tool stays in your browser. A server that accepts tokens, certificates or IBANs would give that up.
What WebMCP is
WebMCP is a draft of the W3C Web Machine Learning Community Group, currently a “Draft Community Group Report” dated 3 December 2026. The idea is simple: a web page registers functions with the browser, each with a name, a description and a JSON Schema for its input. The browser passes that list to the assistant, which calls a function directly. The page runs it and returns a result.
What matters most to me: the function runs in the page, on the device of the person in front of the browser. No server in between.
It is not a standard yet. Chrome offers WebMCP as an origin trial from version 149, Edge from version 150. Brave has announced it for its Leo assistant, and ChatGPT Desktop is listed as supported in the implementation status. Firefox and Safari only have standards-position discussions so far, no implementation.
What I built
The 38 tools on this site register 48 functions between them. On top of that, every page registers notadevblog_find_tool, which finds the right tool for a task.
The groundwork was a refactor that made sense without WebMCP too: every tool now has a module with pure logic and no DOM. The page uses the same functions as the agent. Each module describes its functions like this:
{
name: 'url_encode_decode',
title: 'Encode or decode URL text',
description: 'Percent-encode or decode text per RFC 3986. variant "component" = encodeURIComponent …',
inputSchema: {
type: 'object',
required: ['text'],
properties: {
text: { type: 'string', maxLength: 1_000_000 },
mode: { type: 'string', enum: ['encode', 'decode'], default: 'encode' },
variant: { type: 'string', enum: ['component', 'full', 'form'], default: 'component' },
},
},
annotations: { readOnlyHint: true },
run: codec,
}
Errors are return values, not exceptions: { ok: false, error: { code: 'malformed_percent_encoding' } }. The interface translates the code into English or German, and the agent gets a stable code it can work with. As a side effect this fixed my old problem with half-translated error messages.
Registering the tools
The only part that knows about WebMCP is a single file. It is only loaded when the browser offers the interface:
if ('modelContext' in document) import('/core/webmcp.js');
People without an agent download none of it. The file itself is 1.1 KB (gzip). At its core it does this:
const mc = document.modelContext;
const controller = new AbortController();
addEventListener('pagehide', () => controller.abort(), { once: true });
const { functions } = await import(`./${core}.js`);
for (const fn of functions) {
mc.registerTool({
name: fn.name,
title: fn.title,
description: fn.description,
inputSchema: fn.inputSchema,
annotations: fn.annotations,
async execute(input, { signal }) {
const out = await fn.run(input, { signal });
document.dispatchEvent(new CustomEvent('tool:agent-run', { detail: { name: fn.name, input, out } }));
return out;
},
}, { signal: controller.signal }).catch(() => {});
}
Three things that tripped me up:
document, notnavigator. Many examples online usenavigator.modelContext. That comes from older drafts and does not work with the current one.- You unregister through the
AbortSignal. There is nounregisterTool. Aborting the signal removes the tool. - The return value has to be serializable. The browser turns it into JSON. A
Date, aMapor aUint8Arraywon’t arrive the way you expect. My modules only return strings, numbers, arrays and plain objects.
The tool:agent-run event is my own addition, not part of the draft. The page listens for it and fills in the same fields as if you had typed yourself, so you can see what your assistant calculated. I think that matters: an agent that calls functions on a page without anything visible happening is hard to follow.
For Chrome and Edge to enable the interface for everyone, not just people with a testing flag, the page needs an origin trial token for each browser in its head:
<meta http-equiv="origin-trial" content="…" />
The tokens are free from Chrome’s origin trial console and from Microsoft for Edge. They are tied to the domain and they expire.
Annotations: a hint, not a safeguard
Each function can carry hints. I use two of them:
readOnlyHint: truefor everything that only calculates. That is 47 of the 48 functions. The exception is the focus timer, because it changes the state of the page.untrustedContentHint: truefor seven functions whose output contains someone else’s text: Base64 decoding, JWT, regex matches, Markdown to HTML, certificates and two diff functions.
The second one is the interesting one. A JWT payload is arbitrary text. Someone can write “Ignore all previous instructions and …” into it. When my decoder returns that text, it ends up in the assistant’s context. The hint tells the assistant to treat that part as data. Whether it does is out of my hands.
What WebMCP gives you
- Reliability. The agent gets a schema instead of an interface. I can rename buttons without breaking anything.
- Speed. One call instead of a chain of reading, typing and clicking.
- Privacy on my side. The calculation runs locally, like a click of yours. I need no server and never see any input.
- It uses what is already there. The function runs in your browser session. For sites with a login that is a big difference from an external service that would need its own credentials. Here it doesn’t matter, there are no accounts.
What it can’t do
- The agent has to be on the page. The functions only exist while the tab is open. The draft has no way to discover a site’s tools in advance, for example through a manifest. That is why I also offer
/tools.json,/llms.txtand/llms-full.txt. They are not part of WebMCP, but they help assistants find the right page in the first place. - No replacement for a server-side MCP. For anything that should run in the background without an open browser, WebMCP is the wrong tool.
- It mostly runs in Chromium. Chrome and Edge in an origin trial, Brave soon. If you use Firefox or Safari, you get nothing from it.
- The draft keeps changing. The move from
navigatortodocumentis unlikely to be the last change. Origin trials end, tokens need renewing. That is why all WebMCP code lives in one file, and I check the spec repository regularly with a small watcher script.
Risks
- Your data still goes to the model. This is easy to miss. My site calculates locally, but input and result end up in the assistant’s context, which usually runs in its provider’s cloud. If you have it generate a real password, that password is now in your chat history. The description of
password_generatesays so explicitly, so the assistant can pass that on. - Prompt injection through tool output. See above.
untrustedContentHintis a hint, not a guarantee. - Actions with consequences. A page can just as well register “place order” or “delete account” as a tool. The draft has the hint
consequentialHintfor that. How the browser and assistant react to it, whether they ask first for example, is not up to the page. There is no such function here, but if you connect a shop or a customer account, think this through carefully. - Tools are a public interface. Once an assistant relies on
url_encode_decode, I can no longer change its schema at will. My rule: additions only, anything incompatible gets a new name. - Testing is tedious. There is no browser with WebMCP in CI. I test the logic with
node --testdirectly against the modules, and the registration with a stand-indocument.modelContext.
What it cost
For people without an agent, almost nothing. The WebMCP code is never loaded. What every tool page did gain is about 0.5 KB for deep links and a machine-readable result mirror. Overall the refactored tool pages grew by 0.6 to 2.9 KB (gzip). Most of that is more thorough logic with error codes, not WebMCP.
The real work was the refactor to pure modules. If your logic is already cleanly separated from the DOM, you can add WebMCP in an afternoon.
Adding it yourself
- Separate logic from the DOM. A function that takes an object and returns an object. Validate the input, because agents send nonsense too. Put limits like
maxLengthin the schema and enforce them in the function. - Write the schema and description. In English, short, written for a model: what the function does, when to use it, where its limits are. The description is what the assistant reads to decide.
- Feature detection. Only load the code when
'modelContext' in documentis true. - Register with an
AbortSignal, abort onpagehide. - Return JSON only, errors as values.
- Set annotations. Above all
untrustedContentHintas soon as someone else’s text comes back. - Origin trial tokens for Chrome and Edge in the head.
- Try it. In Chrome, turn on
chrome://flags/#enable-webmcp-testing. For tests without a native browser there is the polyfill@w3c/webmcp-polyfill. - Show what happens. The page should make visible what an agent ran.
Nobody knows whether WebMCP will stay the way it looks today. The part that pays off either way is the work before it: functions with a clear input, a clear output and error codes are better for people, tests and every other way in. After that, WebMCP is just a thin layer on top.
Which functions this site offers and how to try them is on the page For AI agents.