A live demonstration of building a RAG (Retrieval-Augmented Generation) system entirely in the browser using WebMCP, Transformers.js, and Dexie.
Presented at AI Tinkerers
An AI agent implements a complete RAG pipeline live, using Chrome DevTools MCP to:
- Ingest documents - Chunk text and generate embeddings
- Search semantically - Find relevant content using cosine similarity
- Inspect the index - Debug embeddings and verify storage
All running 100% in the browser - no backend required.
| Layer | Tool |
|---|---|
| Agent Tools | WebMCP - Expose browser tools to AI agents |
| Embeddings | Transformers.js + Supabase/gte-small |
| Storage | Dexie.js (IndexedDB wrapper) |
| UI | React + shadcn/ui + Tailwind CSS v4 |
The demo exposes 4 tools via WebMCP:
| Tool | Description | Implementation |
|---|---|---|
rag_ingest |
Ingest a document into the index | Agent implements live |
rag_search |
Semantic search over indexed content | Agent implements live |
rag_stats |
Get index statistics | Pre-built |
rag_get_chunk |
Inspect a specific chunk + embedding | Pre-built |
# Install dependencies
pnpm install
# Start dev server
pnpm devOpen http://localhost:5173 and connect Chrome DevTools MCP.
- Setup: Agent connects via Chrome DevTools MCP, lists available tools
- Implement
rag_ingest: Agent writes chunking logic + embedding pipeline - Test ingestion: Upload a document, verify chunks are stored
- Implement
rag_search: Agent writes cosine similarity from scratch - Test search: Query the index, verify semantic matching works
src/
components/
RAGPanel.tsx # Main UI component
ui/ # shadcn/ui components
tools/
rag.ts # WebMCP tool definitions (skeleton)
lib/
embedder.ts # Transformers.js wrapper
db/
index.ts # Dexie database schema
schemas/
index.ts # Zod schemas for validation
types/
index.ts # TypeScript types
The skeleton tools throw "Not implemented" - the agent fills in:
// rag_ingest: Agent decides chunking strategy
// - By sentences? Paragraphs? Fixed characters?
// - Overlap between chunks?
// rag_search: Agent writes cosine similarity
// - No libraries - pure math from scratchMIT