https://dondibogusky.com/notes/webmcp-site-search/ Back to notes

Making Site Search Available to WebMCP

WebMCP turns the site's static Pagefind index into a discoverable search tool that agents can call without changing the site's static-first architecture.

WebMCP Search Astro

WebMCP is a good fit for this site because the best tool for exposing it was already here: the static Pagefind index generated from the production build.

The work focused less on adding a new search system and more on making the existing one legible to agents. The site now advertises WebMCP discovery manifests, marks the homepage and search forms with tool metadata, and registers a site-search tool via navigator.modelContext when the browser supports it.

Search Stays Static

The tool loads the same Pagefind runtime that powers the visible search page. For a query, it returns titles, URLs, excerpts, and structured result data instead of redirecting an agent to a page flow meant for a person.

This keeps the architecture honest. Search is still built from the final HTML, deployed as static assets, and available without a hosted search service.

A Better Agent Boundary

The human interface and the agent interface now share the same source of truth, but they do different jobs. People get a quiet search page. Agents get a read-only tool with a small input schema and predictable output.

The surrounding cleanup matters too: Pagefind ignores hidden microformat metadata that should not pollute excerpts, and the content security policy allows the new inline registration script without opening the site up broadly.