I spend a lot of my time thinking about developers who are new to a platform, and what usually decides whether they succeed is how much effort it takes to get the first useful thing done. With more and more of the web being written by an agent, and more of it being read by one too, I find myself asking:
"Do things need to look different when an agent is the one reading your websites to get things done?"
To answer that, it helps to know what the agent actually sees, because it isn't the page you see on your screen. When a browser loads your page it builds the DOM, a tree of every element, and from that a second tree called the accessibility tree, which holds the role of each element (e.g. button, link), its name and its state. That is what an agent has to work with, either as snapshots of those two trees or as screenshots of the rendered page, and then it simulates the input on top, which means a lot of guessing at every step. It adds up too: Anthropic's computer use docs put a screenshot at roughly 1,000 to 1,800 input tokens!
It is a bit like working out what a restaurant serves by wandering into the kitchen and looking around. The agent only knows what is there by what it can read, and if something isn't in the tree, or has no name, it may as well not exist. WebMCP flips that around. Rather than the agent inferring what your page can do, the page hands over the menu and says what it can do.
I added WebMCP to my own site, anisha.dev, to see what it actually takes, and this post is what I did, how you can test it yourself, and the things that tripped me up along the way.
So what is WebMCP?
WebMCP is a proposed web standard that lets a page expose tools to an AI agent running in the browser. A tool is a function with a name, a description and an input schema, and the agent can call it directly rather than clicking around the page. If you have used MCP servers before, it is the same idea, except the "server" is the page you already have open, and it can use the same code and state as your UI.
It is still a draft, so expect things to move. At the time of writing you register tools with document.modelContext.registerTool, and it only works in Chrome behind a flag. The spec lives in the webmachinelearning/webmcp repo if you want to follow along.
What I like about WebMCP is that it puts the site owner in control. You decide what is exposed, what it is called, and what it is allowed to change.
What did I add to my site?
My site is a small React and Vite app with a handful of pages: blog, talks, code, about and contact. I started with the thing I most wanted an agent to be able to do, which is search my blog posts, and then asked what else someone visiting would want to know: what has she written, where has she spoken, and what has she built. Each of those became a read only tool that returns the same data the page shows, and I added one more so an agent can move around, since the site is a single page app.
Here is what a tool looks like:
document.modelContext.registerTool( { name: 'search-blog-posts', title: 'Search blog posts', description: "Search Anisha's blog posts by keyword.", annotations: { readOnlyHint: true }, inputSchema: { type: 'object', properties: { query: { type: 'string' }, limit: { type: 'number' } }, }, execute: ({ query, limit }) => { /* search, return JSON text */ }, }, { signal: controller.signal }, ); I added four of them, all registered in one file, src/webmcp.ts:
- search-blog-posts: search my dev.to posts by keyword, with an optional limit
- list-talks: talks, workshops and podcasts, filtered by keyword or year, with upcoming talks listed separately
- list-projects: my open source projects and Vega sample apps
- navigate-to-page: show a page to the user
A few decisions are worth explaining:
- The tools and the pages share code. The blog page and
search-blog-postsuse the samesearchPostsfunction, so an agent finds exactly what a visitor would, so there is no second copy of the logic to keep in sync. I borrowed this idea from Sarah Drasner's WebMCP demo, where the "add to cart" button and the agent's tool call the same function. - Unregistering is an AbortSignal. There is no
unregisterTool. You pass a signal when you register and abort it when you are done, which fits a React effect cleanup nicely. - Annotations are not decoration. I marked the three lookups with
readOnlyHint: true. As you will see in a moment, that decides whether the agent has to ask the user for permission. - I left the contact form out on purpose. A tool that acts on someone's behalf should have a confirmation step, and a
mailto:link doesn't.
How can you test it?
You need Chrome 155 or newer (I used 157), and then:
- Clone Google's example extension, GoogleChromeLabs/webmcp-extension, then follow its README: copy
.env.exampleto.env, add a model and an API key (it supports Gemini, OpenAI, Anthropic and Ollama, and a free Gemini key from Google AI Studio is the quickest way to start), runnpm install,npm run serverandnpm run build. - In
chrome://extensions, turn on Developer mode, choose Load unpacked and select thedistfolder. - Turn on
chrome://flags/#enable-webmcp-testingand relaunch. - Open your site, then open the extension's side panel and ask it something.
To check your tools registered before involving an agent at all, open the DevTools console and run:
await document.modelContext.getTools() If you get your tools back, the page side is working and any problem is in the agent or the setup. The extension also lists them for you: click the chip above the chat box, then View actions, and you get the tools the page has registered.
Notice that the list shows each tool's description, not its name or title. That means your descriptions are not just for the agent, they are the labels your users see, so I kept them to one short sentence and moved the detail, like how the search matches words, into the parameter descriptions.
Inspecting the trace at /logs
The part I ended up using most is the extension's log page. When you run npm run server, the backend prints a link to /logs on 127.0.0.1:3000, with a token in the URL that it swaps for a cookie, and it streams every call live.
Each entry is one request to the model, with its status and how long it took. Expand it and you get the full request payload: the chat id, the user's message, and every tool the model was offered, with the descriptions and schemas exactly as it saw them. Underneath is the response, which is either the tool calls it decided to make, with their arguments, or its final answer.
This is the best way I found to see where an agent is struggling, because you can read the trace instead of guessing. If it searched three times, you can see the three queries. If it picked the wrong tool, you can see what it was told about each one. Several of the problems I describe below only made sense once I could read the trace.
How did I write the evals?
Now the trace tells you what happened on one run, but that was also its limit. I only spotted a problem if I happened to ask the right question, and every run was a model call that took time, cost money and depended on a model being available, which mine often wasn't. A search that quietly returns nothing for "AI agents" doesn't look like a bug in the trace, it looks like an agent that found nothing, and I would only have noticed if I had tried that exact prompt.
That is where evals come in. An eval is a repeatable check that something behaves the way you expect. Mine are on the simple end, because they call my tools directly and check what they return, with no model involved, so they are fast and I can run them every time I change something.
My first attempt checked the search against a handful of hard-coded post titles, and it found a real bug straight away: searching for "AI agents" or "in-app purchases" returned nothing, because I was matching the whole query as one chunk of text. Matching every word in any order, plus a few aliases, took it from 9 of 12 checks passing to all of them.
Then I made it less prescriptive. Hard-coded titles break the moment I publish a new post, so the current checks come from the site's own data instead. Every tag should find every post that has it, every post should be found by its own title, word order shouldn't matter, and every Vega sample should be reachable through list-projects. If I add a post tomorrow, nothing needs updating.
I will be honest, though: evals are probably the area I most need to work on. What I have only checks that the tools return the right things, not that an agent picks the right tool or gives a good answer, and the agent runs I did were single runs on a small model, so I wouldn't read too much into them. I would love to hear how you are doing it!
Let's see it in action!
In the video I load the site, check the tools in the extension, ask the agent a few questions about my blog, talks and projects, and then open the /logs page to read the trace of what it did and which tools it called.
What next?
If you want to try this on your own site:
🔍 Pick one thing a visitor does most often, like searching, and make that your first tool.
🔗 Share the code between the UI and the tool, so they can't drift apart.
🧪 Test with the extension, and watch the log dashboard, not just the answers.
💬 Tell me how it goes!




