SR
Usage

WebMCP

Expose read-only tools to in-browser AI agents via the experimental WebMCP standard.


WebMCP is an experimental browser standard that lets websites offer tools to AI agents running inside the visitor's browser (e.g. Gemini in Chrome). Instead of scraping the rendered page, the agent calls the tools your site provides and gets structured answers back.

With WebMCP enabled, LLMify registers a set of read-only tools on every front-end page. A visitor's browser agent can then search your content, read whole pages as Markdown, and navigate the site on the visitor's behalf.

What You Get

Every front-end page loads a small script that registers four tools with the browser agent:

  • Search content: full-text search across your enabled content, returning matching pages with title, description, and URL.
  • Get page: the full Markdown of a single page, the same content your .md URLs serve.
  • List sections: the content sections available on the current site.
  • Navigate: sends the visitor's browser to a page on your site (same-origin only).

The tools respect your LLMify configuration: only content from enabled sections shows up, excluded entries never appear, and everything is read-only. Agents can only reach content that is already public through your Markdown URLs, and all responses are marked noindex.

Enable WebMCP

WebMCP is disabled by default. Turn it on in the control panel under Settings > LLMify > WebMCP, or via the enableWebMcp config setting:

<?php
// config/llmify.php

return [
    '*' => [
        'enableWebMcp' => true,
    ],
];
Caution

WebMCP is an experimental, pre-standard browser API and currently Chrome-only. Enabling it publishes a public, machine-callable search and content API over your already-public content.

To verify it works, open any front-end page and check that /webmcp.js loads. Browsers without WebMCP support ignore the script entirely.

Note

WebMCP targets sites where Craft renders the front end. In headless mode the script is not injected automatically.

Custom Tools

This section is for plugin and module developers. LLMify fires WebMcpService::EVENT_REGISTER_TOOLS when the tool set is built, so you can add your own tools, adjust the built-in definitions, or remove tools entirely. Appending a tool with the name of an existing one replaces it.

A tool consists of a name, a description for the agent, a JSON Schema for its input, and a client-side JavaScript handler. The handler receives the tool input and a helpers object with text(value) to build a text result, fetchTool(url) for same-origin JSON requests, and config.

use samuelreichor\llmify\events\RegisterWebMcpToolsEvent;
use samuelreichor\llmify\services\WebMcpService;
use yii\base\Event;

Event::on(
    WebMcpService::class,
    WebMcpService::EVENT_REGISTER_TOOLS,
    function(RegisterWebMcpToolsEvent $event) {
        $event->tools[] = [
            'name' => 'get_opening_hours',
            'description' => 'Get the opening hours of the store.',
            'inputSchema' => ['type' => 'object'],
            'handler' => <<<JS
async (input, helpers) => {
  const r = await helpers.fetchTool(new URL('/api/opening-hours', location.origin));
  return helpers.text(r.ok ? JSON.stringify(r.data) : 'Opening hours are unavailable.');
}
JS,
        ];
    }
);

The handler runs in the visitor's browser. Keep it self-contained, return a result via helpers.text() instead of throwing, and only call endpoints that are safe to expose publicly.


Copyright © 2026 Samuel Reichör