webmcp-tour Live demo

Quick start

Two requirements: a secure context (https, or http://localhost), and a browser or bridge that provides WebMCP (document.modelContext). See Agent hosts for how to get one, including a polyfill for development.

Install with npm install webmcp-tour, or use the script tag below. The library is experimental (0.x), so pin the version.

With a script tag #

dist/webmcp-tour.js is a single file (an IIFE). Include it and it creates a default tour and registers its four tools; nothing else is needed.

Try it (quick experiments only: always the newest version, no integrity check):

<script src="https://unpkg.com/webmcp-tour"></script>

Production: pin the exact version and lock the file with Subresource Integrity:

<script src="https://unpkg.com/webmcp-tour@0.1.0/dist/webmcp-tour.js" integrity="sha384-ZFV7oLCiB6T5KDOyhLF+G6M+t6L1P0nugi+feJ6QYJnKy8pJ1ThykxOFoV7mnn2A" crossorigin="anonymous"></script>

Do not use @latest in production: SRI is impossible and 0.x releases can break silently. The hash of a release is curl -s https://unpkg.com/webmcp-tour@0.1.0/dist/webmcp-tour.js | openssl dgst -sha384 -binary | openssl base64 -A (in a clone, pnpm build && pnpm sri). You can also serve dist/webmcp-tour.js yourself.

That is the whole setup. window.webmcpTour is { tour, createTour, registerAsWebMcpTool }: tour is the default tour, so you can configure it from your own script:

<script src="/webmcp-tour.js"></script>
<script>
  webmcpTour.tour.defineTarget({
    id: "change-plan",
    selector: "#plan-button",
    description: "Opens the plan picker.",
  });
</script>

To give the default tour its options, add a JSON block and point the script tag at it with data-config. The block can be anywhere on the page, before or after the tag. Only JSON-safe options are read: pages, labels, pageSuggestion, resume and takeMeThere.

<script type="application/json" id="tour-config">
  { "pages": [{ "id": "billing", "url": "/billing", "title": "Billing" }], "labels": { "gotIt": "Entendi" } }
</script>
<script src="/webmcp-tour.js" data-config="tour-config"></script>

data-config is the id of exactly one <script type="application/json"> element; any other element with that id is ignored. With none or several, or with invalid JSON, labels that are not strings or pages that are not objects, the script warns once in the console and uses the defaults. A value starting with { is read as inline JSON instead: data-config='{"takeMeThere":true}'. When the server renders the JSON block, escape < as \u003c (JSON.stringify(config).replace(/</g, "\\u003c")) so the content can never close the tag early. A second copy of the script on the page does not register the tools again. A page url must be http(s) on the page's own origin; for another origin add "allowCrossOrigin": true. navigate is a function and cannot be JSON. For that, or for several tours, use data-manual and build the tours yourself with webmcpTour.createTour(options) and webmcpTour.registerAsWebMcpTool(tour), or use a bundler as below.

Attributes on the script tag. They are read from document.currentScript, which is null when the file is bundled as a module: there is then no config and no flag (use createTour(options) instead).

AttributeEffect
data-configId of the JSON config block, or inline JSON starting with {.
data-no-globalDo not set window.webmcpTour. window.webmcpTour is page-global: any same-origin script can drive the overlay, so opt out if that matters.
data-manualCreate the default tour but do not register its tools. Register them yourself with webmcpTour.registerAsWebMcpTool(...) (Engine API).

With a bundler #

import { createTour, registerAsWebMcpTool } from "webmcp-tour";

const tour = createTour({
  pages: [
    { id: "billing", url: "/billing", title: "Billing" },
    { id: "security", url: "/security", title: "Security" },
  ],
  navigate: (url) => router.push(url),
});
await registerAsWebMcpTool(tour); // registers the four tools of that tour

createTour() returns a new tour each time, so its options always apply. To register several tours, give each its own toolPrefix or names (Engine API).

Importing createTour alone gives you the engine without registering any tool (Engine API). The package is side-effect free: importing it on a server touches nothing (FAQ).

Declare a control (optional) #

Mark up the controls you want agents to know about:

<button data-tour-id="change-plan"
        data-tour-description="Opens the plan picker. Choose a plan, then press Confirm.">
  Change plan
</button>

data-tour-description is the default card text when the agent does not give a message. Other attributes: data-tour-label (accessible-name override in lists), data-tour-reveal (what to do first when the control is hidden), data-tour-page (which page it lives on), and data-tour-exclude (never point at this). See Concepts.

Check it works #

  1. Open the page in a WebMCP-capable browser (or add the polyfill, see Agent hosts).
  2. Ask the agent to list its tools. You should see tour_show_step, tour_list_targets, tour_dismiss and tour_wait_for_interaction (a bridge may add a prefix: Playwright MCP calls them webmcp_tour_show_step).
  3. Ask "Where do I change my plan?". The agent calls tour_list_targets, then tour_show_step, and the control lights up.

Where WebMCP is missing, registration is skipped with one console.info that says why (not a secure context, a Permissions-Policy that blocks tools, or no document.modelContext). Nothing throws.

The live demo is the quickest way to see it first.

Let a coding agent do it #

An Agent Skill teaches a coding agent (Claude Code, Cursor, Codex and others) to add webmcp-tour to your app: install, declare targets and pages, write good descriptions, and test.

npx skills add fboldo/webmcp-tour --skill webmcp-tour

The skill also has an audit script, node skills/webmcp-tour/scripts/audit.mjs src/, which lists controls that lack data-tour-id and data-tour-description.