cd /news/developer-tools/beyond-dom-scraping-building-the-las… Β· home β€Ί topics β€Ί developer-tools β€Ί article
[ARTICLE Β· art-119395] src=dev.to β†— pub= topic=developer-tools verified=true sentiment=Β· neutral

Beyond DOM Scraping: Building "THE LAST TERMINAL" with WebMCP

A developer has built THE LAST TERMINAL, a browser-based cyberpunk escape room that demonstrates WebMCP (Web Model Context Protocol), an emerging standard allowing web applications to register machine-readable tools for AI agents instead of relying on DOM scraping. The project unifies execution logic so that human players and AI agents trigger the same game functions, and it exposes 10 structured tools representing facility subsystems.

read5 min views1 publishedSep 2, 2026

Project Title:THE LAST TERMINAL β€” WebMCP Escape Room

GitHub Repository:[https://github.com/scha54/WebMCP]

Live Demo:[https://webmcp-blush.vercel.app/]

For the past several years, autonomous browser agents have interacted with web applications primarily through DOM scraping and visual inspection. A typical AI browser workflow involves taking high-resolution screenshots, feeding them into a Vision-Language Model (VLM), predicting pixel coordinates or CSS selectors, and firing synthetic click and keypress events.

This approach suffers from critical flaws:

WebMCP (Web Model Context Protocol) is an emerging browser standard that solves this. Instead of forcing AI agents to reverse-engineer visual UIs, WebMCP allows web applications to directly register machine-readable tools (navigator.modelContext.registerTool

).

To demonstrate this paradigm shift, we built THE LAST TERMINALβ€”a polished, browser-based cyberpunk escape room where human players and AI agents collaborate to solve interconnected facility puzzles using shared WebMCP tool capabilities.

The core architectural principle behind THE LAST TERMINAL is Unified Execution Logic. The application never duplicates business logic for human interactions vs. agent interactions.

                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚     WEBMCP AGENT /       β”‚
                 β”‚     DEMO SIMULATOR       β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                      WebMCP Tool Calls
                              β”‚
                              β–Ό
 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
 β”‚                   THE LAST TERMINAL                       β”‚
 β”‚                                                           β”‚
 β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
 β”‚  β”‚                 src/lib/webmcp/                     β”‚  β”‚
 β”‚  β”‚   tools.ts Β· schemas.ts Β· registry.ts              β”‚  β”‚
 β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
 β”‚                             β”‚                             β”‚
 β”‚                             β–Ό                             β”‚
 β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
 β”‚  β”‚                  src/lib/game/                      β”‚  β”‚
 β”‚  β”‚   gameEngine.ts Β· gameState.ts Β· puzzles.ts         β”‚  β”‚
 β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
 β”‚                β”‚                         β”‚                β”‚
 β”‚                β–Ό                         β–Ό                β”‚
 β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
 β”‚  β”‚     Human Visual UI       β”‚ β”‚   Agent Activity      β”‚  β”‚
 β”‚  β”‚  (Facility Map & Systems) β”‚ β”‚   & Tool Trace Log    β”‚  β”‚
 β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

When a human user flips physical switches on the Power Control UI, the component triggers:

restorePower(['C', 'A', 'D', 'B'], 'human');

When an AI agent invokes the WebMCP tool restore_power

, the WebMCP execution context routes directly to the identical function:

restorePower(['C', 'A', 'D', 'B'], 'agent');

Both invocations mutate the central GameState

, trigger real-time UI updates, emit Web Audio synthesized feedback, and push a structured entry to the Agent Activity Feed.

The application exposes 10 structured tools representing realistic facility subsystems:

# Tool Name Description JSON Input Schema
1 get_game_state
Retrieves system lock statuses, discovered clues, and active view {}
2 inspect_system
Inspects facility subsystems (security , power , archive , etc.)
{ "system": "surveillance" }
3 read_log
Reads facility logs by ID (LOG-2049 )
{ "logId": "LOG-2049" }
4 inspect_surveillance
Inspects CCTV camera feeds (CAM-07 ) for frame anomalies
{ "cameraId": "CAM-07" }
5 decode_message
Decodes encrypted ciphers into override candidates { "message": "SURVEILLANCE_ANOMALY" }
6 restore_power
Restores auxiliary power using quad-switch sequence { "sequence": ["C", "A", "D", "B"] }
7 unlock_security
Unlocks security terminal with 4-digit passcode { "code": "7319" }
8 open_archive
Mounts archive database vault (requires auxiliary power) {}
9 inspect_archive
Queries archive records matching search terms { "query": "exit protocol" }
10 unlock_exit
Disengages emergency exit pneumatic doors { "code": "7319" }

restore_power

export const RESTORE_POWER_SCHEMA = {
  type: 'object',
  properties: {
    sequence: {
      type: 'array',
      items: { type: 'string' },
      description: 'Ordered list of switch labels, e.g. ["C", "A", "D", "B"].',
    },
  },
  required: ['sequence'],
  additionalProperties: false,
};

// WebMCP Tool Definition
{
  name: 'restore_power',
  description: 'Attempt to restore auxiliary power grid using an ordered 4-switch sequence.',
  inputSchema: RESTORE_POWER_SCHEMA,
  execute: (input: { sequence: string[] }, source = 'agent') => restorePower(input.sequence, source),
}

WebMCP tools should not be omnipotent "cheat codes." To demonstrate realistic agent reasoning, tools enforce environment prerequisites:

export function openArchive(source: ToolCallSource = 'agent') {
  // Prerequisite Guard
  if (currentGameState.power === 'offline') {
    const error = {
      code: 'PREREQUISITE_NOT_MET',
      message: 'Facility archive requires auxiliary power. Restore power first.',
    };
    recordToolCall('open_archive', {}, { error }, false, source);
    return { success: false, error };
  }

  currentGameState.archive = 'unlocked';
  // ... state progression
}

If an agent attempts open_archive()

while power is offline, WebMCP returns a structured JSON error response code PREREQUISITE_NOT_MET

. The agent reads this structured output, inspects logs to discover that power must be restored, and calls restore_power

first.

To register tools safely in React environments without re-registering on component re-renders, THE LAST TERMINAL implements an initialization guard module in src/lib/webmcp/registry.ts

:

let initialized = false;

export function registerWebMCPTools(): boolean {
  if (typeof window === 'undefined') return false;
  if (initialized) return isWebMCPAvailableInBrowser;

  try {
    // Polyfill window.__webmcp for browser inspection and agent simulators
    (window as any).__webmcp = {
      tools: WEBMCP_TOOLS,
      callTool: async (name: string, input: any, source = 'agent') => {
        const tool = WEBMCP_TOOLS.find((t) => t.name === name);
        return await tool.execute(input, source);
      },
    };

    // Native WebMCP Imperative API
    const nav = navigator as any;
    if (nav.modelContext && typeof nav.modelContext.registerTool === 'function') {
      WEBMCP_TOOLS.forEach((tool) => {
        nav.modelContext.registerTool({
          name: tool.name,
          description: tool.description,
          inputSchema: tool.inputSchema,
          execute: async (input: any) => await tool.execute(input, 'agent'),
        });
      });
      isWebMCPAvailableInBrowser = true;
    }

    initialized = true;
  } catch (e) {
    console.error('Failed to register WebMCP tools:', e);
  }

  return isWebMCPAvailableInBrowser;
}

For hackathon judges and developers, transparency is vital. The interface provides two real-time inspection features:

   23:51:04  AGENT  β†’ inspect_surveillance("CAM-07")
   23:51:05  SYSTEM ← clue discovered: 7319
   23:51:09  AGENT  β†’ unlock_security("7319")
   23:51:09  SYSTEM ← SECURITY UNLOCKED

human

, agent

, simulator

), JSON inputs, return objects, and execution durations.AudioContext

to generate retro cyberpunk typing clicks, success chimes, failure buzzers, and power-up sweeps without hosting external MP3 files.

git clone https://github.com/scha54/WebMCP.git
cd WebMCP
npm install
npm run test:engine
npm run build

vercel --prod

WebMCP transforms web applications from passive visual UIs into agentic APIs. By exposing structured tools alongside standard visual components, websites become directly operable by AI models with 90%+ token reduction and near-zero latency.

THE LAST TERMINAL proves that building WebMCP-compatible web apps is clean, robust, and framework-agnostic.

── more in #developer-tools 4 stories Β· sorted by recency
── more on @webmcp 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/beyond-dom-scraping-…] indexed:0 read:5min 2026-09-02 Β· β€”