AI Focus

webmcp intent registry lab

Why this matters

When a browser connects an assistant to dozens of WebMCP websites at once, loading every site’s full MCP 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 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=.
Test on-demand Okapi BM25 cross-site WebMCP tool search (8 sites, 24 tools), an 11-query accuracy benchmark, 2–60 site prompt token scaling, and a SHA-256 schema rug-pull diff gate. Open webmcp intent registry lab full screen ↗

Hypothesis

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.

What 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.

What 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 (source on GitHub) runs shared deterministic ES modules across the browser tab and a Cloudflare Worker to benchmark cross-site 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) ↗
A browser API proposal letting websites register structured callable tools directly in the page for assistants to invoke.
Model Context Protocol (MCP) ↗
A JSON-RPC protocol that lets assistants list available tools (tools/list) and invoke them with typed JSON inputs.
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) ↗
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 ↗
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 ↗
Retrieval evaluation metrics measuring how often the expected tool appears in the top k results and how close it ranks to #1.

Open questions

  • 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

  • — 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.

This is an active lab under /labs/ and stays off the main RSS feed until graduated into a full essay.

More in agent discovery, auth & protocol bridges

Connected labs

← agent discovery, auth & protocol bridges · All labs