# webmcp intent registry lab

- Status: `experiment`
- Track: [agent discovery, auth & protocol bridges](https://aifoc.us/labs/agent-bridges-and-discovery/)
- Layer: 9. Agent Discovery, Auth & Protocol Bridges
- Updated: 2 December 2026
- Live demo: https://webmcp-intent-registry-lab.kinlan-test.workers.dev
- Source: https://github.com/PaulKinlan/webmcp-intent-registry-lab

## Inspired by

- [webmcp is the new web intents ... maybe](https://aifoc.us/webmcp-is-the-new-web-intents/)
- [I think i've got it - Web Intents](https://aifoc.us/i-think-ive-got-it-web-intents/)
- [ai agents make mashups worth revisiting](https://aifoc.us/ai-powered-site-mashups/)

## Why this matters

When a browser connects an assistant to dozens of [WebMCP](https://webmachinelearning.github.io/webmcp/) websites at once, loading every site's full [MCP](https://modelcontextprotocol.io/specification) `tools/list` schema into the prompt burns thousands of context tokens before work starts. Switching to on-demand tool lookup introduces two concrete risks: keyword search misses when user wording diverges from tool names, and silent 'rug-pull' edits where a website rewrites a tool's description or allowed enum values after discovery to inject instructions or escalate privileges.

## What this opens up

Safe cross-site WebMCP tool lookup across 2–60 websites at a flat ~650-token upfront prompt budget, blocking prompt injection and parameter drift from mutated schemas with deterministic [WebCrypto](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) SHA-256 pinning (`409 SCHEMA_DRIFT`).

## How the tests work

1. Click **Test Mismatch (Synonyms OFF)** to search `"book an overnight sleeper"` across 24 tools and see `reserve_cabin` score `0` without synonyms, then click **Retry with Synonyms ON** to rank it #1.
2. Click **Run 11-Query Eval Suite** to compare `Recall@1`, `Recall@3`, and `MRR` side by side with synonyms disabled versus enabled.
3. Click **Compare Unguarded vs. Pinned Gate** (or pick one of 3 rug-pull scenarios in section 3) to mutate a tool on the live Cloudflare Worker and watch Name-Only Dispatch execute (`200`) while the SHA-256 Diff Gate halts with `409 SCHEMA_DRIFT` and a field-by-field diff.
4. Drag the **Connected WebMCP Sites** slider from 2 to 60 sites to measure exact serialized prompt token savings, and expand section 5 to reproduce Chrome text-listing delimiter truncation on `", inputSchema=`.


## Hypothesis

- **Claim:** Pairing a field-weighted browser-local Okapi BM25 tool index (`--stable` on-demand retrieval) with canonical WebCrypto SHA-256 schema pinning keeps upfront `tools/list` token overhead constant across 2–60 connected sites and fails closed (`409 SCHEMA_DRIFT`) whenever a publisher alters a tool contract after discovery.
- **Confirms it:** `--stable` mode holds upfront prompt overhead flat (~650 tokens) from 2 to 60 sites compared with linear eager `tools/list_changed` growth, the 11-query suite quantifies `Recall@1`, `Recall@3`, and `MRR` deterministically, and the SHA-256 Diff Gate blocks mutated descriptions, widened enums, and hidden parameters with `409 SCHEMA_DRIFT` where unguarded name-only dispatch returns `200 OK`.
- **Bounds or disproves it:** Disabling curated synonyms exposes pure lexical BM25 misses (`"book an overnight sleeper"` missing `reserve_cabin` when its text uses `couchette` and `berth`), and `GET /api/parser-fragility` reproduces text-delimiter truncation when a tool description embeds `", inputSchema=`.


## Under the hood

[WebMCP Intent Registry Lab](https://webmcp-intent-registry-lab.kinlan-test.workers.dev) ([source on GitHub](https://github.com/PaulKinlan/webmcp-intent-registry-lab)) runs shared deterministic ES modules across the browser tab and a Cloudflare Worker to benchmark cross-site [WebMCP](https://webmachinelearning.github.io/webmcp/) discovery without LLM variance:

- **Weighted Okapi BM25 index (`public/lib/bm25-registry.js`):** Indexes 8 simulated publisher origins (24 tools across flights, calendar, code review, expenses, maps, bookmarks, inventory, and healthcare triage) with configurable field weights (`toolName: 8, siteTitle: 6, description: 4, origin: 1, inputSchemaKeys: 1, synonyms: 3`) matching `webmcp-relay`'s SQLite FTS5 model.
- **11-query eval suite & token comparator (`public/lib/eval-suite.js`, `public/lib/token-budget.js`):** Computes `Recall@1`, `Recall@3`, and `MRR` live with synonyms toggled off vs. on, and compares exact serialized `tools/list` JSON token cost (`Math.ceil(chars / 4)`) for eager catalogs versus 7 fixed `--stable` wrapper tools from 2 to 60 sites.
- **Canonical SHA-256 diff gate & parser fragility probe (`public/lib/schema-gate.js`, `src/worker.ts`):** Canonicalizes and hashes live site manifests (`GET /api/sites/:site/manifest`) via `crypto.subtle.digest("SHA-256", ...)`, pits unguarded dispatch against pinned verification on `POST /api/sites/:site/call` (`409 SCHEMA_DRIFT` with field-level JSON diffs), and reproduces Chrome DevTools text-listing delimiter truncation on `GET /api/parser-fragility`.


## Key terms & further reading

- [WebMCP (navigator.modelContext)](https://webmachinelearning.github.io/webmcp/) — A browser API proposal letting websites register structured callable tools directly in the page for assistants to invoke.
- [Model Context Protocol (MCP)](https://modelcontextprotocol.io/specification) — A JSON-RPC protocol that lets assistants list available tools (`tools/list`) and invoke them with typed JSON inputs.
- [Okapi BM25](https://en.wikipedia.org/wiki/Okapi_BM25) — A deterministic keyword-ranking formula that scores matches by term frequency, rarity, and per-field weights without running an LLM.
- [SHA-256 Schema Pinning (Web Crypto API)](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) — Computing a canonical SHA-256 digest of a tool's sorted JSON contract at discovery time so any post-discovery change triggers a mismatch.
- [Tool Schema Rug-Pull](https://owasp.org/www-project-top-10-for-large-language-model-applications/) — An attack where a remote site alters a tool's description or allowed inputs after initial approval to inject instructions or widen permissions.
- [Recall@k & MRR](https://en.wikipedia.org/wiki/Mean_reciprocal_rank) — Retrieval evaluation metrics measuring how often the expected tool appears in the top *k* results and how close it ranks to #1.

## Open questions to iterate on

- How small can a hybrid lexical + local embedding reranker stay inside a browser Worker to eliminate synonym-less BM25 misses without hurting latency?
- Should browsers pin WebMCP tool schema digests per user consent grant automatically inside `navigator.modelContext`?

## Iteration log

- **2026-12-02:** Deployed Cloudflare Worker + browser-native Okapi BM25 WebMCP registry across 8 publisher origins (24 tools), 11-query `Recall@1`/`Recall@3`/`MRR` eval suite, 2–60 site dynamic vs. eager token-budget comparator, WebCrypto SHA-256 Schema Rug-Pull Diff Gate (`409 SCHEMA_DRIFT`), and `GET /api/parser-fragility` delimiter-truncation reproducer.

## Primitives tested

- `WebMCP (navigator.modelContext)`
- `Okapi BM25 Field-Weighted Search`
- `Canonical SHA-256 Schema Pinning (409 SCHEMA_DRIFT)`
- `Token Budget Comparator`
- `Parser Fragility Probe`

## Connected labs in other tracks

- [messageport intent & acp bridge](https://aifoc.us/labs/agent-bridges-and-discovery/messageport-intent-acp-bridge/) — Hands off a single attenuated tool over `MessagePort` once an intent is selected.
- [canonical multimodal ui](https://aifoc.us/labs/hypermedia-and-islands/canonical-multimodal-ui/) — Generates aligned human HTML forms and WebMCP tool schemas from one canonical definition.
- [acp context firewall lab](https://aifoc.us/labs/agent-bridges-and-discovery/acp-context-firewall-lab/) — Enforces closed-enum WebMCP JSON Schema locks against tool-argument exfiltration.

---
Canonical: https://aifoc.us/labs/agent-bridges-and-discovery/webmcp-intent-registry-lab/
