webmcp-ai.dev Get the audit →

home / guides / guide

WebMCP for WordPress & WooCommerce

Make a WordPress site agent-ready: enqueue WebMCP tools over the REST API, expose WooCommerce products and cart, annotate forms declaratively, and register for Chrome's origin trial.

Updated 2026-08-28 · webmcp-ai.dev research desk

WordPress powers roughly 40% of the web, and almost none of it is agent-ready — which makes it the biggest single opportunity surface for WebMCP. The good news: WordPress already ships the backend you need (the REST API), so tools are mostly thin wrappers.

Step 1 — Enqueue a tools script

In your child theme's functions.php:

function webmcp_enqueue_tools() {
  wp_enqueue_script(
    'webmcp-tools',
    get_stylesheet_directory_uri() . '/js/webmcp-tools.js',
    array(), '1.0', array( 'strategy' => 'defer' )
  );
}
add_action( 'wp_enqueue_scripts', 'webmcp_enqueue_tools' );

// Chrome origin-trial token
function webmcp_origin_trial() {
  echo '<meta http-equiv="origin-trial" content="YOUR_TOKEN_HERE">';
}
add_action( 'wp_head', 'webmcp_origin_trial' );

Step 2 — Wrap the REST API

js/webmcp-tools.js, for any content site:

const mc = document.modelContext ?? navigator.modelContext;
if (mc) {
  mc.registerTool({
    name: "search_site_content",
    description: "Search this site's posts and pages. Returns titles, excerpts and URLs.",
    inputSchema: { type: "object",
      properties: { query: { type: "string" } }, required: ["query"] },
    annotations: { readOnlyHint: true },
    async execute({ query }) {
      const r = await fetch(`/wp-json/wp/v2/search?search=${encodeURIComponent(query)}&per_page=8`);
      return (await r.json()).map(p => ({ title: p.title, url: p.url, type: p.subtype }));
    }
  });
}

Running WooCommerce? The Store API (/wp-json/wc/store/v1/…) is session-aware and unauthenticated by design — perfect for WebMCP. Wrap /products?search= as search_products and POST /cart/add-item as add_to_cart; the agent fills the visitor's real cart and the visitor checks out. (There is also an early WebMCP Bridge plugin if you'd rather not touch code — evaluate it against your theme before production.)

Step 3 — Declarative tools for forms

WebMCP's declarative API turns an existing form into an agent tool with attributes alone — ideal for WordPress contact and booking forms:

<form action="/contact" method="post"
      toolname="request_quote"
      tooldescription="Request a quote for services. Submits the visitor's details to the business.">
  <label>Name <input name="name" required></label>
  <label>Email <input name="email" type="email" required></label>
  <label>What do you need? <textarea name="message"></textarea></label>
  <button>Send</button>
</form>

Well-labeled fields matter double here: they're the schema. If your form builder generates field_7281 names, fix that first.

Step 4 — The rest of the readiness stack

Want the full picture for your specific WordPress site — including which tools fit your business? Start with the free scan or get the deep audit.