Build log · built in public
WebMCP Example: How I Added WebMCP to a WordPress Site
This is a working WebMCP example you can test yourself. On October 18, 2026 I made this site usable by AI assistants, not just by people. Four WebMCP tools, a WordPress mu-plugin, two Contact Form 7 forms, and about an evening of work. Here is what I built, why, the actual code, and how I tested it.
By Michael Robichaud, Claude consultant · Built October 18, 2026 · Updated October 19, 2026
Short answer
You can add WebMCP to a WordPress site without a plugin from a directory: label your existing contact form with three HTML attributes, register read-only tools in a small mu-plugin, and add Chrome’s origin-trial token to every page. An assistant in Chrome can then search this site, list my services and fill in my contact form, while a person still presses Send.
Why I built it
People increasingly ask an assistant to do the legwork: “find someone who sets up Claude for a small office and get me a call.” Today that assistant has to read a page built for eyes and guess which field is which. WebMCP lets the site say it plainly: here is a tool called send_message, here are its inputs, here is what happens when you use it.
Three reasons I did it now rather than later:
- It costs almost nothing and breaks nothing. Browsers that do not support WebMCP ignore the extra attributes. Every visitor today gets the same page they got yesterday.
- I already did it once. I built the first version on Strategized.ai on October 11. Doing it a second time on a different site is how I find out what was a one-off and what is a repeatable process.
- You should be able to see the work. I tell people I set things up properly. A public build log with the real code is a better argument than a sales page.
An honest caveat: WebMCP is a proposed standard. It runs in Chrome 149 and later, on sites in Chrome’s origin trial or with a testing flag on. Very few visitors arrive with an agent that uses it today. I built it as a small, early bet, not as a traffic plan.
What is live on this site
Four tools. Two read, two write. The two that write both end in an email to me, and nothing is booked or sold through any of them.
| Tool | Type | Where | What it does | Who sends it |
|---|---|---|---|---|
search_coworkconsultant | Script (imperative) | Every page | Searches my guides, how-tos and service pages and returns titles and links. | Nobody. Read-only. |
get_services | Script (imperative) | Every page | Lists my services, read live from the pages, plus every way to reach me. | Nobody. Read-only. |
send_message | HTML form (declarative) | /contact/ | The normal contact form, labeled so an assistant can fill it in. | The person. The assistant fills it in, the person reads it and presses Send. |
agent_inquiry | HTML form (declarative) | /contact/#agents | A longer intake for an assistant acting on someone's request. No button for people. | The assistant, and only with the person's confirmation. I reply to the person to confirm before anything else happens. |
How the pieces fit together
- Chrome finds the tools. A small file on the server (a WordPress mu-plugin) registers the two read-only tools in page script and adds Chrome’s origin-trial token to every page. The contact page’s forms carry the attributes for the other two.
- The assistant reads the tool list. Each tool has a name, a plain description and a schema of its inputs. Chrome builds the schema for the two forms from the form fields themselves, including which ones are required.
- The assistant calls a tool. For the read-only tools, the page script fetches from WordPress’s own public search and page data and returns plain JSON. For the forms, Chrome fills the fields in front of the person.
- The result goes back to the assistant. The forms answer with Contact Form 7’s real result (sent, or which field is wrong), so the assistant can tell the person what actually happened.
The code
1. A contact form an assistant can fill in (declarative)
This is the existing Contact Form 7 form with three kinds of attributes added. No new form, no new plugin. The person still presses Send.
<form toolname="send_message"
tooldescription="Send a message to Michael Robichaud at CoworkConsultant.com ...
The person reviews the message and presses Send themselves.">
<input type="text" name="your-name" required
toolparamdescription="Full name of the person sending the message.">
<input type="email" name="your-email" required
toolparamdescription="Email address where Michael should reply.">
<textarea name="your-message" required
toolparamdescription="The message: what the person needs help with."></textarea>
<input type="submit" value="Send Message">
</form>
One trap I hit on Strategized.ai and fixed here from the start: Contact Form 7 marks required fields with aria-required, but Chrome reads the plain HTML required attribute when it builds the tool’s input schema. Add both, or the assistant thinks every field is optional. The form also has a hidden spam-trap field, so I gave it a description that tells assistants to leave it empty.
2. The agent-only intake, with a consent gate
A second form, published as agent_inquiry, carries toolautosubmit so the assistant can send it. It has no button for people, and it will not send unless the assistant confirms the person asked it to. The same consent box is required on the server, so skipping the page script does not get around it. When an assistant is filling it in, the form becomes visible so the person watching can see what is being sent.
document.addEventListener("submit", function (e) {
var f = e.target;
if (!f.matches('form[toolname="agent_inquiry"]')) return;
var consent = f.querySelector('input[name="person-asked"]');
if (!consent.checked) { // no consent, nothing is sent
e.preventDefault();
if (e.respondWith) e.respondWith(Promise.resolve({
status: "acceptance_missing",
message: "Not sent. Only send this if the person asked you to."
}));
return;
}
if (e.agentInvoked && e.respondWith) { // hand the real result back to the agent
e.preventDefault();
e.respondWith(new Promise(function (resolve) {
f.closest(".wpcf7").addEventListener("wpcf7mailsent", function (ev) {
resolve({ status: ev.detail.apiResponse.status,
message: ev.detail.apiResponse.message });
}, { once: true });
}));
}
}, true);
3. Read-only tools on every page (imperative)
These live in the mu-plugin. Both are marked readOnlyHint, both read only public data WordPress already serves, and get_services reads the service pages live, so the prices it reports always match the pages.
document.modelContext.registerTool({
name: "search_coworkconsultant",
title: "Search CoworkConsultant.com",
description: "Search the site's guides, how-tos and service pages. Read-only.",
inputSchema: {
type: "object",
properties: {
query: { type: "string", description: "What to look for, in plain words." },
limit: { type: "integer", minimum: 1, maximum: 10 }
},
required: ["query"]
},
annotations: { readOnlyHint: true },
execute: async function (input, options) {
var r = await fetch("/wp-json/wp/v2/search?search=" +
encodeURIComponent(input.query) + "&per_page=" + (input.limit || 5),
{ signal: options && options.signal });
var hits = await r.json();
return JSON.stringify(hits.map(function (h) {
return { title: h.title, url: h.url };
}));
}
});
4. The origin-trial token
Tokens are tied to one domain, so this site needs its own; the Strategized.ai token does not carry over. I registered coworkconsultant.com on October 18 and the same mu-plugin prints the token in the page head. It runs until March 29, 2027, when the trial ends.
add_action('wp_head', function () {
echo '<meta http-equiv="origin-trial" content="' . esc_attr(SSTACK_WEBMCP_OT_TOKEN) . '">';
}, 1);
The guardrails I kept
- A person stays in the loop.
send_messagenever sends itself.agent_inquiryneeds the person’s confirmation, and I reply to the person by email before anything else happens. - Read-only means read-only. The two script tools only call public, read-only WordPress endpoints. No login, no cookies sent, nothing stored.
- Nothing secret in the tools. Tool names, descriptions and page script are public by nature. They contain nothing that is not already on the site.
- Every call is logged. Each tool call sends a
webmcp_tool_callevent to my analytics, so I can see which tools get used and how often. - One-step off switch. The script tools turn off with a single WordPress setting, and the agent form can be paused without touching the server.
How I tested it
I tested in two rounds on October 19, 2026. First with a stand-in for Chrome’s WebMCP object, to check the markup and the code. Then for real, in Chrome 155 with this site’s origin-trial token live.
- Chrome sees all four tools. On every page Chrome lists
search_coworkconsultantandget_services, both marked read-only. On the contact page it also listssend_message(3 required inputs) andagent_inquiry(9 required of 21, including the consent box). - Search works. A real call to
search_coworkconsultantfor “Claude Team invites” returned my Claude Team onboarding checklist, the two-seat Team plan how-to, and the Claude Team how-to hub, with links. An empty query returns an error instead of guessing. - Services read live.
get_servicesreturned all 7 service pages with their current descriptions, plus the call link, the message form, the agent form and my reply time. - The consent gate holds. A real
agent_inquirycall with the consent box unchecked came back “Not sent” with the reason. A direct submission that skipped the page script was rejected by the form plugin on the server too. - The person can watch. When the assistant starts filling in
agent_inquiry, the form becomes visible on the page. - A real inquiry goes through. With consent, the call returned
mail_sentand told the assistant that I reply to the person to confirm.
What the tests caught. Three things. First, the reveal: one CSS rule mixed a normal selector with Chrome’s new :tool-form-active state, and a browser that does not know a selector throws away the whole rule. Splitting it fixed that. Second, and more important: “sent” was not “delivered”. The test inquiry left WordPress fine, but my own mail server turned away the email service’s sending address as junk. That was true for the regular contact form too. I moved both forms to deliver to my main inbox. A form that reports success while the email never lands is the most common failure I see on small business sites, and the only way to catch it is to check the inbox, not the form. Third: Contact Form 7 clears the form the moment it sends, and Chrome read that as the person cancelling. The assistant got an error even though the email went out, which invites a second send. The page now holds the form’s reset until the result is back. After that fix, one call, one email, and mail_sent back to the assistant.
What changed since the Strategized.ai build a week ago
The spec moved in seven days, which is the main lesson. The W3C community group draft was updated on October 16, 2026 and Chrome’s imperative API guide the same day:
- Tools can now carry annotations:
readOnlyHint,untrustedContentHintandconsequentialHint. I marked both read-only tools. registerToolreturns a promise, and a tool is removed by passing anAbortSignalwhen you register it, not with a separate unregister call.- Chrome 156 drops
window.ontoolactivated. Listen ondocument.modelContextinstead, which is what both sites do. - New this time: the two read-only script tools. Strategized.ai only has form tools.
Try it yourself
In Chrome 149 or later, turn on chrome://flags/#enable-webmcp-testing, relaunch, open any page on this site, and paste this into the DevTools console:
// Chrome 149+ with chrome://flags/#enable-webmcp-testing on, on any coworkconsultant.com page:
const tools = await document.modelContext.getTools();
tools.map(t => t.name);
// ["search_coworkconsultant", "get_services"] (on /contact/ you also get send_message and agent_inquiry)
const search = tools.find(t => t.name === "search_coworkconsultant");
await document.modelContext.executeTool(search, { query: "Claude Team invites", limit: 3 });
Please do not send test messages through agent_inquiry. I read every one.
Questions people ask
What is WebMCP?
WebMCP is a proposed web standard, worked on in a W3C community group with engineers from Google and Microsoft, that lets a website publish tools an AI assistant in the browser can call: search this site, send this form. The assistant gets a name, a description and a list of inputs instead of guessing which button to press.
Does WebMCP work in every browser?
Not yet. Today it works in Chrome 149 and later, either on sites that joined Chrome's WebMCP origin trial or with the testing flag turned on. Other browsers ignore it, and the site works exactly as before.
Can an AI agent buy something or book a call through these WebMCP tools?
No. Two tools only read public pages. The other two send me a message, and I reply to the person by email before anything else happens. Nothing is booked, charged or sold through them.
Do I need WebMCP on my own website?
Most small business sites do not need it this month. If people already ask an AI assistant to find and contact businesses like yours, a contact form an agent can use is cheap to add now. For a business site, that is a build I do through Strategized.ai.
What I actually sell
Claude, set up right the first time. One-on-one. If you want the same care on your own Claude setup, start with a free 20-minute call.
Want an agent-ready website for your business? That is a build I do through Strategized.ai.
Sources: WebMCP, W3C Web Machine Learning Community Group draft (October 16, 2026); Chrome for Developers: WebMCP; Declarative API; Imperative API.