Skip to content

Add WebMCP search

Add the WebMCP search tool to a site created before it shipped, so an agent in the reader's browser can search your docs.

AI-generated · awaiting reviewUpdated

WebMCP is an experimental browser API that lets a page offer tools to an agent running in the browser. Nimbus registers one tool, search_documentation, which searches the site’s search index. New sites have it already.

What new sites get

Nothing loads until an agent calls the tool, and browsers without the API skip it. Results follow the same rules as site search: drafts and hidden versions are left out, and so are noindex pages unless they set searchable: true.

Input

Field Type Default Constraints
query string — Required, at most 500 characters
limit integer 5 1 to 20
version string Every version except deprecated ones Versioned sites only; any visible version, deprecated included

Result: a list of matches, each with title, heading, an anchored url, and a plain-text excerpt of at most 1,000 characters.

Errors

Code Meaning
invalid_input The query, limit or version is invalid.
index_unavailable The search index couldn’t load: check that the build’s whole pagefind/ folder is deployed.
search_failed The search or its code failed to load. Retry, or reload the page.

Add it to an older site

Prerequisites

  • Site search on the default provider (search not set to false or a custom provider)
  • Pagefind 1.5.2 or later

Steps

  1. Copy the component

    Copy src/components/WebMCP.astro from the starter into your project’s src/components/.

  2. Render it in the head

    In src/layouts/BaseLayout.astro, import the component and render it inside <head>:

    src/layouts/BaseLayout.astroastro
    ---
    import WebMCP from "@/components/WebMCP.astro";
    ---
    <head>
      <!-- … -->
      <WebMCP />
    </head>
  3. Build the site

    npm run build

Verify

Open any built page’s HTML and find the tool’s settings in <head>:

<meta name="nimbus-webmcp" content="{&quot;search&quot;:&quot;pagefind&quot;,…}">

If the tag is missing, the site’s search isn’t the default provider. The tool needs a production build: in astro dev it answers index_unavailable.

Next steps

Type to search…

↑↓ navigate↵ selectEsc close