> Canonical URL: https://codingcat.dev/demos/web-ai

# Interactive Web AI, WebMCP & Chrome Built-in AI Playground | CodingCat.dev

⚡ Interactive Client-Side Web AI LabWebMCP + Gemini Nano + Firebase Hybrid AI + WebGPU

# browser-native web ai & webmcp playground

Test our production client-side Web AI stack directly in your browser. Inspect and execute live **WebMCP**  tools registered on `document.modelContext` and declarative HTML forms, probe **Chrome Built-in AI (Gemini Nano)**  APIs with live **Firebase AI Logic & Edge**  fallback, and run zero-backend **WebGPU / Float32**  semantic vector search.

[Read WebMCP Guide&rarr;](/post/webmcp-browser-native-model-context-protocol-guide)[Read Built-in AI Guide &rarr;](/post/chrome-built-in-ai-gemini-nano-prompt-api-guide)[Read Hybrid Routing Guide &rarr;](/post/hybrid-web-ai-routing-gemini-nano-firebase-ai-logic-workers)[Agent Discovery Docs](/developers)WebMCP Ready!WebMCP ContextPolyfill Ready (3 tools)Chrome Prompt APIHybrid Fallback ReadySummarizer / RewriterHybrid Fallback ReadyWebGPU ComputeFloat32 SIMD Ready

## Imperative API (`document.modelContext`)

registerTool()

Select any WebMCP tool registered on this page to inspect its typed JSON Schema contract and execute its in-tab handler with same-origin session locality.

Registered Browser Toolsearch_content (Live CodingCat.dev Search API)estimate_inference_budget (Local vs. Cloud Token Calculator)extract_page_headings (DOM Outline Extractor)JSON Arguments Payload{"query": "WebMCP"}ReadyRegistered Tool Schema & Annotations

{
  "name": "search_content",
  "description": "Search CodingCat.dev tutorials, blog posts, courses, and podcasts by technical topic",
  "annotations": {
    "readOnlyHint": true,
    "untrustedContentHint": true
  },
  "inputSchema": {
    "type": "object",
    "properties": {
      "query": {
        "type": "string",
        "description": "Keyword or technology (e.g. WebMCP, Gemini Nano, WebGPU, Astro)"
      }
    },
    "required": [
      "query"
    ]
  }
}

### Live Tool Execution Response

JSON-RPC / Structured ResultClick "Execute WebMCP Tool" to run the registered handler in your browser session.

### Declarative API (``)

Zero-JS Schema DiscoveryThis HTML form includes standard W3C WebMCP attributes (`toolname`, `tooldescription`, and `toolparamdescription`) so browser agents can synthesize a tool contract without executing custom scripts.

Topic Keyword (`q`)Content Pillar (`type`)Blog Posts (post)Courses (course)Podcasts (podcast)Auto-Extracted Declarative Tool Contract from DOM

{
  "protocol": "webmcp-declarative/1.0",
  "toolname": "search_codingcat_catalog",
  "tooldescription": "Search CodingCat.dev courses, podcasts, and blog posts by keyword and content pillar",
  "toolautosubmit": true,
  "action": "/api/search",
  "method": "GET",
  "inputSchema": {
    "type": "object",
    "properties": {
      "q": {
        "type": "string",
        "description": "Technical keyword or framework name (for example: Astro, Sanity, WebMCP, Firebase)"
      },
      "type": {
        "type": "string",
        "enum": [
          "post",
          "course",
          "podcast"
        ],
        "description": "CodingCat.dev content pillar filter (post, course, podcast)"
      }
    },
    "required": [
      "q"
    ]
  }
}

## Chrome Built-in AI & Firebase Hybrid Router

PREFER_ON_DEVICERun zero-cost, on-device inference via Chrome's `window.LanguageModel`, `Summarizer`, or `Rewriter` APIs when Gemini Nano is available locally, or automatically route through our live **Firebase AI Logic / Cloudflare Edge Fallback**  endpoint (`/api/ai/hybrid-fallback`).

Web AI Task APIPrompt API (LanguageModel)Summarizer API (key-points)Rewriter API (more-casual)Firebase AI InferenceModePREFER_ON_DEVICE (Local Nano &rarr; Edge Fallback)ONLY_IN_CLOUD (Force Firebase / Edge Cloud)Input Context / Developer PromptExplain why exposing structured tools via WebMCP (document.modelContext) is 10x faster and more reliable than DOM screen-scraping for browser AI agents.Route: Ready (PREFER_ON_DEVICE)Firebase AI Logic SDK Hybrid Configuration (`firebase/ai`)

import { initializeApp } from "firebase/app";
import { getAI, getGenerativeModel, GoogleAIBackend, InferenceMode } from "firebase/ai";

const app = initializeApp(firebaseConfig);
const ai = getAI(app, { backend: new GoogleAIBackend() });

// Automatically routes to Chrome Built-in AI (Gemini Nano) when available,
// and falls back to Gemini Flash in the cloud via Firebase AI Logic:
const hybridModel = getGenerativeModel(ai, {
  mode: InferenceMode.PREFER_ON_DEVICE,
  inCloudParams: { model: "gemini-flash-latest" },
});

const result = await hybridModel.generateContent(prompt);

### Live Inference Output & Route Telemetry

StandbyClick "Run Hybrid Inference" to execute on local Chrome Gemini Nano or fall back to our live Edge AI endpoint (/api/ai/hybrid-fallback).Chrome & Hybrid Router Diagnostic Matrix{
  "builtInAi": { "LanguageModel": "probing...", "Summarizer": "probing...", "Rewriter": "probing..." },
  "hybridFallbackEndpoint": "/api/ai/hybrid-fallback (Firebase AI Logic + Edge Worker)"
}

## Client-Side Vector Cosine Similarity Engine

0 Bytes Network EgressTest client-side semantic retrieval in the browser. Enter a technical query below to compute real-time `Float32Array` cosine similarity against our pre-indexed Web AI & Architecture corpus right on your device.

Semantic Search QueryReady

### Top-K Local Vector Matches (Cosine Similarity)

[Apr 14, 2026Cosine: 0.942 (94%)WebMCP Explained: Exposing Browser-Native AI Tools with document.modelContextDeep dive into the W3C WebMCP specification, imperative registerTool() lifecycles with AbortController, and declarative HTML tool forms.](/post/webmcp-browser-native-model-context-protocol-guide)

## Web AI & Agent Architecture Trade-Off Matrix

How modern browser-native AI capabilities compare across latency, privacy, token economics, and ideal production workloads:

Web AI LayerBrowser API / StandardNetwork Latency & CostBest Production Use CaseWebMCP (Client-Side Agent Tools)`document.modelContext.registerTool` & ``0ms IPC / 90% fewer agent tokensExposing authenticated in-tab actions (search, filters, checkout, speaker kits) to browser AI assistants without fragile DOM scraping.Chrome Built-in AI (Gemini Nano)`LanguageModel`, `Summarizer`, `Rewriter`, `Translator`0ms RTT / $0 per 1M tokensPrivacy-sensitive drafting, instant article summaries, offline-capable UI helpers, and zero-cost pre-classification.Client-Side WebGPU / WebNN`navigator.gpu` + Transformers.js v3 / MediaPipe + OPFS0ms RTT / Local GPU ShadersLocal 384-d embeddings, client-side RAG over OPFS/IndexedDB, and real-time vision/audio inference.Hybrid Edge AI FallbackFirebase AI Logic (Gemini Flash) / Cloudflare Workers120ms to 380ms RTT / Metered APIFallback for devices without local NPU/GPU weights or complex multi-step reasoning and large context windows.