# webmcp-tour (full documentation) > webmcp-tour is a zero-dependency TypeScript browser library that gives AI agents guided tours of a web app: with one script tag, any WebMCP agent can walk users through the app, highlighting and explaining each step. It registers four WebMCP tools (tour_show_step, tour_list_targets, tour_dismiss, tour_wait_for_interaction) that highlight a control with a short explanation beside it; the user does the action. It works with no setup on any page (the agent points at visible text) and gets better with declared targets, pages, and resume-after-navigation. --- # Guided tours for AI agents Source: https://fboldo.github.io/webmcp-tour/index.md **webmcp-tour** gives AI agents guided tours of your app, in one script tag. Any WebMCP agent can walk your users through it, highlighting and explaining each step. Declare a few targets when you want to shape the tour. [Try the live demo](https://fboldo.github.io/webmcp-tour/demo/) · [Quick start](https://fboldo.github.io/webmcp-tour/quick-start.md) · [Tools reference](https://fboldo.github.io/webmcp-tour/tools.md) ![The Billing page of the demo app: the Change plan button is highlighted and a card beside it says "From the AI assistant" with the explanation and a Got it button.](https://fboldo.github.io/webmcp-tour/images/highlight-card.png) It is a zero-dependency TypeScript library for the browser. It registers four [WebMCP](https://github.com/webmachinelearning/webmcp) tools on the page, so any agent that can call WebMCP tools (a browser's built-in assistant, an MCP client driving Chrome, or a model called from your own page script) can point at things. The library is **experimental** (0.x): the API may change between minor versions, and WebMCP itself is still evolving. These docs describe the code in the repository as it is. ## Two ways to use it **The zero-shot primitive.** Add one script tag. The agent calls `tour_list_targets` to read a visible outline of the page (headings, and controls with role, name and context), then `tour_show_step({ text: "Change plan", message: "…" })` to point at a control by its visible text. No markup, no configuration. This works on any page and is the way to start. See [Quick start](https://fboldo.github.io/webmcp-tour/quick-start.md). **The declared map.** You tell the tour what your app has: targets (`data-tour-id`) with labels and descriptions, pages with URLs, and how to navigate. The agent then answers from your descriptions, can say "that control is on the Security page" and offer a **Go to Security** card, and the step **resumes** on the new page after the user presses Go. See [Concepts](https://fboldo.github.io/webmcp-tour/concepts.md). | | Zero-shot | Declared map | |---|---|---| | Setup | A script tag | `data-tour-id` attributes, `pages`, `navigate` | | The agent finds controls by | Visible text, accessible name, or a CSS selector | The same, plus ids you chose | | Descriptions | Written by the agent each time | Written by you, shown by default | | Other pages | Not known | Suggested with a card; resumes after Go | | Best for | A quick start, a site you do not control | Your own product, where wording matters | You can mix them freely: declared targets are an addition, not a mode. ## What the user sees - A spotlight ring around the control, and a card beside it labelled **From the AI assistant** (so a page cannot pass the text off as its own) with a **Got it** button. - Optionally **Take me there**, which scrolls to the control, focuses it and pulses the ring. - For a control on another page: a card in the middle of the viewport, **Go to Security** or **Not now**, and nothing moves until the user picks. The overlay uses system colours, supports light and dark, forced-colors and reduced motion, and is announced to screen readers ([Accessibility](https://fboldo.github.io/webmcp-tour/accessibility.md)). ## Where to go next - [Quick start](https://fboldo.github.io/webmcp-tour/quick-start.md): a script tag, or a bundler. - [Concepts](https://fboldo.github.io/webmcp-tour/concepts.md): targets, pages, the outline, resume, labels and placement. - [Tools reference](https://fboldo.github.io/webmcp-tour/tools.md) and [Engine API](https://fboldo.github.io/webmcp-tour/engine-api.md): exact inputs and results. - [Agent hosts](https://fboldo.github.io/webmcp-tour/agent-hosts.md): Playwright MCP, Chrome, and in-page agents. - [FAQ](https://fboldo.github.io/webmcp-tour/faq.md): how this differs from browser agents, size, SSR. --- # Quick start Source: https://fboldo.github.io/webmcp-tour/quick-start.md Two requirements: a **secure context** (https, or `http://localhost`), and a browser or bridge that provides WebMCP (`document.modelContext`). See [Agent hosts](https://fboldo.github.io/webmcp-tour/agent-hosts.md) 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): ```html ``` Production: pin the exact version and lock the file with Subresource Integrity: ```html ``` 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: ```html ``` 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`. ```html ``` `data-config` is the id of exactly one ` ``` The [live demo](https://fboldo.github.io/webmcp-tour/demo/) detects the capability (native `document.modelContext`, else it loads the polyfill) and shows a status line ("Native WebMCP", "Polyfill (in-page agents only)" or "Not a secure context"); `?webmcp=native` or `?webmcp=polyfill` overrides the detection for testing. It runs a small in-page assistant with four modes: a scripted agent (no model), Chrome's Prompt API in JSON-constrained mode, the Prompt API with native tool use, and OpenRouter with your own key. Pick the mode from its **Mode** menu. Notes for in-page agents: - A **full page load** restarts the agent. For a single-page app, pass `navigate` (your router's push) so the page does not reload; otherwise the highlight still resumes after Go, but the agent starts over. - The agent should call `tour_list_targets` first, then point with `text` or a declared `target`, and answer in its own words what the card says. ## ChatGPT Desktop, Edge, Brave These may offer WebMCP or something like it; nobody has tried this library there. If you do, the things to check are: are the four tools listed, what are they called (bridges prefix names), and do failure envelopes show up. Please report what you find in the repository's issues. --- # Examples Source: https://fboldo.github.io/webmcp-tour/examples.md ## Live demo [Open the live demo](https://fboldo.github.io/webmcp-tour/demo/): a fake settings app (Acme Cloud) with four pages (Billing, Team, Security, Notifications), the tour tools registered, a control panel that drives `window.webmcpTour` by hand, and an **Ask the assistant** panel. It runs entirely in your browser; nothing is sent anywhere unless you choose the OpenRouter mode and enter a key. By default the assistant is a **scripted agent**: canned question-to-tool-call mappings and no AI model. The tool calls are real. If your Chrome has the Prompt API and its model, the page can use that instead. Try this: 1. On Billing, press **How do I change my plan?**. The **Change plan** button is highlighted with its card. ![The demo's Billing page with Change plan highlighted.](https://fboldo.github.io/webmcp-tour/images/highlight-card.png) 2. Ask **Where do I set up two-factor?** from Billing. That control is on Security, so a card appears in the middle of the page: **Go to Security** / **Not now**. Nothing moves until you click. 3. Press **Go to Security**. The app switches page and the step **resumes**: **Set up two-factor** is already highlighted. 4. The controls work, so guidance can span steps: **Change plan** opens a plan picker (a modal dialog with declared targets for the options and **Confirm**). The demo needs WebMCP: it uses the native API when the browser has one, and otherwise loads the W3C polyfill by itself (a status line says which; `?webmcp=native` or `?webmcp=polyfill` overrides). Polyfilled tools are visible to in-page agents only, not to a browser agent. In a browser that blocks the polyfill or has no secure context, the assistant says so and turns itself off. ## Runnable examples Three small apps live in the repository's `examples/` folder. Each starts with one command (see the repository README); none needs a build for the page itself apart from the library. ### Script tag (`examples/script-tag`) A plain HTML "Northwind" settings app with Billing, Team, Security and Notifications tabs. One `